-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathDockerfile
More file actions
142 lines (114 loc) · 4.49 KB
/
Dockerfile
File metadata and controls
142 lines (114 loc) · 4.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# Multi-stage build for object storage with web console
ARG MINIO_VERSION=latest
ARG CONSOLE_VERSION=v1.7.6
ARG MDS_COMMIT=027fb7f9834e2bd6daba7f62a9d04d9a3606fbe1
# Build web console UI
FROM node:18-alpine AS console-ui-builder
ARG CONSOLE_VERSION
ARG MDS_COMMIT
WORKDIR /app
ENV GIT_TERMINAL_PROMPT=0
RUN apk add --no-cache git jq && \
git clone https://github.com/Harsh-2002/MinIO-Object-Browser.git . && \
git checkout ${CONSOLE_VERSION} && \
git clone https://github.com/Harsh-2002/mds.git /tmp/mds && \
cd /tmp/mds && git checkout ${MDS_COMMIT} && \
cd /app/web-app && \
jq '.dependencies.mds = "file:///tmp/mds"' package.json > /tmp/pkg.json && \
mv /tmp/pkg.json package.json && \
corepack enable && \
yarn install && \
yarn build
# Build console binary
FROM golang:1.24-alpine AS console-builder
# Add architecture arguments
ARG CONSOLE_VERSION
ARG TARGETARCH
ARG TARGETOS=linux
WORKDIR /app
RUN apk add --no-cache git make && \
git clone https://github.com/Harsh-2002/MinIO-Object-Browser.git . && \
git checkout ${CONSOLE_VERSION}
COPY --from=console-ui-builder /app/web-app/build ./web-app/build
# Set GOOS and GOARCH for proper cross-compilation
ENV GOOS=${TARGETOS} GOARCH=${TARGETARCH} CGO_ENABLED=0
RUN make console
# Build storage server from source
FROM golang:1.24-alpine AS server-builder
ARG MINIO_VERSION=latest
# Add architecture arguments
ARG TARGETARCH
ARG TARGETOS=linux
ENV GOPATH=/go
ENV CGO_ENABLED=0
# Set GOOS and GOARCH for proper cross-compilation
ENV GOOS=${TARGETOS}
ENV GOARCH=${TARGETARCH}
WORKDIR /workspace
# Install build dependencies
RUN apk add --no-cache ca-certificates git make curl bash && \
go install aead.dev/minisign/cmd/minisign@v0.2.1
# Clone and build server
RUN git clone https://github.com/minio/minio.git . && \
if [ "$MINIO_VERSION" != "latest" ]; then \
echo "Checking out version: $MINIO_VERSION" && \
git checkout ${MINIO_VERSION}; \
else \
echo "Building from latest master"; \
fi
# Build server binary
RUN COMMIT_ID=$(git rev-parse --short HEAD) && \
echo "Building version: $MINIO_VERSION commit: $COMMIT_ID" && \
CGO_ENABLED=0 go build -trimpath \
-ldflags "-s -w -X github.com/minio/minio/cmd.ReleaseTag=${MINIO_VERSION}" \
-o /usr/bin/minio . && \
/usr/bin/minio --version
# Download and verify client binary - use TARGETARCH instead of BUILDARCH
RUN curl -s -q https://dl.min.io/client/mc/release/linux-${TARGETARCH}/mc -o /usr/bin/mc && \
curl -s -q https://dl.min.io/client/mc/release/linux-${TARGETARCH}/mc.minisig -o /usr/bin/mc.minisig && \
chmod +x /usr/bin/mc && \
/go/bin/minisign -Vqm /usr/bin/mc -x /usr/bin/mc.minisig -P RWTx5Zr1tiHQLwG9keckT0c45M3AGeHD6IvimQHpyRywVWGbP1aVSGav && \
/usr/bin/mc --version
# Final runtime image
FROM alpine:latest
ARG MINIO_VERSION=latest
ARG TARGETARCH
LABEL maintainer="Anurag Vishwakarma <av7312002@gmail.com>" \
version="${MINIO_VERSION}" \
org.opencontainers.image.source="https://github.com/minio/minio" \
org.opencontainers.image.version="${MINIO_VERSION}" \
org.opencontainers.image.licenses="AGPL-3.0"
# Install runtime dependencies
RUN apk add --no-cache ca-certificates curl bash && \
mkdir -p /data /etc/minio/console
# Copy binaries
COPY --from=server-builder /usr/bin/minio /usr/bin/minio
COPY --from=server-builder /usr/bin/mc /usr/bin/mc
COPY --from=console-builder /app/console /usr/bin/console
# Copy license files
COPY --from=server-builder /workspace/CREDITS /licenses/CREDITS
COPY --from=server-builder /workspace/LICENSE /licenses/LICENSE
# Copy startup script
COPY start.sh /usr/bin/start.sh
RUN chmod +x /usr/bin/start.sh
# Server configuration
ENV MINIO_UPDATE_MINISIGN_PUBKEY="RWTx5Zr1tiHQLwG9keckT0c45M3AGeHD6IvimQHpyRywVWGbP1aVSGav" \
MC_CONFIG_DIR=/tmp/.mc
# Console configuration
ENV CONSOLE_MINIO_SERVER=http://localhost:9000
# Configurable ports
ENV MINIO_API_PORT=9000 \
MINIO_CONSOLE_PORT=9001 \
MINIO_ADMIN_CONSOLE_PORT=9002
# Expose ports
EXPOSE 9000 9001 9002
# Health check (respects TLS certificates if present)
HEALTHCHECK --interval=30s --timeout=20s --start-period=5s --retries=3 \
CMD sh -c 'CERT_DIR="${MINIO_CERTS_DIR:-/data/.minio/certs}"; SCHEME="http"; FLAGS="-sf"; \
if [ -f "${CERT_DIR}/public.crt" ] && [ -f "${CERT_DIR}/private.key" ]; then \
SCHEME="https"; FLAGS="-sfk"; \
fi; \
curl ${FLAGS} ${SCHEME}://localhost:${MINIO_API_PORT}/minio/health/live || exit 1'
WORKDIR /data
# Start services
CMD ["/usr/bin/start.sh"]