FROM golang:1.23-alpine AS builder

ARG BUILD_COMMIT=unknown
ARG BUILD_TIME=unknown

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

COPY . .
RUN CGO_ENABLED=0 GOOS=linux go build \
    -ldflags "-X git.nixc.us/a250/ss-atlas/internal/version.Commit=${BUILD_COMMIT} -X git.nixc.us/a250/ss-atlas/internal/version.BuildTime=${BUILD_TIME}" \
    -o /ss-atlas ./cmd/

FROM alpine:3.21
RUN apk add --no-cache ca-certificates docker-cli
WORKDIR /app
COPY --from=builder /ss-atlas /app/ss-atlas
COPY templates/ /app/templates/

EXPOSE 8080
ENTRYPOINT ["/app/ss-atlas"]
