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
|
# Build stage
|
||||||
FROM node:24-alpine AS builder
|
FROM node:24-bookworm-slim AS builder
|
||||||
|
|
||||||
# Set working directory
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Copy package files
|
ENV NODE_ENV=development
|
||||||
COPY package*.json ./
|
ENV NEXT_TELEMETRY_DISABLED=1
|
||||||
|
|
||||||
# Install dependencies
|
# Install dependencies
|
||||||
RUN npm ci --only=production
|
COPY package*.json ./
|
||||||
|
RUN npm ci
|
||||||
|
|
||||||
# Copy source code
|
# Copy source
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
# Build the Next.js application
|
# Build the Next.js application
|
||||||
RUN npm run build -- --no-turbopack
|
RUN npm run build
|
||||||
|
|
||||||
# Production stage
|
# Production stage
|
||||||
FROM node:24-alpine AS production
|
FROM node:24-bookworm-slim AS runner
|
||||||
|
|
||||||
# Set working directory
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Create non-root user
|
ENV NODE_ENV=production
|
||||||
RUN addgroup -g 1001 -S nodejs && \
|
ENV NEXT_TELEMETRY_DISABLED=1
|
||||||
adduser -S nextjs -u 1001
|
|
||||||
|
|
||||||
# Copy dependencies from builder stage
|
# Install curl for healthcheck
|
||||||
COPY --from=builder /app/node_modules ./node_modules
|
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/.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
|
COPY --from=builder /app/public ./public
|
||||||
|
|
||||||
# Change ownership
|
# Use non-root user provided by the official Node image
|
||||||
RUN chown -R nextjs:nodejs /app
|
USER node
|
||||||
USER nextjs
|
|
||||||
|
|
||||||
# Expose port
|
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
|
|
||||||
# Health check
|
# Health check
|
||||||
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
|
HEALTHCHECK --interval=30s --timeout=30s --start-period=10s --retries=3 \
|
||||||
CMD curl -f http://localhost:3000/health || exit 1
|
CMD curl -f http://localhost:3000/ || exit 1
|
||||||
|
|
||||||
# Start command
|
# Start command
|
||||||
CMD ["npm", "start"]
|
CMD ["npm", "start"]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user