FROM golang:1.25.6 AS builder


WORKDIR /app

COPY  . .
ENV CGO_ENABLED=0
ENV GIN_MODE=release
RUN go mod tidy
RUN go build -ldflags "-s -w" -o backend ./cmd/main.go


FROM alpine:3.23.0

COPY --from=builder /app/backend .

EXPOSE 8080
RUN apk add --no-cache curl
HEALTHCHECK CMD curl --fail http://localhost:8080/health || exit 1
CMD ["./backend"]
