-
Notifications
You must be signed in to change notification settings - Fork 0
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
3c485f6
commit f4012e6
Showing
1 changed file
with
58 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,58 @@ | ||
FROM node:20.10.0-alpine3.18 AS node | ||
ENV NODE_OPTIONS --unhandled-rejections=strict --enable-source-maps | ||
WORKDIR /app | ||
|
||
# | ||
# Stage: NPM environment | ||
# | ||
FROM node AS npm | ||
COPY .npmrc \ | ||
package.json \ | ||
package-lock.json \ | ||
./ | ||
|
||
# | ||
# Stage: Development NPM install | ||
# | ||
FROM npm AS npm-dev | ||
|
||
RUN npm ci | ||
|
||
# | ||
# Stage: Production NPM install | ||
# | ||
FROM npm AS npm-prod | ||
|
||
RUN npm ci --production | ||
|
||
# | ||
# Stage: Production build | ||
# | ||
FROM npm AS build-prod | ||
ENV NODE_ENV=production | ||
|
||
COPY --from=npm-dev /app/node_modules/ node_modules/ | ||
COPY tsconfig.build.json \ | ||
tsconfig.json \ | ||
./ | ||
COPY src/ src/ | ||
|
||
RUN npx tsc --project tsconfig.build.json | ||
|
||
# | ||
# Stage: Production environment | ||
# | ||
FROM node AS prod | ||
ENV NODE_ENV=production | ||
|
||
RUN echo "{\"type\": \"module\"}" > package.json | ||
COPY --from=npm-prod /app/node_modules/ node_modules/ | ||
COPY --from=build-prod /app/dist/ dist/ | ||
|
||
HEALTHCHECK --interval=5s --timeout=1s \ | ||
CMD wget --quiet --tries=1 --spider http://localhost:3000/health || exit 1 | ||
|
||
EXPOSE 3000 | ||
USER node | ||
|
||
CMD ["node", "dist/index.js"] |