ARG BASE_REGISTRY=docker.m.daocloud.io/library
FROM ${BASE_REGISTRY}/golang:1.25-bookworm AS build
WORKDIR /src
ENV GOPROXY=https://goproxy.cn,direct
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 GOOS=linux go build -o /out/platform .

FROM ${BASE_REGISTRY}/debian:bookworm-slim
RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates \
  && rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY --from=build /out/platform /app/platform
COPY etc/platform.docker.yaml /app/etc/platform.yaml
RUN mkdir -p /app/data/uploads
EXPOSE 8888
CMD ["/app/platform", "-f", "/app/etc/platform.yaml"]
