##
## Build
##

FROM golang:1.24-alpine AS build

ARG VERSION

WORKDIR /app

COPY go.mod go.sum ./
RUN go mod download

COPY . ./
RUN CGO_ENABLED=0 go build \
        -ldflags "-s -w -X 'ost.ch/educdn/cmd.version=${VERSION}'" \
        -trimpath \
        -o ./bin/educdn \
        main.go

RUN apk add --no-cache ca-certificates

##
## Prepare Container
##

FROM scratch

COPY --from=build /app/bin/educdn /educdn
COPY --from=build /etc/ssl/certs /etc/ssl/certs

EXPOSE 8080
ENTRYPOINT ["/educdn"]
