Реализована лабораторная работа 5 на оценку 4

This commit is contained in:
MacBook
2026-11-03 14:05:38 +03:00
parent 276dbdad8a
commit 9db2fa724a
41 changed files with 4267 additions and 37 deletions
+16
View File
@@ -0,0 +1,16 @@
# Build MinIO from a pinned commit of the official upstream source.
FROM golang:1.26.8-alpine3.23@sha256:a8fa79c5bd40d880b52bd3b6d7669ecdcfd00e85facdd427d279efb5ddd79cb1 AS build
ADD --checksum=sha256:be6d0bd3696c3a13a35f02d3a0280b64319c67918b4501c5c3d87f96d000085c https://codeload.github.com/minio/minio/tar.gz/refs/tags/RELEASE.2025-10-15T17-29-55Z /source.tar.gz
WORKDIR /src
RUN tar -xzf /source.tar.gz --strip-components=1 -C /src
RUN --mount=type=cache,target=/go/pkg/mod --mount=type=cache,target=/root/.cache/go-build \
CGO_ENABLED=0 GOMAXPROCS=2 go build -p 2 -trimpath -buildvcs=false \
-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 -X github.com/minio/minio/cmd.CommitID=9e49d5e7a648f00e26f2246f4dc28e6b07f8c84a -X github.com/minio/minio/cmd.CopyrightYear=2025' \
-o /minio .
FROM busybox:1.37.0-musl
COPY --from=build /minio /minio
COPY --from=build /src/LICENSE /licenses/MinIO-LICENSE
COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
RUN mkdir -p /data
ENTRYPOINT ["/minio"]
+8
View File
@@ -0,0 +1,8 @@
FROM application AS app_binary
FROM python:3.13.7-slim-bookworm
RUN pip install --no-cache-dir Pillow==12.0.0
COPY --from=app_binary /messenger /messenger
COPY worker/process_image.py /opt/process_image.py
USER 65532:65532
ENTRYPOINT ["/messenger"]
CMD ["worker"]
+43
View File
@@ -0,0 +1,43 @@
#!/bin/sh
set -eu
upstream=/run/nginx-upstream.conf
write_servers() {
if [ "$1" = 1 ]; then
printf '%s\n' 'server api1:8080 resolve max_fails=0;'
fi
if [ "$2" = 1 ]; then
printf '%s\n' 'server api2:8080 resolve max_fails=0;'
fi
}
# With no healthy replica, keep both reachable so API can return its normal
# 401/503 JSON responses instead of Nginx reporting "no live upstreams".
write_servers 1 1 > "$upstream"
monitor() {
sleep 2
while :; do
ready1=0
ready2=0
wget -q -T 2 -O /dev/null http://api1:8080/health/ready && ready1=1 || true
wget -q -T 2 -O /dev/null http://api2:8080/health/ready && ready2=1 || true
if [ "$ready1" = 0 ] && [ "$ready2" = 0 ]; then
ready1=1
ready2=1
fi
next=$(mktemp /run/nginx-upstream.XXXXXX)
write_servers "$ready1" "$ready2" > "$next"
if cmp -s "$next" "$upstream"; then
rm -f "$next"
else
mv "$next" "$upstream"
nginx -t >/dev/null 2>&1 && nginx -s reload
fi
sleep 1
done
}
monitor &
exec nginx -g 'daemon off;'
+35
View File
@@ -0,0 +1,35 @@
events {}
http {
access_log /dev/stdout;
error_log /dev/stderr notice;
resolver 127.0.0.11 valid=2s ipv6=off;
upstream messenger_api {
zone messenger_api 64k;
include /run/nginx-upstream.conf;
keepalive 16;
}
server {
listen 8080;
client_max_body_size 0;
client_body_timeout 20s;
location / {
proxy_request_buffering off;
proxy_buffering off;
proxy_pass http://messenger_api;
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_connect_timeout 500ms;
proxy_send_timeout 65s;
proxy_read_timeout 65s;
proxy_next_upstream error timeout http_502 http_503 http_504;
proxy_next_upstream_tries 2;
}
}
}