From c7ef0fc65c7f94dd178cd9034dcace89ffc68d43 Mon Sep 17 00:00:00 2001 From: Nathan Date: Sat, 20 Sep 2025 00:57:49 +0800 Subject: [PATCH] chore: update dockerfile --- docker/Dockerfile | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 9cc5145f..a8df8026 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,22 +1,41 @@ # syntax=docker/dockerfile:1 -FROM node:20.12.0 AS builder +# Build stage +FROM node:20.12.0-alpine AS builder + +# Set production environment +ENV NODE_ENV=production WORKDIR /app -ARG VERSION=main +# Copy package files first for better layer caching +COPY package.json pnpm-lock.yaml ./ +# Enable corepack and install dependencies +RUN corepack enable && \ + pnpm install --frozen-lockfile + +# Copy source code COPY . . -RUN corepack enable -RUN pnpm install -# Build without environment variables - they will be injected at runtime +# Build the application RUN pnpm run build -FROM nginx:alpine +# Production stage +FROM nginx:1.25-alpine + +# Install runtime dependencies +RUN apk add --no-cache tini + +# Copy built application COPY --from=builder /app/dist /usr/share/nginx/html/ + +# Copy configuration files COPY --from=builder /app/docker/nginx.conf /etc/nginx/nginx.conf COPY --from=builder /app/docker/entrypoint.sh /docker-entrypoint.sh + +# Make entrypoint executable RUN chmod +x /docker-entrypoint.sh -# Set the entrypoint -ENTRYPOINT ["/docker-entrypoint.sh"] + +# Use tini to handle signals properly +ENTRYPOINT ["/sbin/tini", "--", "/docker-entrypoint.sh"]