9 months ago
I'm using Railway as Trial and want to upgrade to Pro after resolve some issues.
In first, My project which deployed on Railway is made of Next.js 14.
To inject environment variables, I'm trying to use 'New Variable' on Variables tab, but can't deploy the project.
I also named the environment variables with NEXT_PUBLIC_ prefix.
Build Logs says that environment variables are undefined.
At now, To inject environment variables, make .env.production file in my source and push to GitHub Repository.
But, I want to use Variables tab to inject environment variables.
How to do that?
---
Here is the Build Logs.
#13 10.45 ✓ Compiled successfully
#13 10.45 Linting and checking validity of types ...
#13 12.59 Collecting page data ...
#13 13.85 Generating static pages (0/10) ...
#13 14.02 Generating static pages (2/10)
#13 14.08 Error: NEXT_PUBLIC_SUPABASE_URL, NEXT_PUBLIC_SUPABASE_ANON_KEY must be SET <- This error is made by self that if the variables are undefined, will throw.
#13 14.08 at 5298 (/app/.next/server/app/profile/page.js:1:7028)
#13 14.08 at t (/app/.next/server/webpack-runtime.js:1:143)
#13 14.08 at 695 (/app/.next/server/app/profile/page.js:1:6486)
#13 14.08 at t (/app/.next/server/webpack-runtime.js:1:143)
#13 14.08 at 9776 (/app/.next/server/app/profile/page.js:1:3191)
#13 14.08 at Object.t [as require] (/app/.next/server/webpack-runtime.js:1:143)
#13 14.08 at require (/app/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:16:18365)
#13 14.08 at I (/app/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:94362)
#13 14.08 at /app/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:96668
#13 14.08 at F._fromJSON (/app/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:97106) {
#13 14.08 digest: '2596267883'
#13 14.08 }
> [stage-0 9/11] RUN --mount=type=cache,id=s/30af292b-687f-4745-9a4b-b5ce3e8fba80-next/cache,target=/app/.next/cache --mount=type=cache,id=s/30af292b-687f-4745-9a4b-b5ce3e8fba80-node_modules/cache,target=/app/node_modules/.cache yarn run build:
14.12 at JSON.parse (<anonymous>)
14.12 at O (/app/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:94083)
14.13
14.13 > Export encountered errors on following paths:
14.13 /_not-found/page: /_not-found
14.13 /fnq/page: /fnq
14.13 /login/page: /login
14.13 /magic-link-login/page: /magic-link-login
14.13 /page: /
14.13 /profile/page: /profile
-----
2 warnings found (use --debug to expand):
- UndefinedVar: Usage of undefined variable '$NIXPACKS_PATH' (line 18)
LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format (line 18)
Dockerfile:25
-------------------
23 | # build phase
24 | COPY . /app/.
25 | >>> RUN --mount=type=cache,id=s/30af292b-687f-4745-9a4b-b5ce3e8fba80-next/cache,target=/app/.next/cache --mount=type=cache,id=s/30af292b-687f-4745-9a4b-b5ce3e8fba80-node_modules/cache,target=/app/node_modules/.cache yarn run build
26 |
27 |
-------------------
ERROR: failed to solve: process "/bin/bash -ol pipefail -c yarn run build" did not complete successfully: exit code: 1
Error: Docker build failed
Thanks.
4 Replies
9 months ago
Hey, i'm not seeing any of the errors mentioned in the latest build, is this good to mark as solved?
9 months ago
Hey, i'm not seeing any of the errors mentioned in the latest build, is this good to mark as solved?
Hi, you can see that the errors at BUILD ID: 4f3b1f62-c24c-4da4-a926-96ca89f1f686
9 months ago
Perhaps this docs section will be of help - https://docs.railway.app/guides/dockerfiles#using-variables-at-build-time
9 months ago
I'll share either success or fail. Thank you!