Docker build failed Next.js

I am looking to deploy my next.js app on railway. I've added environment variables, added railway.toml file to root and I am still getting a docker failed error. It seems to be that there is a space after ENV on line 12 but not sure how to correct that? I dont have docker or access to that file. here is a copy of the build log:
Dockerfile:12

-------------------

10 |

11 | ARG CI NIXPACKS_METADATA NODE_ENV NPM_CONFIG_PRODUCTION RAILWAY_ENVIRONMENT RAILWAY_ENVIRONMENT_ID RAILWAY_ENVIRONMENT_NAME RAILWAY_GIT_AUTHOR RAILWAY_GIT_BRANCH RAILWAY_GIT_COMMIT_MESSAGE RAILWAY_GIT_COMMIT_SHA RAILWAY_GIT_REPO_NAME RAILWAY_GIT_REPO_OWNER RAILWAY_PROJECT_ID RAILWAY_PROJECT_NAME RAILWAY_PUBLIC_DOMAIN RAILWAY_SERVICE_ID RAILWAY_SERVICE_NAME RAILWAY_SERVICE_PROJECT_PIXEL_POUCH_URL RAILWAY_STATIC_URL

12 | >>> ENV =$ CI=$CI NIXPACKS_METADATA=$NIXPACKS_METADATA NODE_ENV=$NODE_ENV NPM_CONFIG_PRODUCTION=$NPM_CONFIG_PRODUCTION RAILWAY_ENVIRONMENT=$RAILWAY_ENVIRONMENT RAILWAY_ENVIRONMENT_ID=$RAILWAY_ENVIRONMENT_ID RAILWAY_ENVIRONMENT_NAME=$RAILWAY_ENVIRONMENT_NAME RAILWAY_GIT_AUTHOR=$RAILWAY_GIT_AUTHOR RAILWAY_GIT_BRANCH=$RAILWAY_GIT_BRANCH RAILWAY_GIT_COMMIT_MESSAGE=$RAILWAY_GIT_COMMIT_MESSAGE RAILWAY_GIT_COMMIT_SHA=$RAILWAY_GIT_COMMIT_SHA RAILWAY_GIT_REPO_NAME=$RAILWAY_GIT_REPO_NAME RAILWAY_GIT_REPO_OWNER=$RAILWAY_GIT_REPO_OWNER RAILWAY_PROJECT_ID=$RAILWAY_PROJECT_ID RAILWAY_PROJECT_NAME=$RAILWAY_PROJECT_NAME RAILWAY_PUBLIC_DOMAIN=$RAILWAY_PUBLIC_DOMAIN RAILWAY_SERVICE_ID=$RAILWAY_SERVICE_ID RAILWAY_SERVICE_NAME=$RAILWAY_SERVICE_NAME RAILWAY_SERVICE_PROJECT_PIXEL_POUCH_URL=$RAILWAY_SERVICE_PROJECT_PIXEL_POUCH_URL RAILWAY_STATIC_URL=$RAILWAY_STATIC_URL

13 |

14 | # setup phase

-------------------

ERROR: failed to solve: dockerfile parse error on line 12: ENV names can not be blank



Error: Docker build failed
Dockerfile:12

-------------------

10 |

11 | ARG CI NIXPACKS_METADATA NODE_ENV NPM_CONFIG_PRODUCTION RAILWAY_ENVIRONMENT RAILWAY_ENVIRONMENT_ID RAILWAY_ENVIRONMENT_NAME RAILWAY_GIT_AUTHOR RAILWAY_GIT_BRANCH RAILWAY_GIT_COMMIT_MESSAGE RAILWAY_GIT_COMMIT_SHA RAILWAY_GIT_REPO_NAME RAILWAY_GIT_REPO_OWNER RAILWAY_PROJECT_ID RAILWAY_PROJECT_NAME RAILWAY_PUBLIC_DOMAIN RAILWAY_SERVICE_ID RAILWAY_SERVICE_NAME RAILWAY_SERVICE_PROJECT_PIXEL_POUCH_URL RAILWAY_STATIC_URL

