57 lines
1.4 KiB
Docker
57 lines
1.4 KiB
Docker
# Standard Dockerfile for normal deployment
|
|
# This builds a complete image with the application code included
|
|
|
|
# Build stage
|
|
FROM node:18-alpine AS builder
|
|
|
|
WORKDIR /app
|
|
|
|
# Copy package files and install dependencies
|
|
COPY package*.json ./
|
|
RUN npm ci
|
|
|
|
# Copy application code
|
|
COPY . .
|
|
|
|
# Generate Prisma client
|
|
RUN npx prisma generate
|
|
|
|
# Build the Next.js application
|
|
RUN npm run build
|
|
|
|
# Production stage
|
|
FROM node:18-alpine AS runner
|
|
|
|
WORKDIR /app
|
|
|
|
# Set production environment
|
|
ENV NODE_ENV=production
|
|
|
|
# Install necessary runtime dependencies
|
|
RUN apk --no-cache add bash
|
|
|
|
# Create non-root user for security
|
|
RUN addgroup --system --gid 1001 nodejs \
|
|
&& adduser --system --uid 1001 nextjs
|
|
|
|
# Copy necessary files from build stage
|
|
COPY --from=builder /app/next.config.js ./
|
|
COPY --from=builder /app/public ./public
|
|
COPY --from=builder /app/package*.json ./
|
|
COPY --from=builder /app/.next/standalone ./
|
|
COPY --from=builder /app/.next/static ./.next/static
|
|
COPY --from=builder /app/node_modules/.prisma ./node_modules/.prisma
|
|
COPY --from=builder /app/node_modules/@prisma ./node_modules/@prisma
|
|
|
|
# Create required directories with proper permissions
|
|
RUN mkdir -p public/content/permits public/content/uploads logs \
|
|
&& chown -R nextjs:nodejs public/content logs
|
|
|
|
# Switch to non-root user
|
|
USER nextjs
|
|
|
|
# Expose the application port
|
|
EXPOSE 3000
|
|
|
|
# Start the application
|
|
CMD ["node", "server.js"] |