Use Debian base image in Dockerfile to fix lightningcss on Alpine
This commit is contained in:
parent
d8dd8a876f
commit
59d8e7d348
50
Dockerfile
50
Dockerfile
@ -1,52 +1,52 @@
|
||||
# Multi-stage Dockerfile for Next.js Application
|
||||
# Multi-stage Dockerfile for Next.js Application (Debian-based to avoid musl issues)
|
||||
# Builder installs ALL deps (including dev) to support Tailwind/PostCSS during build
|
||||
|
||||
# Build stage
|
||||
FROM node:24-alpine AS builder
|
||||
FROM node:24-bookworm-slim AS builder
|
||||
|
||||
# Set working directory
|
||||
WORKDIR /app
|
||||
|
||||
# Copy package files
|
||||
COPY package*.json ./
|
||||
ENV NODE_ENV=development
|
||||
ENV NEXT_TELEMETRY_DISABLED=1
|
||||
|
||||
# Install dependencies
|
||||
RUN npm ci --only=production
|
||||
COPY package*.json ./
|
||||
RUN npm ci
|
||||
|
||||
# Copy source code
|
||||
# Copy source
|
||||
COPY . .
|
||||
|
||||
# Build the Next.js application
|
||||
RUN npm run build -- --no-turbopack
|
||||
RUN npm run build
|
||||
|
||||
# Production stage
|
||||
FROM node:24-alpine AS production
|
||||
FROM node:24-bookworm-slim AS runner
|
||||
|
||||
# Set working directory
|
||||
WORKDIR /app
|
||||
|
||||
# Create non-root user
|
||||
RUN addgroup -g 1001 -S nodejs && \
|
||||
adduser -S nextjs -u 1001
|
||||
ENV NODE_ENV=production
|
||||
ENV NEXT_TELEMETRY_DISABLED=1
|
||||
|
||||
# Copy dependencies from builder stage
|
||||
COPY --from=builder /app/node_modules ./node_modules
|
||||
# Install curl for healthcheck
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends curl \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Install only production deps
|
||||
COPY package*.json ./
|
||||
RUN npm ci --omit=dev
|
||||
|
||||
# Copy built assets and public files
|
||||
COPY --from=builder /app/.next ./.next
|
||||
COPY --from=builder /app/package.json ./package.json
|
||||
|
||||
# Copy source code
|
||||
COPY --from=builder /app/.env ./.env
|
||||
COPY --from=builder /app/public ./public
|
||||
|
||||
# Change ownership
|
||||
RUN chown -R nextjs:nodejs /app
|
||||
USER nextjs
|
||||
# Use non-root user provided by the official Node image
|
||||
USER node
|
||||
|
||||
# Expose port
|
||||
EXPOSE 3000
|
||||
|
||||
# Health check
|
||||
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
|
||||
CMD curl -f http://localhost:3000/health || exit 1
|
||||
HEALTHCHECK --interval=30s --timeout=30s --start-period=10s --retries=3 \
|
||||
CMD curl -f http://localhost:3000/ || exit 1
|
||||
|
||||
# Start command
|
||||
CMD ["npm", "start"]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user