12 | >>> ENV =$ CI=$CI NIXPACKS_METADATA=$NIXPACKS_METADATA NODE_ENV=$NODE_ENV NPM_CONFIG_PRODUCTION=$NPM_CONFIG_PRODUCTION RAILWAY_ENVIRONMENT=$RAILWAY_ENVIRONMENT RAILWAY_ENVIRONMENT_ID=$RAILWAY_ENVIRONMENT_ID RAILWAY_ENVIRONMENT_NAME=$RAILWAY_ENVIRONMENT_NAME RAILWAY_GIT_AUTHOR=$RAILWAY_GIT_AUTHOR RAILWAY_GIT_BRANCH=$RAILWAY_GIT_BRANCH RAILWAY_GIT_COMMIT_MESSAGE=$RAILWAY_GIT_COMMIT_MESSAGE RAILWAY_GIT_COMMIT_SHA=$RAILWAY_GIT_COMMIT_SHA RAILWAY_GIT_REPO_NAME=$RAILWAY_GIT_REPO_NAME RAILWAY_GIT_REPO_OWNER=$RAILWAY_GIT_REPO_OWNER RAILWAY_PROJECT_ID=$RAILWAY_PROJECT_ID RAILWAY_PROJECT_NAME=$RAILWAY_PROJECT_NAME RAILWAY_PUBLIC_DOMAIN=$RAILWAY_PUBLIC_DOMAIN RAILWAY_SERVICE_ID=$RAILWAY_SERVICE_ID RAILWAY_SERVICE_NAME=$RAILWAY_SERVICE_NAME RAILWAY_SERVICE_PROJECT_PIXEL_POUCH_URL=$RAILWAY_SERVICE_PROJECT_PIXEL_POUCH_URL RAILWAY_STATIC_URL=$RAILWAY_STATIC_URL

13 |

14 | # setup phase

-------------------

ERROR: failed to solve: dockerfile parse error on line 12: ENV names can not be blank



Error: Docker build failed
project id: 7a7981e0-b081-4941-8efd-d9c6a55d5383
31 Replies
Percy
Percy12mo ago
Project ID: 7a7981e0-b081-4941-8efd-d9c6a55d5383
Lukoolios
LukooliosOP12mo ago
Looks like discord auto corrected the error and turned it into an unamused emoji. I believe it is supposed to be ENV=$ but there is an added space before the assignment operator
Brody
Brody12mo ago
enclose it in triple backticks edit your original message
Lukoolios
LukooliosOP12mo ago
yea caught that sorry haha
Brody
Brody12mo ago
do you have a service variable with a blank name?
Lukoolios
LukooliosOP12mo ago
negative and I checked for added spaces before and after
Brody
Brody12mo ago
can you show me the variables you do have? (just the variable names)
Lukoolios
LukooliosOP12mo ago
No description
Brody
Brody12mo ago
thats it?
Lukoolios
LukooliosOP12mo ago
correct
Brody
Brody12mo ago
try deploying your repo in a new railway service
Lukoolios
LukooliosOP12mo ago
That seemed to get it past that issue though now I am running into a nope version compatability, Next.js requires at least version >= 18 and looks like 16.18.1 is whats avaialble?
#12 0.757 > next build

#12 0.757

#12 0.847 You are using Node.js 16.18.1. For Next.js, Node.js version >= v18.17.0 is required.



#12 ERROR: process "/bin/bash -ol pipefail -c npm run build" did not complete successfully: exit code: 1

-----

> [stage-0 8/10] RUN --mount=type=cache,id=s/c9969c3c-7588-4025-8b46-207ea0e007f3-next/cache,target=/app/.next/cache --mount=type=cache,id=s/c9969c3c-7588-4025-8b46-207ea0e007f3-node_modules/cache,target=/app/node_modules/.cache npm run build:

0.743 npm WARN config production Use `--omit=dev` instead.

0.757

0.757 > [email protected] build

0.757 > next build

0.757

0.847 You are using Node.js 16.18.1. For Next.js, Node.js version >= v18.17.0 is required.

-----



Dockerfile:24

-------------------

22 | # build phase

23 | COPY . /app/.

24 | >>> RUN --mount=type=cache,id=s/c9969c3c-7588-4025-8b46-207ea0e007f3-next/cache,target=/app/.next/cache --mount=type=cache,id=s/c9969c3c-7588-4025-8b46-207ea0e007f3-node_modules/cache,target=/app/node_modules/.cache npm run build

25 |

26 |

-------------------

ERROR: failed to solve: process "/bin/bash -ol pipefail -c npm run build" did not complete successfully: exit code: 1



Error: Docker build failed
#12 0.757 > next build

#12 0.757

#12 0.847 You are using Node.js 16.18.1. For Next.js, Node.js version >= v18.17.0 is required.



#12 ERROR: process "/bin/bash -ol pipefail -c npm run build" did not complete successfully: exit code: 1

-----

> [stage-0 8/10] RUN --mount=type=cache,id=s/c9969c3c-7588-4025-8b46-207ea0e007f3-next/cache,target=/app/.next/cache --mount=type=cache,id=s/c9969c3c-7588-4025-8b46-207ea0e007f3-node_modules/cache,target=/app/node_modules/.cache npm run build:

0.743 npm WARN config production Use `--omit=dev` instead.

0.757

0.757 > [email protected] build

0.757 > next build

0.757

