Some checks failed
Podman Rootless Demo / test-backend (push) Has been skipped
Podman Rootless Demo / test-frontend (push) Successful in 12s
Podman Rootless Demo / build-backend (push) Has been skipped
Podman Rootless Demo / build-frontend (push) Failing after 1m47s
Podman Rootless Demo / deploy-prod (push) Has been skipped
53 lines
No EOL
1.1 KiB
Docker
53 lines
No EOL
1.1 KiB
Docker
# Multi-stage build for Next.js frontend
|
|
FROM docker.io/node:20-alpine AS builder
|
|
|
|
# Set working directory
|
|
WORKDIR /app
|
|
|
|
ENV NODE_ENV=development
|
|
|
|
# Copy package files
|
|
COPY package*.json ./
|
|
|
|
# Install all dependencies (including dev dependencies for build)
|
|
RUN npm ci
|
|
|
|
# Copy source code
|
|
COPY . .
|
|
|
|
ENV NEXT_TELEMETRY_DISABLED=1
|
|
|
|
# Build the application
|
|
RUN npm run build
|
|
|
|
# Production stage
|
|
FROM docker.io/node:20-alpine AS runner
|
|
|
|
# Create non-root user
|
|
RUN addgroup --system --gid 1001 nodejs \
|
|
&& adduser --system --uid 1001 nextjs
|
|
|
|
WORKDIR /app
|
|
|
|
# Copy standalone artifacts
|
|
COPY --from=builder /app/public ./public
|
|
COPY --from=builder /app/.next/standalone ./
|
|
COPY --from=builder /app/.next/static ./.next/static
|
|
|
|
# Ownership
|
|
RUN chown -R nextjs:nodejs /app
|
|
USER nextjs
|
|
|
|
ENV NODE_ENV=production
|
|
ENV NEXT_TELEMETRY_DISABLED=1
|
|
ENV PORT=3000
|
|
ENV HOSTNAME=127.0.0.1
|
|
|
|
EXPOSE 3000
|
|
|
|
# Healthcheck: hit the frontend root over IPv4 (no curl needed)
|
|
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
|
CMD wget -qO- http://127.0.0.1:${PORT}/ >/dev/null 2>&1 || exit 1
|
|
|
|
# Run the application
|
|
CMD ["node", "server.js"] |