Skip to content

Commit

Permalink
improved how the webclient dockerfile is structured
Browse files Browse the repository at this point in the history
  • Loading branch information
CommanderStorm committed Dec 25, 2024
1 parent a5fe45e commit d00b07f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 23 deletions.
6 changes: 4 additions & 2 deletions webclient/.dockerignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
node_modules
# looking at the output would be cheesing
dist
cdn
node_modules
.output
.nuxt
# don't prevent rapid iteration on the docker file
Dockerfile
43 changes: 22 additions & 21 deletions webclient/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,32 +1,38 @@
# https://docs.docker.com/build/attestations/sbom/#scan-build-context
ARG BUILDKIT_SBOM_SCAN_CONTEXT=true

FROM node:23-alpine3.20 AS build-stage
FROM node:23-alpine3.20 AS base

ENV NODE_ENV=development
ENV NITRO_PRESET=node-server
ENV NITRO_PORT=3000
ENV NITRO_HOST=0.0.0.0

ARG GIT_COMMIT_SHA
ENV GIT_COMMIT_SHA=${GIT_COMMIT_SHA}
ARG GIT_COMMIT_MESSAGE
ENV GIT_COMMIT_MESSAGE=${GIT_COMMIT_MESSAGE}

WORKDIR /app

FROM base AS build-stage

ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable
COPY package.json ./
COPY pnpm-lock.yaml ./
RUN pnpm install --frozen-lockfile

ARG GIT_COMMIT_SHA
ENV GIT_COMMIT_SHA=${GIT_COMMIT_SHA}
ARG GIT_COMMIT_MESSAGE
ENV GIT_COMMIT_MESSAGE=${GIT_COMMIT_MESSAGE}
ENV NODE_ENV=production
ENV NITRO_SHUTDOWN=true
ENV NITRO_PRESET=node-server
RUN NODE_ENV=development pnpm install --frozen-lockfile

COPY tsconfig.json .
COPY eslint.config.mjs .
COPY ./*.ts .
COPY public public
COPY content content
COPY app app
RUN pnpm run build

COPY --link public public
COPY --link content content
COPY --link app app
RUN pnpm run build && test -f /app/.output/server/index.mjs

FROM node:23-alpine3.20 AS production-stage
FROM base AS production-stage
RUN apk update --no-progress --quiet && \
apk add --no-cache --no-progress --quiet curl

Expand All @@ -35,11 +41,6 @@ COPY --from=build-stage /app/node_modules /app/node_modules
COPY --from=build-stage /app/.nuxt /app/.nuxt

EXPOSE 3000
ENV NODE_ENV=production
ENV NITRO_PORT=3000
ENV NITRO_HOST=0.0.0.0
ENV NITRO_SHUTDOWN=true
ENV NITRO_PRESET=node-server

HEALTHCHECK CMD curl --fail localhost:3000/health || exit 1
CMD ["node", "/app/.output/server/index.mjs"]

0 comments on commit d00b07f

Please sign in to comment.