[+] lab4
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
# 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"]
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"Version": "2012-10-17",
|
||||
"Statement": [
|
||||
{"Effect":"Allow","Action":["s3:GetBucketLocation"],"Resource":["arn:aws:s3:::messenger-attachments"]},
|
||||
{"Effect":"Allow","Action":["s3:ListBucket"],"Resource":["arn:aws:s3:::messenger-attachments"],"Condition":{"StringLike":{"s3:prefix":["originals/*"]}}},
|
||||
{"Effect":"Allow","Action":["s3:GetObject","s3:PutObject","s3:DeleteObject"],"Resource":["arn:aws:s3:::messenger-attachments/originals/*"]}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
mc alias set local http://minio:9000 "$(cat /run/secrets/minio_root_user)" "$(cat /run/secrets/minio_root_password)" >/dev/null
|
||||
mc mb --ignore-existing local/messenger-attachments >/dev/null
|
||||
mc anonymous set none local/messenger-attachments >/dev/null
|
||||
mc admin user add local "$(cat /run/secrets/s3_access_key_id)" "$(cat /run/secrets/s3_secret_access_key)" >/dev/null
|
||||
mc admin policy create local messenger-api /config/api-policy.json >/dev/null
|
||||
mc admin policy attach local messenger-api --user "$(cat /run/secrets/s3_access_key_id)" >/dev/null
|
||||
printf '%s\n' 'PASS: private bucket and restricted API policy ready (credentials hidden).'
|
||||
@@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
export MINIO_ROOT_USER="$(cat /run/secrets/minio_root_user)"
|
||||
export MINIO_ROOT_PASSWORD="$(cat /run/secrets/minio_root_password)"
|
||||
exec minio "$@"
|
||||
@@ -0,0 +1,62 @@
|
||||
worker_processes 1;
|
||||
error_log /dev/stderr warn;
|
||||
pid /var/run/nginx.pid;
|
||||
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
http {
|
||||
access_log off;
|
||||
server_tokens off;
|
||||
limit_conn_zone $server_name zone=uploads:64k;
|
||||
|
||||
# Docker DNS; resolve updates the upstream when replicas get new IPs.
|
||||
resolver 127.0.0.11 valid=1s ipv6=off;
|
||||
resolver_timeout 1s;
|
||||
|
||||
upstream messenger {
|
||||
zone messenger 64k;
|
||||
# All A records of api participate in the default round-robin balancing.
|
||||
server api:8080 resolve max_fails=1 fail_timeout=2s;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 8080;
|
||||
server_name messenger;
|
||||
|
||||
location ~ ^/api/v1/chats/[^/]+/attachments$ {
|
||||
limit_conn uploads 16;
|
||||
client_max_body_size 11m;
|
||||
client_body_buffer_size 64k;
|
||||
client_body_timeout 10s;
|
||||
proxy_request_buffering on;
|
||||
proxy_pass http://messenger;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_set_header Connection "";
|
||||
proxy_connect_timeout 1s;
|
||||
proxy_read_timeout 30s;
|
||||
proxy_send_timeout 30s;
|
||||
proxy_next_upstream error timeout http_503;
|
||||
proxy_next_upstream_tries 2;
|
||||
}
|
||||
|
||||
location / {
|
||||
proxy_pass http://messenger;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_set_header Connection "";
|
||||
|
||||
proxy_connect_timeout 1s;
|
||||
proxy_read_timeout 5s;
|
||||
proxy_send_timeout 5s;
|
||||
|
||||
# Passive checks. Do NOT enable non_idempotent: an already-sent POST
|
||||
# must not be resent by Nginx after an ambiguous response.
|
||||
proxy_next_upstream error timeout http_503;
|
||||
proxy_next_upstream_tries 2;
|
||||
proxy_next_upstream_timeout 6s;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user