feat(lab5): implement reliable image pipeline and track 2

This commit is contained in:
sashadugina06
2026-11-20 18:43:47 +03:00
parent 276dbdad8a
commit b423b93e2a
62 changed files with 3799 additions and 38 deletions
+12
View File
@@ -0,0 +1,12 @@
#!/bin/sh
set -eu
# Compose file-based secrets inherit host ownership. Copy only the secrets
# mounted for this role before dropping privileges.
install -d -m 0700 -o appuser -g appuser /run/app-secrets
for key in DATABASE_URL_FILE S3_ACCESS_KEY_ID_FILE S3_SECRET_ACCESS_KEY_FILE BROKER_URL_FILE; do
source_file=$(printenv "$key") || continue
target="/run/app-secrets/$key"
install -m 0400 -o appuser -g appuser "$source_file" "$target"
export "$key=$target"
done
exec setpriv --reuid=appuser --regid=appuser --init-groups -- "$@"
+4
View File
@@ -0,0 +1,4 @@
#!/bin/sh
set -eu
export RABBITMQ_DEFAULT_PASS="$(cat /run/secrets/broker_password)"
exec docker-entrypoint.sh rabbitmq-server
+35
View File
@@ -0,0 +1,35 @@
global
log stdout format raw local0
maxconn 1024
defaults
log global
mode http
option httplog
timeout connect 1s
timeout client 60s
timeout server 60s
timeout check 1s
# Never replay a potentially committed POST automatically.
retries 0
resolvers docker
nameserver dns 127.0.0.11:53
resolve_retries 3
timeout resolve 1s
timeout retry 1s
hold valid 1s
hold obsolete 1s
hold nx 1s
frontend public
bind :8080
default_backend replicas
backend replicas
balance roundrobin
option httpchk
http-check send meth GET uri /health/ready ver HTTP/1.1 hdr Host api
http-check expect status 200
default-server inter 1s fastinter 500ms downinter 1s fall 2 rise 2 resolvers docker init-addr libc,none
server-template api 1-10 api:8080 check
+8
View File
@@ -0,0 +1,8 @@
#!/bin/sh
set -eu
mc alias set local http://s3:9000 "$(cat /run/secrets/s3_root_user)" "$(cat /run/secrets/s3_root_password)" >/dev/null
mc mb --ignore-existing local/messenger-attachments
mc anonymous set none local/messenger-attachments
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 attachments-api /policy.json
mc admin policy attach local attachments-api --user "$(cat /run/secrets/s3_access_key_id)"
+34
View File
@@ -0,0 +1,34 @@
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:GetObject",
"s3:PutObject",
"s3:DeleteObject"
],
"Resource": [
"arn:aws:s3:::messenger-attachments/originals/*",
"arn:aws:s3:::messenger-attachments/staging/*",
"arn:aws:s3:::messenger-attachments/results/*"
]
},
{
"Effect": "Allow",
"Action": [
"s3:ListBucket"
],
"Resource": [
"arn:aws:s3:::messenger-attachments"
],
"Condition": {
"StringLike": {
"s3:prefix": [
"originals/*", "staging/*", "results/*"
]
}
}
}
]
}