FROM golang:1.26-alpine AS builder WORKDIR /build COPY go.mod go.sum ./ RUN go mod download COPY . . RUN CGO_ENABLED=0 go build -o vidarchive ./cmd/vidarchive FROM alpine:3.24 RUN apk --no-cache add ca-certificates ffmpeg python3 py3-pip \ && python3 -m venv /opt/ytdlp \ && /opt/ytdlp/bin/pip install --no-cache-dir --upgrade yt-dlp ENV PATH="/opt/ytdlp/bin:${PATH}" WORKDIR /app COPY --from=builder /build/vidarchive /app/vidarchive COPY --from=builder /build/web /app/web ENV VIDARCHIVE_DATA_DIR=/data ENV VIDARCHIVE_PORT=8080 VOLUME ["/data"] EXPOSE 8080 # /healthz reports 503 when the database is unreachable. start-period covers # migrations on first boot so they don't count as failures. HEALTHCHECK --interval=30s --timeout=5s --start-period=15s --retries=3 \ CMD wget -q -O /dev/null "http://127.0.0.1:${VIDARCHIVE_PORT}/healthz" || exit 1 # exec form, so the app is PID 1 and gets SIGTERM directly — it needs that for a # graceful shutdown (drain requests, kill yt-dlp children, checkpoint the DB). ENTRYPOINT ["/app/vidarchive"]