Repository navigation
Expand file tree
/
Copy pathContainerfile
More file actions
91 lines (82 loc) · 5.24 KB
/
Copy pathContainerfile
File metadata and controls
91 lines (82 loc) · 5.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# --------------------------------------------------------------------------
# THIS FILE IS AUTOGENERATED - DO NOT EDIT MANUALLY
#
# Source: Containerfile.j2
# --------------------------------------------------------------------------
ARG BASE_VERSION=15-pkg
FROM ghcr.io/daemonless/base-core:${BASE_VERSION}
ARG FREEBSD_ARCH=amd64
ARG APP_VERSION=""
ARG UPSTREAM_URL="https://registry.npmjs.org/playwright-core/latest"
ARG UPSTREAM_JQ=".version"
ARG PACKAGES="chromium ffmpeg dejavu noto-basic ca_root_nss node24"
# --- Metadata (Injected by Generator) ---
LABEL org.opencontainers.image.title="Playwright" \
org.opencontainers.image.description="Playwright (Chromium) on FreeBSD. Use as a base image for running browser tests." \
org.opencontainers.image.source="https://github.com/daemonless/playwright" \
org.opencontainers.image.url="https://playwright.dev/" \
org.opencontainers.image.licenses="Apache-2.0" \
org.opencontainers.image.vendor="daemonless" \
org.opencontainers.image.authors="daemonless" \
io.daemonless.category="Utilities" \
io.daemonless.arch="${FREEBSD_ARCH}" \
io.daemonless.pkg-source="upstream" \
io.daemonless.upstream-url="${UPSTREAM_URL}" \
io.daemonless.upstream-jq="${UPSTREAM_JQ}"
# Install runtime packages
RUN pkg update && \
pkg install -y ${PACKAGES} && \
pkg clean -ay && \
rm -rf /var/cache/pkg/* /var/db/pkg/repos/*
# Install playwright-core from upstream npm registry, patch for FreeBSD, and configure browser links
RUN if [ -n "${APP_VERSION}" ] && [ "${APP_VERSION}" != "latest" ]; then \
VERSION="${APP_VERSION}"; \
TARBALL_URL="https://registry.npmjs.org/playwright-core/-/playwright-core-${APP_VERSION}.tgz"; \
else \
META=$(fetch -qo - "${UPSTREAM_URL}"); \
VERSION=$(echo "${META}" | jq -r "${UPSTREAM_JQ}"); \
TARBALL_URL=$(echo "${META}" | jq -r '.dist.tarball'); \
fi && \
echo "Installing Playwright ${VERSION}" && \
mkdir -p /usr/local/lib/node_modules/playwright-core && \
fetch -qo - "${TARBALL_URL}" | tar -xzf - -C /usr/local/lib/node_modules/playwright-core --strip-components 1 && \
cd /usr/local/lib/node_modules/playwright-core && \
sed -i.bak -e '/if (!localCacheDir)/{N;s@throw new Error("Unsupported platform: " + process.platform)@localCacheDir = process.env.XDG_CACHE_HOME || require("path").join(require("os").homedir(), ".cache")@;}' \
lib/coreBundle.js && \
sed -i.bak \
-e 's@function toShortPlatform(hostPlatform2) {@function toShortPlatform(hostPlatform2) { if (hostPlatform2 === "freebsd-amd64") return "freebsd-amd64";@' \
-e 's@"linux-x64": \["chrome-linux64", "chrome"\],@"linux-x64": ["chrome-linux64", "chrome"], "freebsd-amd64": ["chrome-freebsdamd64", "chrome"],@g' \
-e 's@"linux-x64": \["chrome-headless-shell-linux64", "chrome-headless-shell"\],@"linux-x64": ["chrome-headless-shell-linux64", "chrome-headless-shell"], "freebsd-amd64": ["chrome-headless-shell-freebsdamd64", "chrome-headless-shell"],@g' \
-e 's@"linux-x64": \["ffmpeg-linux"\],@"linux-x64": ["ffmpeg-linux"], "freebsd-amd64": ["ffmpeg-freebsd"],@g' \
-e 's@const suffix = lookAt\[process.platform\]@const _plt = process.platform === "freebsd" ? "linux" : process.platform; const suffix = lookAt[_plt]@g' \
-e 's@throw new Error("Unsupported platform: " + process.platform)@return process.env.XDG_CACHE_HOME || require("path").join(require("os").homedir(), ".cache")@g' \
lib/coreBundle.js && \
sed -i.bak -e \
's@throw new Error("Unsupported platform: " + process.platform)@return process.env.XDG_CACHE_HOME || require("path").join(require("os").homedir(), ".cache")@g' \
lib/serverRegistry.js && \
sed -i.bak -e \
's@throw new Error("Unsupported platform: " + process.platform)@localCacheDir = process.env.XDG_CACHE_HOME || require("path").join(require("os").homedir(), ".cache")@g' \
lib/tools/cli-client/registry.js && \
grep -q 'freebsd-amd64' lib/coreBundle.js && \
rm -f lib/*.bak lib/tools/cli-client/*.bak && \
CR_REV=$(jq -r '.browsers[] | select(.name == "chromium") | .revision' browsers.json) && \
FFMPEG_REV=$(jq -r '.browsers[] | select(.name == "ffmpeg") | .revision' browsers.json) && \
MP=/usr/local/libexec/ms-playwright && \
mkdir -p "${MP}/chromium-${CR_REV}/chrome-freebsdamd64" \
"${MP}/chromium_headless_shell-${CR_REV}/chrome-headless-shell-freebsdamd64" \
"${MP}/ffmpeg-${FFMPEG_REV}" && \
ln -sf /usr/local/bin/chrome "${MP}/chromium-${CR_REV}/chrome-freebsdamd64/chrome" && \
ln -sf /usr/local/bin/chrome "${MP}/chromium_headless_shell-${CR_REV}/chrome-headless-shell-freebsdamd64/chrome-headless-shell" && \
ln -sf /usr/local/bin/ffmpeg "${MP}/ffmpeg-${FFMPEG_REV}/ffmpeg-freebsd" && \
mkdir -p /app && \
echo "${VERSION}" > /app/version && \
chmod 755 /app && chmod 644 /app/version
# Wrapper script and symlink
COPY root/ /
RUN chmod 755 /usr/local/bin/playwright && \
ln -sf /usr/local/bin/playwright /usr/local/bin/playwright-core
ENV PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 \
PLAYWRIGHT_BROWSERS_PATH=/usr/local/libexec/ms-playwright \
PLAYWRIGHT_HOST_PLATFORM_OVERRIDE=freebsd-amd64 \
NODE_PATH=/usr/local/lib/node_modules
USER bsd