0.847 You are using Node.js 16.18.1. For Next.js, Node.js version >= v18.17.0 is required.

-----



Dockerfile:24

-------------------

22 | # build phase

23 | COPY . /app/.

24 | >>> RUN --mount=type=cache,id=s/c9969c3c-7588-4025-8b46-207ea0e007f3-next/cache,target=/app/.next/cache --mount=type=cache,id=s/c9969c3c-7588-4025-8b46-207ea0e007f3-node_modules/cache,target=/app/node_modules/.cache npm run build

25 |

26 |

-------------------

ERROR: failed to solve: process "/bin/bash -ol pipefail -c npm run build" did not complete successfully: exit code: 1



Error: Docker build failed
Brody
Brody12mo ago
set engines.node to 18 in your package.json
Lukoolios
LukooliosOP12mo ago
1.613 You are using Node.js 18.12.1. For Next.js, Node.js version >= v18.17.0 is required.
1.613 You are using Node.js 18.12.1. For Next.js, Node.js version >= v18.17.0 is required.
should I specify the 18.17.0 version?
Brody
Brody12mo ago
no, only specifying major versions is supported
Lukoolios
LukooliosOP12mo ago
setting it to 18 still has the version compatibility conflict
Brody
Brody12mo ago
what version is being used
Lukoolios
LukooliosOP12mo ago
18.12.1 iv'e tried other major versions and they all revert back to version 16, is this going to be a stopper?
Brody
Brody12mo ago
other major versions?
Lukoolios
LukooliosOP12mo ago
seems that the latest version is 21? at least when I installed node locally anyway
Brody
Brody12mo ago
show me your package.json with engines.node set to 21 please
Lukoolios
LukooliosOP12mo ago
No description
Brody
Brody12mo ago
okay and show me the build table from the latest build using that package.json
Lukoolios
LukooliosOP12mo ago
> [stage-0 8/10] RUN --mount=type=cache,id=s/c9969c3c-7588-4025-8b46-207ea0e007f3-next/cache,target=/app/.next/cache --mount=type=cache,id=s/c9969c3c-7588-4025-8b46-207ea0e007f3-node_modules/cache,target=/app/node_modules/.cache npm run build:

WARN config production Use `--omit=dev` instead.

0.689

0.689 > [email protected] build

0.689 > next build

0.689

0.768 You are using Node.js 16.18.1. For Next.js, Node.js version >= v18.17.0 is required.

-----



Dockerfile:24

-------------------

22 | # build phase

23 | COPY . /app/.

24 | >>> RUN --mount=type=cache,id=s/c9969c3c-7588-4025-8b46-207ea0e007f3-next/cache,target=/app/.next/cache --mount=type=cache,id=s/c9969c3c-7588-4025-8b46-207ea0e007f3-node_modules/cache,target=/app/node_modules/.cache npm run build

25 |

26 |

-------------------

ERROR: failed to solve: process "/bin/bash -ol pipefail -c npm run build" did not complete successfully: exit code: 1



Error: Docker build failed
> [stage-0 8/10] RUN --mount=type=cache,id=s/c9969c3c-7588-4025-8b46-207ea0e007f3-next/cache,target=/app/.next/cache --mount=type=cache,id=s/c9969c3c-7588-4025-8b46-207ea0e007f3-node_modules/cache,target=/app/node_modules/.cache npm run build:

WARN config production Use `--omit=dev` instead.

0.689

0.689 > [email protected] build

0.689 > next build

0.689

0.768 You are using Node.js 16.18.1. For Next.js, Node.js version >= v18.17.0 is required.

-----



Dockerfile:24

-------------------

22 | # build phase

23 | COPY . /app/.

24 | >>> RUN --mount=type=cache,id=s/c9969c3c-7588-4025-8b46-207ea0e007f3-next/cache,target=/app/.next/cache --mount=type=cache,id=s/c9969c3c-7588-4025-8b46-207ea0e007f3-node_modules/cache,target=/app/node_modules/.cache npm run build

25 |

26 |

-------------------

ERROR: failed to solve: process "/bin/bash -ol pipefail -c npm run build" did not complete successfully: exit code: 1



Error: Docker build failed
Brody
Brody12mo ago
show me the build table from the latest build using that package.json please
Lukoolios
LukooliosOP12mo ago
sorry what does that refence?
Brody
Brody12mo ago
the build table, at the top of the logs
Lukoolios
LukooliosOP12mo ago
No description
Brody
Brody12mo ago
youre on an old version of nixpacks, why?
Lukoolios
LukooliosOP12mo ago
ah that was from the railway.toml file. was added that due to a past helpdesk question. I removed it and it looks like it built successfully thank you!
Brody
Brody12mo ago
no problem!
Want results from more Discord servers?
Add your server