Inject environment variables through Railway.

dellilTRIAL

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

Aug 07 18:35:15

the-file

Aug 07 18:35:16

the-file

#13 10.45 Linting and checking validity of types ...

Aug 07 18:35:16

the-file

Aug 07 18:35:18

the-file

#13 12.59 Collecting page data ...

Aug 07 18:35:18

the-file

Aug 07 18:35:19

the-file

#13 13.85 Generating static pages (0/10) ...

Aug 07 18:35:19

the-file

Aug 07 18:35:19

the-file

#13 14.02 Generating static pages (2/10)

Aug 07 18:35:19

the-file

Aug 07 18:35:19

the-file

#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.

Aug 07 18:35:19

the-file

#13 14.08 at 5298 (/app/.next/server/app/profile/page.js:1:7028)

Aug 07 18:35:19

the-file

#13 14.08 at t (/app/.next/server/webpack-runtime.js:1:143)

Aug 07 18:35:19

the-file

#13 14.08 at 695 (/app/.next/server/app/profile/page.js:1:6486)

Aug 07 18:35:19

the-file

#13 14.08 at t (/app/.next/server/webpack-runtime.js:1:143)

Aug 07 18:35:19

the-file

#13 14.08 at 9776 (/app/.next/server/app/profile/page.js:1:3191)

Aug 07 18:35:19

the-file

#13 14.08 at Object.t [as require] (/app/.next/server/webpack-runtime.js:1:143)

Aug 07 18:35:19

the-file

#13 14.08 at require (/app/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:16:18365)

Aug 07 18:35:19

the-file

#13 14.08 at I (/app/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:94362)

Aug 07 18:35:19

the-file

#13 14.08 at /app/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:96668

Aug 07 18:35:19

the-file

#13 14.08 at F._fromJSON (/app/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:97106) {

Aug 07 18:35:19

the-file

#13 14.08 digest: '2596267883'

Aug 07 18:35:19

the-file

#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:

Aug 07 18:35:19

the-file

14.12 at JSON.parse (<anonymous>)

Aug 07 18:35:19

the-file

14.12 at O (/app/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:94083)

Aug 07 18:35:19

the-file

14.13

Aug 07 18:35:19

the-file

14.13 > Export encountered errors on following paths:

Aug 07 18:35:19

the-file

14.13 /_not-found/page: /_not-found

Aug 07 18:35:19

the-file

14.13 /fnq/page: /fnq

Aug 07 18:35:19

the-file

14.13 /login/page: /login

Aug 07 18:35:19

the-file

14.13 /magic-link-login/page: /magic-link-login

Aug 07 18:35:19

the-file

14.13 /page: /

Aug 07 18:35:19

the-file

14.13 /profile/page: /profile

Aug 07 18:35:19

the-file

-----

Aug 07 18:35:19

the-file

Aug 07 18:35:19

the-file

Aug 07 18:35:19

the-file

2 warnings found (use --debug to expand):

Aug 07 18:35:19

the-file

- UndefinedVar: Usage of undefined variable '$NIXPACKS_PATH' (line 18)

Aug 07 18:35:19

the-file

LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format (line 18)

Aug 07 18:35:19

the-file

Aug 07 18:35:19

the-file

Dockerfile:25

Aug 07 18:35:19

the-file

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

Aug 07 18:35:19

the-file

23 | # build phase

Aug 07 18:35:19

the-file

24 | COPY . /app/.

Aug 07 18:35:19

the-file

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

Aug 07 18:35:19

the-file

26 |

Aug 07 18:35:19

the-file

27 |

Aug 07 18:35:19

the-file

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

Aug 07 18:35:19

the-file

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

Aug 07 18:35:19

the-file

Aug 07 18:35:19

the-file

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?


dellilTRIAL

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


dellilTRIAL

9 months ago

I'll share either success or fail. Thank you!