-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
59 lines (49 loc) · 2.46 KB
/
Copy pathDockerfile
File metadata and controls
59 lines (49 loc) · 2.46 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
# codevideo-cli render worker image (multi-stage).
#
# Build stage compiles the Go CLI with the exact toolchain go.mod pins (1.26) —
# don't rely on the runtime image's packaged Go, which lags. Runtime stage is
# zenika/alpine-chrome:with-puppeteer (Chromium + Node + Puppeteer) plus ffmpeg
# (the webm -> mp4 step shells out to it). Published to Docker Hub as
# fullstackcraft/codevideo-cli and pulled by the codevideo-api compose stack.
# ---- build: compile the static Go binary --------------------------------------
FROM golang:1.26-alpine AS build
RUN apk add --no-cache git
WORKDIR /src
# Go deps first for layer caching.
COPY go.mod go.sum ./
RUN go mod download
# CGO off -> a fully static binary that runs on the Alpine runtime base. VERSION
# is injected by release builds (consumed by main.go's `var version`).
COPY . .
ARG VERSION=dev
RUN CGO_ENABLED=0 go build -ldflags "-X main.version=${VERSION}" -o /out/codevideo
# ---- runtime: Chromium + Node/Puppeteer + ffmpeg ------------------------------
FROM zenika/alpine-chrome:with-puppeteer AS runtime
# apk needs root; Chrome runs with --no-sandbox, so root is expected here (see
# the --no-sandbox note in recordVideoV3.js).
USER root
RUN apk add --no-cache ffmpeg
WORKDIR /app
# The compiled worker. The Gatsby static site is go:embed'd into the binary, so
# nothing else is needed for the manifest/static servers.
COPY --from=build /out/codevideo /app/codevideo
# The Puppeteer runner + its Node deps. server.go execs
# `node <execDir>/puppeteer-runner/recordVideoV3.js`, so it must sit next to the
# binary. Chromium comes from the base image — no browser download here.
COPY puppeteer-runner/ /app/puppeteer-runner/
WORKDIR /app/puppeteer-runner
RUN npm install
WORKDIR /app
# Runtime config for the containerized serve worker:
# CODEVIDEO_CHROME_PATH - resolveChromeExecutable() honors this first, so pin
# the base image's Chromium instead of relying on PATH resolution.
# CODEVIDEO_WORK_DIR - the shared render queue the API bind-mounts in. Go's
# WorkFolder()/VideoFolder() and the --manifest-path/--output-webm args
# passed to the Node runner all derive from it, keeping both sides in sync.
ENV CODEVIDEO_CHROME_PATH=/usr/bin/chromium-browser \
CODEVIDEO_WORK_DIR=/work/tmp/v3
# Filesystem-queue worker: no inbound port. The manifest (:7000) and static
# (:7001) servers it starts are reached only by its own Puppeteer over
# localhost, so nothing is published.
ENTRYPOINT ["/app/codevideo"]
CMD ["-m", "serve"]