feat(docker): build and serve with Node and npm instead of Nginx

This commit is contained in:
venus
2026-09-13 01:59:49 -05:00
parent e733f479dd
commit 78b1e0b485
12 changed files with 294 additions and 200 deletions
+12 -20
View File
@@ -1,35 +1,27 @@
# Stage 1: Build static site with Node
FROM node:22-alpine AS builder
FROM node:22-alpine
WORKDIR /app
# Dynamic build arguments for domain & full URL (required, no fallback)
# Dynamic build arguments & environment variables
ARG SITE_DOMAIN
ARG SITE_URL
ENV SITE_DOMAIN=$SITE_DOMAIN
ENV SITE_URL=$SITE_URL
ENV PORT=8080
ENV NODE_ENV=production
# Copy dependency definitions and install
# Install dependencies
COPY package*.json ./
RUN npm ci
# Copy source files and compile static output via Eleventy
# Copy application source files
COPY . .
# Build static production assets
RUN npm run build
# Stage 2: Serve static output via lightweight Alpine Nginx
FROM nginx:1.25-alpine
# Expose web server port
EXPOSE 8080
# Remove default Nginx configuration
RUN rm /etc/nginx/conf.d/default.conf
# Copy custom Nginx security & clean-URL configuration
COPY nginx.conf /etc/nginx/conf.d/default.conf
# Copy compiled static website files from builder stage
COPY --from=builder /app/_site /usr/share/nginx/html
# Expose HTTP port
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
# Serve site with npm
CMD ["npm", "start"]