How to deploy fullstack sveltekit app

nwaughachukwuma
PRO

7 months ago

I use pnpm workspaces making it tricky to run install when building on railway. Find my Dockerfile below.

[Dockerfile]

Use the Node alpine official image

https://hub.docker.com/_/node

FROM node:lts-alpine

Create and change to the app directory.

WORKDIR /app

install pnpm

RUN npm install -g pnpm
RUN npm install -g remove-workspace-deps

Copy the files to the container image

COPY package*.json ./
RUN npm run remove-workspace-deps

Install packages

RUN npm install

Copy local code to the container image.

COPY . ./

Build the app.

RUN npm run sync && npm run build

Serve the app

CMD ["npm", "run", "start"]

View Deploy details

ⓘ Deployment information is only viewable by project members and Railway employees.

10 Replies

7 months ago

Hello,

Is this a shared monorepo? aka does the web app import anything from other packages?


nwaughachukwuma
PRO

7 months ago

Hi @brody, yes it's a monorepo with things like "@projectname/package": "workspace:*"


7 months ago

Then you would want to deploy from the root directory, you are currently set to deploy from src/ui/app


nwaughachukwuma
PRO

7 months ago

Ok, thanks. I'll give it a try and revert.


nwaughachukwuma
PRO

7 months ago

Cool. It works alright, thanks!

Please how do I declare GOOGLE_APPLICATION_CREDENTIALS env variable? It's throwing the following error if I store the JSON value

[error (slightly modified for sensitive values)]
Error: The file at { 19:51:44.722 "type": "service_account",
19:51:44.724 at Object.realpathSync (node:fs:2729:29) 19:51:44.725 at GoogleAuth._getApplicationCredentialsFromFilePath (/opt/buildhome/repo/node_modules/.pnpm/google-auth-library@9.15.0/node_modules/google-auth-library/build/src/auth/googleauth.js:375:27) 19:51:44.725 at GoogleAuth._tryGetApplicationCredentialsFromEnvironmentVariable (/opt/buildhome/repo/node_modules/.pnpm/google-auth-library@9.15.0/node_modules/google-auth-library/build/src/auth/googleauth.js:316:25) 19:51:44.725 at GoogleAuth.getApplicationDefaultAsync (/opt/buildhome/repo/node_modules/.pnpm/google-auth-library@9.15.0/node_modules/google-auth-library/build/src/auth/googleauth.js:260:24) 19:51:44.725 at GoogleAuth._GoogleAuth_determineClient (/opt/buildhome/repo/node_modules/.pnpm/google-auth-library@9.15.0/node_modules/google-auth-library/build/src/auth/googleauth.js:832:43) 19:51:44.725 at GoogleAuth.getClient (/opt/buildhome/repo/node_modules/.pnpm/google-auth-library@9.15.0/node_modules/google-auth-library/build/src/auth/googleauth.js:694:223) 19:51:44.725 at GoogleAuth.getIdTokenClient (/opt/buildhome/repo/node_modules/.pnpm/google-auth-library@9.15.0/node_modules/google-auth-library/build/src/auth/googleauth.js:709:35) 19:51:44.725 at a (file:///opt/buildhome/repo/src/ui/app/.svelte-kit/output/server/chunks/sfetch.server.js:1:238) 19:51:44.725 at <static_initializer> (file:///opt/buildhome/repo/src/ui/app/.svelte-kit/output/server/chunks/sfetch.server.js:1:965) 19:51:44.725 at file:///opt/buildhome/repo/src/ui/app/.svelte-kit/output/server/chunks/sfetch.server.js:1:886 19:51:44.726 Emitted 'error' event on Worker instance at: 19:51:44.726 at [kOnErrorMessage] (node:internal/worker:326:10) 19:51:44.726 at [kOnMessage] (node:internal/worker:337:37) 19:51:44.726 at MessagePort.<anonymous> (node:internal/worker:232:57) 19:51:44.726 at [nodejs.internal.kHybridDispatch] (node:internal/event_target:820:20) 19:51:44.726 at MessagePort.<anonymous> (node:internal/per_context/messageport:23:28) { 19:51:44.726 errno: -36, 19:51:44.726 code: 'ENAMETOOLONG',

19:51:44.727 } 19:51:44.727 19:51:44.727 Node.js v20.17.0 19:51:44.773  ELIFECYCLE  Command failed with exit code 1. 19:51:44.803  ELIFECYCLE  Command failed with exit code 1. 19:51:44.825 Failed: Error while executing user command. Exited with error code: 1 19:51:44.836 Failed: build command exited with code: 1 19:51:45.629 Failed: error occurred while running build command


7 months ago

Hello,

You can do that by setting a service variable -

https://docs.railway.com/overview/the-basics#service-variables


nwaughachukwuma
PRO

7 months ago

Yeah, that's what I did before which led to the error above.


7 months ago

Should I be looking at the preview environment?

If so, I think this docs section will help you -

https://docs.railway.com/guides/dockerfiles#using-variables-at-build-time


nwaughachukwuma
PRO

7 months ago

Thanks so much!


7 months ago

Everything working?


How to deploy fullstack sveltekit app - Railway Help Station