FROM golang:1.25.3 AS build
ENV GIN_MODE=release
ENV PORT=4320
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download

COPY . .
RUN GOOS=linux GOARCH=amd64 GOAMD64=v1 go build -pgo=auto -ldflags="-s -w" -o /bin/esign-server main.go

FROM alpine:latest
WORKDIR /app
COPY --from=build /bin/esign-server ./server
EXPOSE $PORT
CMD ["./server"]