FROM golang:1.25-alpine AS builder

WORKDIR /app

ENV GOTOOLCHAIN=local

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

COPY src/ ./

RUN CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH \
    go build -ldflags="-s -w" -trimpath -o /ax .

FROM alpine:latest

RUN apk --no-cache add ca-certificates

WORKDIR /data

COPY --from=builder /ax /usr/local/bin/ax

EXPOSE 7000

ENTRYPOINT ["ax", "serve"]
