# The replacement realization: Go + net/http + pgx, database reached through
# one DATABASE_URL string instead of reference/'s separate PG* variables.
#
# `go.mod` pins pgx to one exact version, but `go.sum` is not committed, so
# the builder stage below reconstructs it from that pinned version at build
# time: `go mod download` fetches the declared module graph and writes the
# checksums `go.sum` needs, `-mod=mod` lets `go build` add any entry
# `download` left implicit. Building this image
# therefore needs the docker daemon to reach the module proxy — a one-time
# cost on first build, cached by docker's own layers after.
FROM golang:1.22.5-bookworm AS builder

WORKDIR /src
COPY go.mod main.go ./
RUN go mod download && go build -mod=mod -o /out/parity-replacement .

FROM debian:bookworm-slim
COPY --from=builder /out/parity-replacement /usr/local/bin/parity-replacement

EXPOSE 8080

CMD ["/usr/local/bin/parity-replacement"]
