From 8fea8f27ee949688c865a5302e2e011015d5cbbc Mon Sep 17 00:00:00 2001 From: Behzad Rabiei Date: Thu, 24 Oct 2024 16:22:02 +0400 Subject: [PATCH] bot: fix workdir --- bot/Dockerfile | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/bot/Dockerfile b/bot/Dockerfile index 8d69ad2f..2be18a06 100644 --- a/bot/Dockerfile +++ b/bot/Dockerfile @@ -1,19 +1,30 @@ -FROM node:18-alpine AS base - -# @pyroscope/nodejs issue: https://github.com/grafana/pyroscope-nodejs/issues/31 -RUN apk add g++ make py3-pip - +# Stage 1: Build the application +FROM node:20-alpine AS builder WORKDIR /app -COPY . . +COPY bot/package*.json ./ RUN npm ci - -FROM base AS test -CMD [ "npx", "jest", "--coverage" ] - -FROM base AS build +COPY bot/ . RUN npm run build -FROM build AS prod +# Stage 2: Development +FROM node:20-alpine AS development +WORKDIR /app +COPY --from=builder /app . +RUN npm install --only=development +EXPOSE 3000 +CMD ["npm", "run", "dev"] + +# Stage 3: Production +FROM node:20-alpine AS production +WORKDIR /app +COPY --from=builder /app . RUN npm ci --omit=dev -CMD ["npm", "run", "start"] -EXPOSE 3000 \ No newline at end of file +EXPOSE 3000 +CMD ["node", "dist/main"] + +# Stage 4: Testing +FROM node:20-alpine AS test +WORKDIR /app +COPY --from=builder /app . +RUN npm install --only=development +CMD ["npx", "jest", "--coverage"]