forked from mtusi2026/mtusi2026lab5
Bring the application, own tests, Dockerfile, toolchain, compose stack, HAProxy, k6 and RustFS configuration, migrations, hooks, evidence and scenario scripts and the CI job from the lab 4 solution commit d2744bc, merge the lab 4 Makefile targets into the lab 5 skeleton Makefile without touching its targets, and append the lab 4 solution variables to the skeleton .env.example. The package and the application follow the contract version 1.5.0, and the image and the throwaway test containers are tagged lab5 so they do not collide with a lab 4 stand on the same host. This is the starting point of the lab 5 cycle: lint, own tests and the offline skeleton check pass before any lab 5 change. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
21 lines
1.1 KiB
Bash
Executable File
21 lines
1.1 KiB
Bash
Executable File
#!/bin/sh
|
|
set -eu
|
|
secret() { tr -d '\r\n' < "/run/secrets/$1"; }
|
|
bucket="${S3_BUCKET:-messenger-attachments}"
|
|
endpoint="${S3_ENDPOINT:-http://s3:9000}"
|
|
policy="${S3_API_POLICY:-messenger-api}"
|
|
RC_HOST_root="${endpoint%%://*}://$(secret s3_root_user):$(secret s3_root_password)@${endpoint#*://}"
|
|
export RC_HOST_root
|
|
api_key=$(secret s3_access_key_id)
|
|
rc ready root --timeout 10 >/dev/null
|
|
rc bucket create --ignore-existing "root/$bucket" >/dev/null
|
|
rc bucket anonymous set private "root/$bucket" >/dev/null
|
|
sed "s/messenger-attachments/$bucket/g" /s3/api-policy.json > /tmp/api-policy.json
|
|
rc admin policy create root "$policy" /tmp/api-policy.json >/dev/null
|
|
rc admin user add root "$api_key" "$(secret s3_secret_access_key)" >/dev/null
|
|
rc admin policy attach root "$policy" --user "$api_key" >/dev/null
|
|
rc bucket lifecycle rule import "root/$bucket" /s3/lifecycle.json >/dev/null
|
|
rc bucket anonymous get "root/$bucket" --json | grep -q '"permission": *"private"'
|
|
rc admin user info root "$api_key" --json | grep -q "\"$policy\""
|
|
echo "s3-init: bucket=$bucket anonymous=private policy=$policy lifecycle=abort-incomplete-uploads"
|