# Official public images/binaries were removed upstream; build fixed release sources.
FROM golang:1.24.2-bookworm AS minio-build
ENV CGO_ENABLED=0 GOMAXPROCS=2 GOTOOLCHAIN=local
RUN git clone --depth 1 --branch RELEASE.2025-04-22T22-12-26Z https://github.com/minio/minio.git /src
WORKDIR /src
RUN go build -p 2 -trimpath -ldflags='-s -w' -o /out/minio .
RUN test "$(git rev-parse HEAD)" = 0d7408fc9969caf07de6a8c3a84f9fbb10a6739e && go build -p 2 -trimpath -ldflags='-s -w -X github.com/minio/minio/cmd.Version=2025-04-22T22:12:26Z -X github.com/minio/minio/cmd.ReleaseTag=RELEASE.2025-04-22T22-12-26Z -X github.com/minio/minio/cmd.CommitID=0d7408fc9969caf07de6a8c3a84f9fbb10a6739e' -o /out/minio .

FROM golang:1.24.2-bookworm AS mc-build
ENV CGO_ENABLED=0 GOMAXPROCS=2 GOTOOLCHAIN=local
RUN git clone --depth 1 --branch RELEASE.2025-04-16T18-13-26Z https://github.com/minio/mc.git /src
WORKDIR /src
RUN go build -p 2 -trimpath -ldflags='-s -w' -o /out/mc .
RUN test "$(git rev-parse HEAD)" = b00526b153a31b36767991a4f5ce2cced435ee8e && go build -p 2 -trimpath -ldflags='-s -w -X github.com/minio/mc/cmd.Version=2025-04-16T18:13:26Z -X github.com/minio/mc/cmd.ReleaseTag=RELEASE.2025-04-16T18-13-26Z -X github.com/minio/mc/cmd.CommitID=b00526b153a31b36767991a4f5ce2cced435ee8e' -o /out/mc .

FROM python:3.13.5-slim AS minio
LABEL org.opencontainers.image.source="https://github.com/minio/minio" org.opencontainers.image.version="RELEASE.2025-04-22T22-12-26Z"
RUN useradd --uid 10002 --create-home minio && mkdir /data && chown 10002:10002 /data
COPY --from=minio-build /out/minio /usr/local/bin/minio
COPY infra/minio/server.sh /server.sh
USER 10002
ENTRYPOINT ["/bin/sh", "/server.sh"]
CMD ["server", "/data", "--address", ":9000", "--console-address", "127.0.0.1:9001"]

FROM debian:bookworm-slim AS mc
LABEL org.opencontainers.image.source="https://github.com/minio/mc" org.opencontainers.image.version="RELEASE.2025-04-16T18-13-26Z"
COPY --from=mc-build /out/mc /usr/local/bin/mc
ENTRYPOINT ["/bin/sh", "/config/bootstrap.sh"]
