From 3da6fdab49531d79df538bd229378b26533ce9f1 Mon Sep 17 00:00:00 2001 From: Codex Date: Wed, 8 Jul 2026 00:41:15 +0000 Subject: [PATCH] Use slim Chromium runtime --- .dockerignore | 12 ++++++++++++ Dockerfile | 11 ++++++++--- package-lock.json | 16 +--------------- package.json | 2 +- src/capture.ts | 2 +- 5 files changed, 23 insertions(+), 20 deletions(-) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..f812d85 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,12 @@ +.git +.agents +.codex +node_modules +dist +dist-client +data +.env +.admin-token +*.log +playwright-report +test-results diff --git a/Dockerfile b/Dockerfile index 3be51d6..19526bd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,6 @@ -FROM mcr.microsoft.com/playwright:v1.45.0-jammy AS build +FROM node:20-bookworm-slim AS build +ENV PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 WORKDIR /app COPY package.json package-lock.json ./ RUN npm ci @@ -9,21 +10,25 @@ COPY client ./client RUN npm run build RUN npm prune --omit=dev -FROM mcr.microsoft.com/playwright:v1.45.0-jammy +FROM node:20-bookworm-slim ENV NODE_ENV=production ENV AISHARE_PORT=8080 ENV AISHARE_DATA_DIR=/data ENV PLAYWRIGHT_BROWSERS_PATH=/ms-playwright +ENV PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 WORKDIR /app RUN apt-get update \ - && apt-get install -y --no-install-recommends fonts-noto fonts-noto-cjk fonts-noto-color-emoji fonts-thai-tlwg \ + && apt-get install -y --no-install-recommends ca-certificates fonts-noto-core fonts-noto-cjk fonts-noto-color-emoji fonts-thai-tlwg \ && rm -rf /var/lib/apt/lists/* COPY --from=build /app/node_modules ./node_modules COPY --from=build /app/dist ./dist COPY --from=build /app/dist-client ./dist-client COPY package.json ./ +RUN ./node_modules/.bin/playwright install --with-deps --only-shell chromium \ + && npm cache clean --force \ + && rm -rf /var/lib/apt/lists/* /tmp/* EXPOSE 8080 CMD ["node", "dist/server.js"] diff --git a/package-lock.json b/package-lock.json index 279cb7f..e2a5af9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,13 +8,13 @@ "name": "aishare", "version": "0.1.0", "dependencies": { - "@playwright/test": "^1.45.0", "archiver": "^7.0.1", "better-sqlite3": "^11.1.2", "cheerio": "1.0.0", "express": "^4.19.2", "fs-extra": "^11.2.0", "nanoid": "^5.0.7", + "playwright": "1.61.1", "sanitize-filename": "^1.6.3", "zod": "^3.23.8" }, @@ -470,20 +470,6 @@ "node": ">=14" } }, - "node_modules/@playwright/test": { - "version": "1.61.1", - "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.61.1.tgz", - "integrity": "sha512-8nKv6+0RJSL9FE4jYOEGXnPeM/Hg12qZpmqzZjRh3qM0Y7c3z1mrOTfFLids72RDQYVh9WpLEfR5WdpNX4fkig==", - "dependencies": { - "playwright": "1.61.1" - }, - "bin": { - "playwright": "cli.js" - }, - "engines": { - "node": ">=18" - } - }, "node_modules/@rollup/rollup-android-arm-eabi": { "version": "4.62.2", "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.62.2.tgz", diff --git a/package.json b/package.json index d7e00d1..976514a 100644 --- a/package.json +++ b/package.json @@ -10,13 +10,13 @@ "typecheck": "tsc --noEmit" }, "dependencies": { - "@playwright/test": "^1.45.0", "archiver": "^7.0.1", "better-sqlite3": "^11.1.2", "cheerio": "1.0.0", "express": "^4.19.2", "fs-extra": "^11.2.0", "nanoid": "^5.0.7", + "playwright": "1.61.1", "sanitize-filename": "^1.6.3", "zod": "^3.23.8" }, diff --git a/src/capture.ts b/src/capture.ts index 544504d..8d67416 100644 --- a/src/capture.ts +++ b/src/capture.ts @@ -1,7 +1,7 @@ import path from "node:path"; import fs from "fs-extra"; import * as cheerio from "cheerio"; -import { chromium, type Browser } from "@playwright/test"; +import { chromium, type Browser } from "playwright"; import { nanoid } from "nanoid"; import { store } from "./db.js"; import { config } from "./config.js";