FROM node:22-slim AS base ENV PNPM_HOME="/pnpm" ENV PATH="$PNPM_HOME:$PATH" RUN corepack enable # use Docker layers as the build cache instead of the local pnpm cache (I chose this method because this works in all environments, even ephemeral Github Actions VMs): FROM base AS prod WORKDIR /app COPY pnpm-lock.yaml /app RUN pnpm fetch --prod COPY . /app RUN pnpm run build FROM base AS final WORKDIR /app COPY --from=prod /app/node_modules /app/node_modules COPY --from=prod /app/dist /app EXPOSE 4321 # set the host to 0.0.0.0 so that it can be accessed from outside the container (doesn't work without this, even with the `-p 4321:4321` docker option): ENV HOST="0.0.0.0" CMD [ "node", "server/entry.mjs" ]