docker setup

This commit is contained in:
Oleksandr Honcharov 2024-06-08 19:08:41 +03:00
parent 1fdb8f451b
commit f028f3d708
2 changed files with 17 additions and 9 deletions

View File

@ -1,5 +1,9 @@
## build runner
FROM node:lts-alpine as build-runner
FROM node:20-slim as build-runner
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable
# Set temp directory
WORKDIR /tmp/app
@ -8,17 +12,22 @@ WORKDIR /tmp/app
COPY package.json .
# Install dependencies
RUN npm install
RUN pnpm install
# Move source files
COPY src ./src
COPY tsconfig.json .
COPY tsup.config.ts .
# Build project
RUN npm run build
RUN pnpm build
## production runner
FROM node:lts-alpine as prod-runner
FROM node:20-slim as prod-runner
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable
# Set work directory
WORKDIR /app
@ -27,10 +36,10 @@ WORKDIR /app
COPY --from=build-runner /tmp/app/package.json /app/package.json
# Install dependencies
RUN npm install --omit=dev
RUN pnpm install --prod
# Move build files
COPY --from=build-runner /tmp/app/build /app/build
# Start bot
CMD [ "npm", "run", "start" ]
CMD [ "pnpm", "start" ]

View File

@ -1,7 +1,6 @@
version: "3"
services:
app:
build: .
command: node build/main.js
command: node build/index.mjs
environment:
- BOT_TOKEN=${BOT_TOKEN}