Introduce a multi-stage Dockerfile for the frontend service to enable efficient builds and an optimized runtime using Node.js 22.
23 lines
597 B
Docker
23 lines
597 B
Docker
FROM node:22-slim AS base
|
|
ENV PNPM_HOME="/pnpm"
|
|
ENV PATH="$PNPM_HOME:$PATH"
|
|
RUN corepack enable
|
|
|
|
FROM base AS build
|
|
WORKDIR /usr/src/app
|
|
COPY . .
|
|
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
|
|
RUN pnpm run --filter @memegoat/frontend build
|
|
|
|
FROM base AS runtime
|
|
WORKDIR /app
|
|
COPY --from=build /usr/src/app/frontend/public ./frontend/public
|
|
COPY --from=build /usr/src/app/frontend/.next/standalone ./
|
|
COPY --from=build /usr/src/app/frontend/.next/static ./frontend/.next/static
|
|
|
|
EXPOSE 3000
|
|
ENV PORT=3000
|
|
ENV HOSTNAME="0.0.0.0"
|
|
|
|
CMD ["node", "frontend/server.js"]
|