a year ago
I'm deploying a Discord bot but I'm getting this returned error, the package is installed and working fine on local
0 Replies
a year ago
is it installed in the dependencies or the dev dependencies
a year 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" ]
```
a year ago
try utilizing a lock file and install from the lock file
a year ago
not sure what you mean by sending
a year ago
your lock file should definitely be in your repo, and used to install the dependencies from
a year ago
are you sure railway is using your Dockerfile?
a year ago
there's just some simple config issue somewhere with your project
a year ago
please show me the updated dockerfile
a year 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" ]
```
a year ago
install from the lock file
a year ago
that is what you would want to be using in a production environment
a year 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" ]
```
a year ago
please update your dockerfile with this
a year ago
locally, delete your node_modules and then run yarn install --frozen-lockfile
and start your project
a year ago
what node version are you using locally
a year ago
what version of node is node:lts-alpine
a year ago
its 20.13.1
a year ago
try using node:20.11.0-alpine
a year ago
in your dockerfile, run a prune and then copy the node_modules folder into the final layer
a year ago
please take everything i said in this message into account
a year ago
no problem