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
Percy11mo ago
Project ID: 7a7981e0-b081-4941-8efd-d9c6a55d5383
Lukoolios
Lukoolios11mo 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
Brody11mo ago
enclose it in triple backticks edit your original message
Lukoolios
Lukoolios11mo ago
yea caught that sorry haha
Brody
Brody11mo ago
do you have a service variable with a blank name?
Lukoolios
Lukoolios11mo ago
negative and I checked for added spaces before and after
Brody
Brody11mo ago
can you show me the variables you do have? (just the variable names)
Lukoolios
Lukoolios11mo ago
No description
Brody
Brody11mo ago
thats it?
Lukoolios
Lukoolios11mo ago
correct
Brody
Brody11mo ago
try deploying your repo in a new railway service
Lukoolios
Lukoolios11mo 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
Brody11mo ago
set engines.node to 18 in your package.json
Lukoolios
Lukoolios11mo 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
Brody11mo ago
no, only specifying major versions is supported
Lukoolios
Lukoolios11mo ago
setting it to 18 still has the version compatibility conflict
Brody
Brody11mo ago
what version is being used
Lukoolios
Lukoolios11mo 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
Brody11mo ago
other major versions?
Lukoolios
Lukoolios11mo ago
seems that the latest version is 21? at least when I installed node locally anyway
Brody
Brody11mo ago
show me your package.json with engines.node set to 21 please
Lukoolios
Lukoolios11mo ago
No description
Brody
Brody11mo ago
okay and show me the build table from the latest build using that package.json
Lukoolios
Lukoolios11mo 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
Brody11mo ago
show me the build table from the latest build using that package.json please
Lukoolios
Lukoolios11mo ago
sorry what does that refence?
Brody
Brody11mo ago
the build table, at the top of the logs
Lukoolios
Lukoolios11mo ago
No description
Brody
Brody11mo ago
youre on an old version of nixpacks, why?
Lukoolios
Lukoolios11mo 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
Brody11mo ago
no problem!
Want results from more Discord servers?
Add your server