# 多阶段构建，纯 Go（CGO_ENABLED=0）+ modernc.org/sqlite，适合 Alpine运行。
# 对外映射建议：主机 28088 ->容器 8088（见 docker-compose.yml）。
FROM golang:alpine AS build
WORKDIR /src
RUN apk add --no-cache git
COPY go.mod go.sum ./
RUN go mod download
COPY . .
ENV CGO_ENABLED=0
RUN go build -trimpath -ldflags="-s -w" -o /out/mengpost-api .

FROM alpine:3.21
RUN apk add --no-cache ca-certificates tzdata
ENV TZ=Asia/Shanghai
WORKDIR /app
RUN mkdir -p /app/data
COPY --from=build /out/mengpost-api /app/mengpost-api

ENV GIN_MODE=release
ENV MP_PORT=8088
ENV MP_DB=/app/data/mengpost.db

EXPOSE 8088
ENTRYPOINT ["/app/mengpost-api"]
