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

This commit is contained in:
2025-06-26 18:57:46 -06:00
parent 43c96c73b2
commit b4298e78ef
2 changed files with 54 additions and 8 deletions

View File

@ -1,27 +1,60 @@
FROM node:lts-alpine AS builder
FROM node:18 AS builder
WORKDIR /app
# Install pnpm
RUN npm i -g pnpm
# Copy package files first for better caching
COPY package.json pnpm-lock.yaml ./
RUN pnpm install
# Install dependencies
RUN pnpm install --frozen-lockfile
# Copy source code
COPY . .
# Build the application
RUN pnpm run build
FROM node:lts-alpine AS runtime
# Production stage
FROM node:18 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
# Copy built application and package files
COPY --from=builder /app/dist ./dist
COPY package.json pnpm-lock.yaml ./
COPY --from=builder /app/package.json /app/pnpm-lock.yaml ./
RUN pnpm install --prod
# Install production dependencies
RUN pnpm install --prod --frozen-lockfile && pnpm store prune
ENV HOST=0.0.0.0
ENV PORT=4321
# Set environment variables
ENV HOST=0.0.0.0 \
PORT=4321 \
NODE_ENV=production
# 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"]

View File

@ -327,7 +327,20 @@ export const GET: APIRoute = async ({ request }) => {
const browser = await puppeteer.launch({
headless: true,
args: ["--no-sandbox", "--disable-setuid-sandbox"],
defaultViewport: null,
executablePath:
process.env.NODE_ENV === "production"
? "/usr/bin/google-chrome"
: undefined,
args: [
"--no-sandbox",
"--disable-setuid-sandbox",
"--disable-dev-shm-usage",
"--disable-accelerated-2d-canvas",
"--no-first-run",
"--no-zygote",
"--disable-gpu",
],
});
const page = await browser.newPage();