-
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
4e74991
commit 8fea8f2
Showing
1 changed file
with
25 additions
and
14 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,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 | ||
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"] |