mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-26 18:42:49 +00:00
modify nextjs deployment
This commit is contained in:
65
infrastructure/docker/Dockerfile.passenger-web
Normal file
65
infrastructure/docker/Dockerfile.passenger-web
Normal file
@@ -0,0 +1,65 @@
|
||||
# syntax=docker/dockerfile:1
|
||||
#
|
||||
# Next.js Dockerfile for passenger web (portal + backoffice).
|
||||
# Builds with turbo, runs with Node.js (not nginx).
|
||||
#
|
||||
# Build example (portal):
|
||||
# DOCKER_BUILDKIT=1 docker build \
|
||||
# --build-arg APP_PACKAGE=@edr/passenger-portal \
|
||||
# --build-arg APP_PATH=apps/edr-passenger-web/portal \
|
||||
# --build-arg PORT=5174 \
|
||||
# -f infrastructure/docker/Dockerfile.passenger-web .
|
||||
#
|
||||
|
||||
ARG APP_PACKAGE=@edr/passenger-portal
|
||||
ARG APP_PATH=apps/edr-passenger-web/portal
|
||||
ARG PORT=5174
|
||||
ARG NEXT_PUBLIC_API_URL=http://localhost:4000
|
||||
|
||||
FROM node:24.15.0-alpine AS base
|
||||
RUN apk add --no-cache libc6-compat
|
||||
RUN corepack enable
|
||||
WORKDIR /app
|
||||
|
||||
FROM base AS pruner
|
||||
ARG APP_PACKAGE
|
||||
COPY . .
|
||||
RUN pnpm dlx turbo prune "${APP_PACKAGE}" --docker
|
||||
|
||||
FROM base AS installer
|
||||
COPY --from=pruner /app/out/json/ .
|
||||
COPY --from=pruner /app/out/pnpm-lock.yaml ./pnpm-lock.yaml
|
||||
RUN --mount=type=secret,id=npmrc,target=./.npmrc,required=false \
|
||||
--mount=type=cache,id=pnpm,target=/pnpm/store \
|
||||
pnpm install --frozen-lockfile
|
||||
|
||||
FROM base AS builder
|
||||
ARG APP_PACKAGE
|
||||
ARG APP_PATH
|
||||
ARG NEXT_PUBLIC_API_URL
|
||||
ENV NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL}
|
||||
COPY --from=installer /app/ .
|
||||
COPY --from=pruner /app/out/full/ .
|
||||
RUN pnpm turbo build --filter="${APP_PACKAGE}..."
|
||||
|
||||
FROM base AS runner
|
||||
ARG APP_PATH
|
||||
ARG PORT=5174
|
||||
ENV PORT=${PORT}
|
||||
ENV NODE_ENV=production
|
||||
|
||||
# Copy built app (Next.js output)
|
||||
COPY --from=builder /app/${APP_PATH}/.next /app/.next
|
||||
COPY --from=builder /app/${APP_PATH}/public /app/public
|
||||
COPY --from=builder /app/${APP_PATH}/package.json /app/package.json
|
||||
|
||||
# Copy node_modules (required for Next.js runtime)
|
||||
COPY --from=builder /app/node_modules /app/node_modules
|
||||
|
||||
# Use node user for security
|
||||
USER node
|
||||
|
||||
EXPOSE ${PORT}
|
||||
|
||||
# Start Next.js standalone server
|
||||
CMD ["node", ".next/standalone/server.js"]
|
||||
Reference in New Issue
Block a user