This commit is contained in:
k00kzaAntonovaIra
2026-11-06 13:57:29 +03:00
parent ec540a1a72
commit 8d001712fe
194 changed files with 13448 additions and 203 deletions
+35
View File
@@ -0,0 +1,35 @@
# MinIO distributes its security release as source only. Compile the official,
# pinned releases; no dependency on a removed Docker Hub / Quay image or make.
FROM golang:1.24.8-bookworm AS go-build
ENV CGO_ENABLED=0 GOTOOLCHAIN=local GOBIN=/out GOMAXPROCS=2
FROM go-build AS minio-build
RUN go install -p 2 -trimpath \
-ldflags="-s -w -X github.com/minio/minio/cmd.Version=2025-10-15T17:29:55Z -X github.com/minio/minio/cmd.ReleaseTag=RELEASE.2025-10-15T17-29-55Z" \
github.com/minio/minio@RELEASE.2025-10-15T17-29-55Z
FROM go-build AS mc-build
RUN go install -p 2 -trimpath \
-ldflags="-s -w -X github.com/minio/mc/cmd.Version=2025-08-13T08:35:41Z -X github.com/minio/mc/cmd.ReleaseTag=RELEASE.2025-08-13T08-35-41Z" \
github.com/minio/mc@RELEASE.2025-08-13T08-35-41Z
FROM python:3.12.8-slim-bookworm AS server
LABEL org.opencontainers.image.source="https://github.com/minio/minio" \
org.opencontainers.image.version="RELEASE.2025-10-15T17-29-55Z"
ENV PYTHONDONTWRITEBYTECODE=1 PYTHONUNBUFFERED=1
COPY --from=minio-build /out/minio /usr/local/bin/minio
COPY infra/minio/healthcheck.py /opt/minio/healthcheck.py
RUN mkdir /data && chown 10001:10001 /data
USER 10001:10001
EXPOSE 9000
ENTRYPOINT ["minio"]
CMD ["server", "/data", "--address", ":9000", "--console-address", "127.0.0.1:9001", "--certs-dir", "/tmp/minio-certs"]
FROM python:3.12.8-slim-bookworm AS bootstrap
LABEL org.opencontainers.image.source="https://github.com/minio/mc" \
org.opencontainers.image.version="RELEASE.2025-08-13T08-35-41Z"
ENV PYTHONDONTWRITEBYTECODE=1 PYTHONUNBUFFERED=1
COPY --from=mc-build /out/mc /usr/local/bin/mc
COPY infra/minio/bootstrap.py /opt/minio/bootstrap.py
USER 10001:10001
ENTRYPOINT ["python", "/opt/minio/bootstrap.py"]
+77
View File
@@ -0,0 +1,77 @@
"""Idempotent private bucket and least-privilege application account setup."""
import json
import os
from pathlib import Path
import re
import subprocess
import tempfile
from urllib.parse import quote, urlsplit
def main():
bucket = os.environ["S3_BUCKET"]
endpoint = urlsplit(os.environ["S3_ENDPOINT_URL"])
if not re.fullmatch(r"[a-z0-9][a-z0-9.-]{1,61}[a-z0-9]", bucket):
raise ValueError("Invalid S3_BUCKET")
if endpoint.scheme not in ("http", "https") or not endpoint.netloc:
raise ValueError("Invalid S3_ENDPOINT_URL")
root_user = os.environ["MINIO_ROOT_USER"]
root_password = os.environ["MINIO_ROOT_PASSWORD"]
access_key = os.environ["S3_ACCESS_KEY"]
secret_key = os.environ["S3_SECRET_KEY"]
if access_key == root_user or secret_key == root_password:
raise ValueError("API credentials must differ from MinIO root credentials")
if len(secret_key) < 32 or len(root_password) < 32:
raise ValueError("S3 secret and root password must contain at least 32 characters")
mc_env = {
**os.environ,
"MC_HOST_store": "%s://%s:%s@%s" % (
endpoint.scheme, quote(root_user, safe=""),
quote(root_password, safe=""), endpoint.netloc,
),
}
secrets = (root_user, root_password, access_key, secret_key, mc_env["MC_HOST_store"])
with tempfile.TemporaryDirectory(prefix="minio-bootstrap-") as temporary:
def run_mc(step, *arguments, stdin=None):
result = subprocess.run(
["mc", "--config-dir", temporary, *arguments],
input=stdin, env=mc_env, text=True, capture_output=True, timeout=30,
)
if result.returncode:
detail = result.stderr
for value in secrets:
detail = detail.replace(value, "[redacted]")
raise RuntimeError("%s: %s" % (step, detail[:1000]))
run_mc("create bucket", "mb", "--ignore-existing", "store/" + bucket)
run_mc("disable anonymous access", "anonymous", "set", "none", "store/" + bucket)
policy = {
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": ["s3:GetBucketLocation", "s3:ListBucket"],
"Resource": ["arn:aws:s3:::" + bucket],
},
{
"Effect": "Allow",
"Action": ["s3:GetObject", "s3:PutObject", "s3:DeleteObject"],
"Resource": ["arn:aws:s3:::" + bucket + "/originals/*"],
},
],
}
path = Path(temporary) / "api-policy.json"
path.write_text(json.dumps(policy), encoding="utf-8")
run_mc("create policy", "admin", "policy", "create", "store", "messenger-api", str(path))
# stdin avoids placing keys in process arguments. AddUser is an upsert.
run_mc("create API user", "admin", "user", "add", "store", stdin=access_key + "\n" + secret_key + "\n")
# mc treats an already attached policy as success.
run_mc("attach policy", "admin", "policy", "attach", "store", "messenger-api", "--user", access_key)
print("PASS: private bucket and separate restricted API account configured")
if __name__ == "__main__":
main()
+11
View File
@@ -0,0 +1,11 @@
"""Liveness of the private MinIO service; no credentials in process arguments."""
import sys
from urllib.request import urlopen
try:
with urlopen("http://127.0.0.1:9000/minio/health/live", timeout=2) as response:
sys.exit(0 if response.status == 200 else 1)
except OSError:
sys.exit(1)