forked from heygen-com/hyperframes
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.render
More file actions
59 lines (51 loc) · 2.82 KB
/
Copy pathDockerfile.render
File metadata and controls
59 lines (51 loc) · 2.82 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
FROM node:22-bookworm-slim
ARG HYPERFRAMES_VERSION=latest
# Set automatically by `docker build --platform` (BuildKit); we use it to
# decide whether to install chrome-headless-shell, which only ships for
# linux64 (see https://googlechromelabs.github.io/chrome-for-testing/).
ARG TARGETARCH=amd64
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates curl unzip ffmpeg chromium \
libgbm1 libnss3 libatk-bridge2.0-0 libdrm2 libxcomposite1 \
libxdamage1 libxrandr2 libcups2 libasound2 libpangocairo-1.0-0 \
libxshmfence1 libgtk-3-0 \
fonts-liberation fonts-noto-color-emoji fonts-noto-cjk fonts-noto-core \
fonts-noto-extra fonts-noto-ui-core fonts-freefont-ttf fonts-dejavu-core \
fontconfig \
&& rm -rf /var/lib/apt/lists/* && apt-get clean && fc-cache -fv
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium
ENV CONTAINER=true
# chrome-headless-shell unlocks BeginFrame-based deterministic capture but the
# project only publishes a linux64 binary. On arm64 we skip the install and
# let the engine fall back to system chromium (set via
# PUPPETEER_EXECUTABLE_PATH above). The wrapper script below only sets
# PRODUCER_HEADLESS_SHELL_PATH when the binary is actually present.
RUN if [ "$TARGETARCH" = "amd64" ]; then \
npx --yes @puppeteer/browsers install chrome-headless-shell@stable \
--path /root/.cache/puppeteer; \
else \
echo "Skipping chrome-headless-shell install on ${TARGETARCH} (linux64-only); using system chromium."; \
fi
RUN npm install -g hyperframes@${HYPERFRAMES_VERSION}
# Wrapper script: resolves chrome-headless-shell path at build time when
# available so the engine uses BeginFrame rendering. On arm64 (no
# chrome-headless-shell) it leaves PRODUCER_HEADLESS_SHELL_PATH unset, so the
# engine falls back to PUPPETEER_EXECUTABLE_PATH (system chromium).
#
# If TARGETARCH=amd64 and the binary is missing, fail the build loudly — the
# previous (pre-PR) wrapper used an `&&` chain that crashed `docker build` in
# this case, and silently downgrading to system chromium on amd64 would mask
# golden-baseline regressions.
RUN SHELL_PATH=$(find /root/.cache/puppeteer/chrome-headless-shell -name "chrome-headless-shell" -type f 2>/dev/null | head -1); \
if [ -n "$SHELL_PATH" ]; then \
printf '#!/bin/sh\nexport PRODUCER_HEADLESS_SHELL_PATH=%s\nexec hyperframes render "$@"\n' "$SHELL_PATH" > /usr/local/bin/hf-render; \
elif [ "$TARGETARCH" = "amd64" ]; then \
echo "ERROR: chrome-headless-shell binary not found on amd64 — @puppeteer/browsers install must have failed or moved its cache layout." >&2; \
exit 1; \
else \
printf '#!/bin/sh\nexec hyperframes render "$@"\n' > /usr/local/bin/hf-render; \
fi \
&& chmod +x /usr/local/bin/hf-render
WORKDIR /project
ENTRYPOINT ["hf-render"]