puffin-app/Dockerfile
Matt b8bb0c8ae3
All checks were successful
Build and Push Docker Images / docker (push) Successful in 2m20s
Fix Docker API routes 404 - Add .next/server copy
Next.js 16 with standalone output creates two separate directories:
- .next/standalone (server infrastructure)
- .next/server (compiled App Router routes)

Previous Dockerfile only copied standalone, causing all /api/*
routes to return 404 in production. This adds the missing copy
command to include compiled API route handlers.

Fixes: /api/wren/portfolios returning 404 after deployment
2025-11-03 12:36:57 +01:00

39 lines
895 B
Docker

# Build Stage
FROM node:20-alpine AS build
WORKDIR /app
# Copy package files and install dependencies
COPY package*.json ./
RUN npm ci
# Copy the rest of the app
COPY . .
# Build Next.js app (standalone mode)
# All environment variables are runtime-configurable via .env or docker-compose
RUN npm run build
# Production Stage - Next.js standalone server
FROM node:20-alpine
WORKDIR /app
# Copy standalone server files from build stage
COPY --from=build /app/.next/standalone ./
COPY --from=build /app/.next/static ./.next/static
COPY --from=build /app/.next/server ./.next/server
COPY --from=build /app/public ./public
# Expose port 3000
EXPOSE 3000
# Set environment to production
ENV NODE_ENV=production
ENV PORT=3000
ENV HOSTNAME="0.0.0.0"
# Start Next.js server
# Runtime environment variables (NEXT_PUBLIC_*) can be passed via docker-compose or -e flags
CMD ["node", "server.js"]