???
All checks were successful
Docker Deploy / build-and-push (push) Successful in 4m6s

This commit is contained in:
2025-10-14 00:47:36 -06:00
parent fb260d499b
commit 94146782cb

View File

@@ -1,31 +1,50 @@
FROM node:24-alpine AS builder
FROM node:24-alpine AS base
# Install system dependencies
RUN apk add --no-cache \
python3 \
make \
g++ \
libc6-compat \
vips-dev \
curl
# Install pnpm globally
RUN npm install -g pnpm
# Configure pnpm
RUN pnpm config set store-dir /.pnpm-store
RUN pnpm config set network-timeout 300000
RUN pnpm config set fetch-retries 10
RUN pnpm config set fetch-retry-factor 2
FROM base AS deps
WORKDIR /app
# Install Chromium and dependencies for Playwright in a single layer
RUN apk add --no-cache \
chromium \
nss \
freetype \
freetype-dev \
harfbuzz \
ca-certificates \
ttf-freefont \
curl \
&& rm -rf /var/cache/apk/*
# Tell Playwright to use the installed Chromium
ENV PLAYWRIGHT_BROWSERS_PATH=/usr/bin
ENV PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH=/usr/bin/chromium-browser
# Install pnpm
RUN npm i -g pnpm
# Copy package files
COPY package.json pnpm-lock.yaml ./
# Install all dependencies (including dev dependencies for build)
RUN pnpm install --frozen-lockfile
# Install dependencies with retry logic
RUN --mount=type=cache,id=pnpm,target=/.pnpm-store \
pnpm install --frozen-lockfile || \
(sleep 5 && pnpm install --frozen-lockfile) || \
(sleep 10 && pnpm install --frozen-lockfile --no-frozen-lockfile)
FROM base AS build-deps
WORKDIR /app
# Copy package files
COPY package.json pnpm-lock.yaml ./
# Install all dependencies including dev dependencies
RUN --mount=type=cache,id=pnpm,target=/.pnpm-store \
pnpm install --frozen-lockfile || \
(sleep 5 && pnpm install --frozen-lockfile) || \
(sleep 10 && pnpm install --frozen-lockfile --no-frozen-lockfile)
FROM build-deps AS builder
# Copy source code
COPY . .
@@ -33,10 +52,32 @@ COPY . .
# Build the application
RUN pnpm run build
# Install only production dependencies and clean up
RUN pnpm install --prod --frozen-lockfile \
&& pnpm store prune \
&& npm cache clean --force
FROM node:24-alpine AS runtime
# Install runtime dependencies for Playwright
RUN apk add --no-cache \
chromium \
nss \
freetype \
freetype-dev \
harfbuzz \
ca-certificates \
ttf-freefont
# Tell Playwright to use the installed Chromium
ENV PLAYWRIGHT_BROWSERS_PATH=/usr/bin
ENV PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH=/usr/bin/chromium-browser
WORKDIR /app
# Copy built application
COPY --from=builder /app/dist ./dist
# Copy production dependencies
COPY --from=deps /app/node_modules ./node_modules
# Copy package.json for any runtime needs
COPY package.json ./
# Set environment variables
ENV HOST=0.0.0.0 \
@@ -47,4 +88,4 @@ ENV HOST=0.0.0.0 \
EXPOSE 4321
# Start the application
CMD ["node", "./dist/server/entry.mjs"]
CMD ["node", "./dist/server/entry.mjs"]