# ★ FORK (2026-09-22): upstream v0.8.6 pins golang:1.27.1-alpine3.24.1, a tag that
# does not exist on Docker Hub (the golang image names alpine minors only:
# 1.27.1-alpine3.24). Same Go, same Alpine line; only the tag is one that resolves.
FROM golang:1.27.1-alpine3.24 AS builder

WORKDIR /app
COPY . /app
# ★ FORK (§15, D18): the build names itself, so the footer, /health and the
# source download all say which commit is running. Upstream's plain build is
# unchanged when the argument is not given.
ARG GLANCE_VERSION=dev
RUN CGO_ENABLED=0 go build -ldflags "-s -w -X github.com/glanceapp/glance/internal/glance.buildVersion=${GLANCE_VERSION}" .

FROM alpine:3.24.1

WORKDIR /app
COPY --from=builder /app/glance .
# ★ FORK (§15, D18): AGPL-3.0 §13 — the Corresponding Source this image offers at
# /source.tar.gz. zeman-build-image.sh writes it from the same commit the binary is
# built from. A build without it FAILS here rather than shipping an image whose
# licence offer answers 503: a missing file is loud, a non-compliant image is not.
COPY build/source.tar.gz /app/source.tar.gz

EXPOSE 8080/tcp
ENTRYPOINT ["/app/glance", "--config", "/app/config/glance.yml"]
