lad-website/frontend/Dockerfile

34 lines
740 B
Docker

# Build stage — needs all dependencies including devDependencies
FROM node:22-alpine AS build
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build
# Production stage — only production dependencies
FROM node:22-alpine
WORKDIR /app
RUN addgroup -S appgroup && adduser -S appuser -G appgroup && \
chown -R appuser:appgroup /app
# Install only production deps in the final image
COPY --chown=appuser:appgroup package*.json ./
RUN npm ci --only=production
# Copy built assets from build stage
COPY --from=build --chown=appuser:appgroup /app/.next ./.next
COPY --from=build --chown=appuser:appgroup /app/next.config.js ./next.config.js
ENV NODE_ENV=production
USER appuser
EXPOSE 3000
CMD ["npm", "start"]