2 years ago
I'm deploying a Discord bot but I'm getting this returned error, the package is installed and working fine on local
48 Replies
2 years ago
is it installed in the dependencies or the dev dependencies
2 years ago
is your lock file in sync
```## build runner
FROM node:lts-alpine as build-runner
Set temp directory
WORKDIR /tmp/app
Move package.json
COPY package.json .
Install dependencies
RUN yarn install
Move source files
COPY src ./src
COPY tsconfig.json .
COPY prisma ./prisma
Generate Prisma Client
RUN npx prisma generate
Build project
RUN yarn run build
production runner
FROM node:lts-alpine as prod-runner
Set work directory
WORKDIR /app
Copy package.json from build-runner
COPY --from=build-runner /tmp/app/package.json /app/package.json
Move build files
COPY --from=build-runner /tmp/app/build /app/build
Start bot
CMD [ "yarn", "run", "start" ]
```
2 years ago
try utilizing a lock file and install from the lock file
2 years ago
not sure what you mean by sending
2 years ago
your lock file should definitely be in your repo, and used to install the dependencies from
2 years ago
are you sure railway is using your Dockerfile?
2 years ago
there's just some simple config issue somewhere with your project
2 years ago
please show me the updated dockerfile
2 years ago
please see my message, this requires you to change the dockerfile a little bit
```## build runner
FROM node:lts-alpine as build-runner
Set temp directory
WORKDIR /tmp/app
Move package.json and yarn.lock
COPY package.json yarn.lock ./
Install dependencies
RUN yarn install
Move source files
COPY src ./src
COPY tsconfig.json .
COPY prisma ./prisma
Generate Prisma Client
RUN npx prisma generate
Build project
RUN yarn run build
production runner
FROM node:lts-alpine as prod-runner
Set work directory
WORKDIR /app
Copy package.json from build-runner
COPY --from=build-runner /tmp/app/package.json /app/package.json
COPY --from=build-runner /tmp/app/yarn.lock /app/yarn.lock
Move build files
COPY --from=build-runner /tmp/app/build /app/build
Start bot
CMD [ "yarn", "run", "start" ]
```
2 years ago
install from the lock file
2 years ago
that is what you would want to be using in a production environment
2 years ago
exactly what you just sent
```## build runner
FROM node:lts-alpine as build-runner
Set temp directory
WORKDIR /tmp/app
Move package.json and yarn.lock
COPY package.json yarn.lock ./
Install dependencies
RUN yarn install --frozen-lockfile
Move source files
COPY src ./src
COPY tsconfig.json .
COPY prisma ./prisma
Generate Prisma Client
RUN npx prisma generate
Build project
RUN yarn run build
production runner
FROM node:lts-alpine as prod-runner
Set work directory
WORKDIR /app
Copy package.json from build-runner
COPY --from=build-runner /tmp/app/package.json /app/package.json
COPY --from=build-runner /tmp/app/yarn.lock /app/yarn.lock
Move build files
COPY --from=build-runner /tmp/app/build /app/build
Start bot
CMD [ "yarn", "run", "start" ]
```
2 years ago
please update your dockerfile with this
2 years ago
locally, delete your node_modules and then run yarn install --frozen-lockfile and start your project
2 years ago
what node version are you using locally
2 years ago
what version of node is node:lts-alpine
2 years ago
its 20.13.1
2 years ago
try using node:20.11.0-alpine
2 years ago
in your dockerfile, run a prune and then copy the node_modules folder into the final layer
You mean COPY --from=build-runner /tmp/app/node_modules /app/node_modules?
2 years ago
please take everything i said in this message into account
2 years ago
no problem

