Bring the application, own tests, Dockerfile, toolchain, compose stack,
HAProxy, k6, RustFS and RabbitMQ configuration, migrations, hooks,
scenario scripts and the CI job from the lab 5 solution commit 64d5c67,
keep the lab 5 Makefile targets on top of the unchanged skeleton
targets, and append the lab 5 solution variables to the skeleton
.env.example. The package and the application follow the contract
version 1.6.0, and the image, the throwaway test containers and the
broker vhost description are tagged lab6 so they do not collide with a
lab 5 stand on the same host.
This is the starting point of the lab 6 cycle: lint, own tests and the
offline skeleton check pass before any lab 6 change.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
27 lines
1.6 KiB
Bash
Executable File
27 lines
1.6 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
|
|
worker_key=$(secret s3_worker_access_key_id)
|
|
sed "s/messenger-attachments/$bucket/g" /s3/worker-policy.json > /tmp/worker-policy.json
|
|
rc admin policy create root messenger-worker /tmp/worker-policy.json >/dev/null
|
|
rc admin user add root "$worker_key" "$(secret s3_worker_secret_access_key)" >/dev/null
|
|
rc admin policy attach root messenger-worker --user "$worker_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\""
|
|
rc admin user info root "$worker_key" --json | grep -q '"messenger-worker"'
|
|
echo "s3-init: bucket=$bucket anonymous=private policy=$policy worker=messenger-worker lifecycle=abort-incomplete-uploads"
|