48 lines
2.3 KiB
Docker
48 lines
2.3 KiB
Docker
# ─────────────────────────────────────────────────────────────────────────────
|
|
# Playwright Base Image for FinlyticNews
|
|
#
|
|
# BUILD ONCE (only rebuild when PLAYWRIGHT_VERSION changes):
|
|
# docker build -f FinlyticNews/Dockerfile.playwright-base `
|
|
# -t finlytic-playwright-base:1.49.0 `
|
|
# FinlyticNews
|
|
#
|
|
# This image is then used as the base in the main Dockerfile so that
|
|
# Chromium + all its OS dependencies are already cached in the image layer
|
|
# and don't need to be downloaded on every code build.
|
|
# ─────────────────────────────────────────────────────────────────────────────
|
|
|
|
FROM mcr.microsoft.com/dotnet/runtime:10.0
|
|
|
|
ARG PLAYWRIGHT_VERSION=1.49.0
|
|
|
|
USER root
|
|
WORKDIR /pw-install
|
|
|
|
# ── 1. Install OS dependencies that Playwright needs ────────────────────────
|
|
RUN apt-get update && \
|
|
apt-get install -y --no-install-recommends \
|
|
libgssapi-krb5-2 \
|
|
wget \
|
|
curl \
|
|
ca-certificates && \
|
|
rm -rf /var/lib/apt/lists/*
|
|
|
|
# ── 2. Install Node.js (LTS) via NodeSource ─────────────────────────────────
|
|
# We need Node only to run `playwright install`; it stays in the image.
|
|
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \
|
|
apt-get install -y --no-install-recommends nodejs && \
|
|
rm -rf /var/lib/apt/lists/*
|
|
|
|
# ── 3. Install Playwright CLI + Chromium with all OS dependencies ────────────
|
|
ENV PLAYWRIGHT_BROWSERS_PATH=/opt/ms-playwright
|
|
|
|
RUN npx --yes playwright@${PLAYWRIGHT_VERSION} install --with-deps chromium && \
|
|
# Remove npx cache & npm to keep the image lean
|
|
npm cache clean --force && \
|
|
rm -rf /root/.npm
|
|
|
|
# ── 4. Verify the installation ───────────────────────────────────────────────
|
|
RUN ls /opt/ms-playwright/ && echo "✅ Playwright browsers installed successfully"
|
|
|
|
WORKDIR /app
|