Files
Finlytic/FinlyticNews/Dockerfile.playwright-base

53 lines
2.5 KiB
Docker

# ─────────────────────────────────────────────────────────────────────────────
# Shared Playwright Base Image
#
# Consumed by BOTH FinlyticNews/Dockerfile and FinlyticFundamentals/Dockerfile.
#
# BUILD ONCE (only rebuild when PLAYWRIGHT_VERSION changes):
# .\rebuild-playwright-base.ps1
# or, via Compose:
# docker compose --profile build-base build finlytic-playwright-base
#
# Not built by a plain `docker compose build` — Compose does not resolve
# FROM-references between services, so this must exist beforehand.
#
# 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