Skip to content

Commit

Permalink
bot: fix dockerFile
Browse files Browse the repository at this point in the history
  • Loading branch information
Behzad-rabiei committed Oct 24, 2024
1 parent 8dab3fa commit cac48f9
Showing 1 changed file with 14 additions and 27 deletions.
41 changes: 14 additions & 27 deletions bot/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,32 +1,19 @@
# Dockerfile
# Stage 1: Build the application
FROM node:20-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build
FROM node:18-alpine AS base

# 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"]
# @pyroscope/nodejs issue: https://github.com/grafana/pyroscope-nodejs/issues/31
RUN apk add g++ make py3-pip

# Stage 3: Production
FROM node:20-alpine AS production
WORKDIR /app
COPY --from=builder /app .
WORKDIR /project/bot
COPY . .
RUN npm install --only=production --ignore-scripts
EXPOSE 3000
CMD ["node", "dist/main"]
RUN npm ci

# Stage 4: Testing
FROM node:20-alpine AS test
WORKDIR /app
COPY --from=builder /app .
RUN npm install --only=development
FROM base AS test
CMD [ "npx", "jest", "--coverage" ]

FROM base AS build
RUN npm run build

FROM build AS prod
RUN npm ci --omit=dev
CMD ["npm", "run", "start"]
EXPOSE 3000

0 comments on commit cac48f9

Please sign in to comment.