-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8dab3fa
commit cac48f9
Showing
1 changed file
with
14 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |