- Add Dockerfile with multi-stage build - Add docker-compose.yml with Traefik labels - Add .dockerignore for optimal build context - Update next.config.ts for standalone output - Update DEPLOYMENT.md with Dokploy instructions Co-Authored-By: Claude <noreply@anthropic.com>
51 lines
908 B
Docker
51 lines
908 B
Docker
# Build stage
|
|
FROM node:20-alpine AS builder
|
|
|
|
# Set working directory
|
|
WORKDIR /app
|
|
|
|
# Copy package files
|
|
COPY package.json package-lock.json ./
|
|
|
|
# Install dependencies
|
|
RUN npm ci
|
|
|
|
# Copy all source files
|
|
COPY . .
|
|
|
|
# Build the application
|
|
RUN npm run build
|
|
|
|
# Production stage
|
|
FROM node:20-alpine AS runner
|
|
|
|
# Set working directory
|
|
WORKDIR /app
|
|
|
|
# Set environment to production
|
|
ENV NODE_ENV=production
|
|
|
|
# Create a non-root user
|
|
RUN addgroup --system --gid 1001 nodejs
|
|
RUN adduser --system --uid 1001 nextjs
|
|
|
|
# Copy necessary files from builder
|
|
COPY --from=builder /app/public ./public
|
|
COPY --from=builder /app/.next/standalone ./
|
|
COPY --from=builder /app/.next/static ./.next/static
|
|
|
|
# Change ownership to nextjs user
|
|
RUN chown -R nextjs:nodejs /app
|
|
|
|
# Switch to nextjs user
|
|
USER nextjs
|
|
|
|
# Expose port 3000
|
|
EXPOSE 3000
|
|
|
|
# Set hostname
|
|
ENV HOSTNAME="0.0.0.0"
|
|
|
|
# Start the application
|
|
CMD ["node", "server.js"]
|