Containerfile
| 1 | FROM golang:1.26-alpine AS builder |
| 2 | |
| 3 | WORKDIR /build |
| 4 | COPY go.mod go.sum ./ |
| 5 | RUN go mod download |
| 6 | |
| 7 | COPY . . |
| 8 | RUN CGO_ENABLED=0 go build -o vidarchive ./cmd/vidarchive |
| 9 | |
| 10 | FROM alpine:3.24 |
| 11 | |
| 12 | RUN apk --no-cache add ca-certificates ffmpeg python3 py3-pip \ |
| 13 | && python3 -m venv /opt/ytdlp \ |
| 14 | && /opt/ytdlp/bin/pip install --no-cache-dir --upgrade yt-dlp |
| 15 | |
| 16 | ENV PATH="/opt/ytdlp/bin:${PATH}" |
| 17 | |
| 18 | WORKDIR /app |
| 19 | |
| 20 | COPY --from=builder /build/vidarchive /app/vidarchive |
| 21 | COPY --from=builder /build/web /app/web |
| 22 | |
| 23 | ENV VIDARCHIVE_DATA_DIR=/data |
| 24 | ENV VIDARCHIVE_PORT=8080 |
| 25 | |
| 26 | VOLUME ["/data"] |
| 27 | |
| 28 | EXPOSE 8080 |
| 29 | |
| 30 | # /healthz reports 503 when the database is unreachable. start-period covers |
| 31 | # migrations on first boot so they don't count as failures. |
| 32 | HEALTHCHECK --interval=30s --timeout=5s --start-period=15s --retries=3 \ |
| 33 | CMD wget -q -O /dev/null "http://127.0.0.1:${VIDARCHIVE_PORT}/healthz" || exit 1 |
| 34 | |
| 35 | # exec form, so the app is PID 1 and gets SIGTERM directly — it needs that for a |
| 36 | # graceful shutdown (drain requests, kill yt-dlp children, checkpoint the DB). |
| 37 | ENTRYPOINT ["/app/vidarchive"] |
| 38 |