This commit is contained in:
30
Dockerfile
30
Dockerfile
@ -1,11 +1,11 @@
|
||||
FROM node:24 AS builder
|
||||
FROM node:24-alpine AS builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Install pnpm
|
||||
RUN npm i -g pnpm
|
||||
|
||||
# Copy package files first for better caching
|
||||
# Copy package files
|
||||
COPY package.json pnpm-lock.yaml ./
|
||||
|
||||
# Install dependencies
|
||||
@ -18,22 +18,10 @@ COPY . .
|
||||
RUN pnpm run build
|
||||
|
||||
# Production stage
|
||||
FROM node:18 AS runtime
|
||||
FROM mcr.microsoft.com/playwright:v1.50.0-noble AS runtime
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# We don't need the standalone Chromium
|
||||
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
|
||||
|
||||
# Install Google Chrome Stable and fonts
|
||||
# Note: this installs the necessary libs to make the browser work with Puppeteer.
|
||||
RUN apt-get update && apt-get install curl gnupg -y \
|
||||
&& curl --location --silent https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
|
||||
&& sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \
|
||||
&& apt-get update \
|
||||
&& apt-get install google-chrome-stable -y --no-install-recommends \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Install pnpm
|
||||
RUN npm i -g pnpm
|
||||
|
||||
@ -41,8 +29,10 @@ RUN npm i -g pnpm
|
||||
COPY --from=builder /app/dist ./dist
|
||||
COPY --from=builder /app/package.json /app/pnpm-lock.yaml ./
|
||||
|
||||
# Install production dependencies
|
||||
RUN pnpm install --prod --frozen-lockfile && pnpm store prune
|
||||
# Install production dependencies and clean up in one layer
|
||||
RUN pnpm install --prod --frozen-lockfile \
|
||||
&& pnpm store prune \
|
||||
&& npm cache clean --force
|
||||
|
||||
# Set environment variables
|
||||
ENV HOST=0.0.0.0 \
|
||||
@ -52,9 +42,5 @@ ENV HOST=0.0.0.0 \
|
||||
# Expose port
|
||||
EXPOSE 4321
|
||||
|
||||
# Health check
|
||||
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
||||
CMD curl -f http://localhost:4321/ || exit 1
|
||||
|
||||
# Start the application
|
||||
CMD ["node", "./dist/server/entry.mjs"]
|
||||
CMD ["node", "./dist/server/entry.mjs"]
|
Reference in New Issue
Block a user