generated from bcgov/quickstart-openshift
-
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
Showing
27 changed files
with
4,822 additions
and
1,690 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,40 +1,44 @@ | ||
FROM node:20.11.0-bullseye-slim AS build | ||
# Build static files | ||
# Node Bullseye has npm | ||
FROM node:20.11.0-bullseye-slim AS buildWithDevDeps | ||
|
||
# Install packages, build and keep only prod packages | ||
WORKDIR /app | ||
COPY *.json ./ | ||
COPY ./src ./src | ||
RUN npm ci --ignore-scripts && \ | ||
npm run build | ||
|
||
RUN mkdir -p /app/sessions | ||
|
||
FROM node:20.11.0-bullseye-slim AS dependencies | ||
COPY ./prisma ./prisma | ||
RUN npm ci --ignore-scripts --no-update-notifier | ||
RUN npm run prisma-generate | ||
FROM node:20.11.0-bullseye-slim AS build | ||
|
||
# Install packages, build and keep only prod packages | ||
WORKDIR /app | ||
COPY *.json ./ | ||
RUN npm ci --omit=dev --ignore-scripts | ||
COPY ./src ./src | ||
COPY ./prisma ./prisma | ||
RUN npm ci --ignore-scripts --no-update-notifier --omit=dev | ||
|
||
# COPY over few dependencies from buildWithDevDeps | ||
COPY --from=buildWithDevDeps /app/node_modules/@prisma ./node_modules/@prisma | ||
COPY --from=buildWithDevDeps /app/node_modules/.prisma ./node_modules/.prisma | ||
COPY --from=buildWithDevDeps /app/node_modules/prisma ./node_modules/prisma | ||
|
||
RUN npm run build | ||
|
||
# Deployment container | ||
# Deploy container | ||
# Distroless has node, but not npm | ||
FROM gcr.io/distroless/nodejs20-debian11:nonroot | ||
ENV NODE_ENV production | ||
# Copy over app.ts | ||
|
||
# Copy over app | ||
WORKDIR /app | ||
COPY --from=dependencies /app/node_modules ./node_modules | ||
COPY --from=build /app/node_modules/@prisma ./node_modules/@prisma | ||
COPY --from=build /app/node_modules/.prisma ./node_modules/.prisma | ||
COPY --from=build /app/node_modules/prisma ./node_modules/prisma | ||
COPY --from=build /app/node_modules ./node_modules | ||
COPY --from=build /app/dist ./dist | ||
COPY --from=build /app/sessions ./sessions | ||
|
||
# Port and health check | ||
# Ports, health check and non-root user | ||
EXPOSE 3000 | ||
HEALTHCHECK --interval=30s --timeout=3s CMD curl -f http://localhost/:3000 | ||
|
||
# Non-privileged user | ||
USER app | ||
HEALTHCHECK --interval=30s --timeout=3s CMD curl -f http://localhost/:3000/api || exit 1 | ||
USER nonroot | ||
|
||
# Start up command with 250MB of heap size, each application needs to determine what is the best value. DONT use default as it is 4GB. | ||
CMD ["--max-old-space-size=250", "/app/dist/server"] | ||
# Start up command with 50MB of heap size, each application needs to determine what is the best value. DONT use default as it is 4GB. | ||
CMD ["--max-old-space-size=50", "/app/dist/main"] |
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,4 @@ | ||
{ | ||
"collection": "@nestjs/schematics", | ||
"sourceRoot": "src" | ||
} |
Oops, something went wrong.