···11+#!/bin/sh
22+33+# Start MinIO in the background
44+minio server /data --console-address ":9001" &
55+66+# Wait for MinIO to be ready before running the initialization script
77+until curl -s http://localhost:9000/minio/health/ready; do
88+ echo "Waiting for MinIO to be ready..."
99+ sleep 5
1010+done
1111+1212+# Run the bucket setup script
1313+sh /init-script.sh
1414+1515+# Keep the container running
1616+wait $!
+60
docker/minio/init-script.sh
···11+#!/bin/sh
22+33+set -e
44+55+# MinIO configuration
66+MINIO_HOST=${MINIO_HOST:-"http://localhost:9000"}
77+MINIO_ACCESS_KEY=${MINIO_ACCESS_KEY:-"minioadmin"}
88+MINIO_SECRET_KEY=${MINIO_SECRET_KEY:-"minioadmin"}
99+1010+# Max retries and delay
1111+MAX_RETRIES=10
1212+RETRY_COUNT=0
1313+RETRY_DELAY=5 # 5 seconds delay between retries
1414+1515+# Function to retry a command
1616+retry_command() {
1717+ local cmd=$1
1818+ until $cmd; do
1919+ RETRY_COUNT=$((RETRY_COUNT + 1))
2020+ if [ $RETRY_COUNT -ge $MAX_RETRIES ]; then
2121+ echo "Command failed after $MAX_RETRIES attempts. Exiting..."
2222+ exit 1
2323+ fi
2424+ echo "Command failed. Retrying ($RETRY_COUNT/$MAX_RETRIES)..."
2525+ sleep $RETRY_DELAY
2626+ done
2727+}
2828+2929+# Function to create a bucket if it doesn't exist
3030+create_bucket_if_not_exists() {
3131+ BUCKET_NAME=$1
3232+ echo "Checking if bucket $BUCKET_NAME exists..."
3333+ if mc ls local/$BUCKET_NAME > /dev/null 2>&1; then
3434+ echo "Bucket $BUCKET_NAME already exists. Skipping creation."
3535+ else
3636+ echo "Creating bucket $BUCKET_NAME..."
3737+ mc mb local/$BUCKET_NAME
3838+ fi
3939+}
4040+4141+# Function to set a bucket public
4242+set_bucket_public() {
4343+ BUCKET_NAME=$1
4444+ echo "Setting bucket $BUCKET_NAME as public..."
4545+ mc anonymous set public local/$BUCKET_NAME
4646+}
4747+4848+# Retry MinIO Client alias setup
4949+retry_command "mc alias set local $MINIO_HOST $MINIO_ACCESS_KEY $MINIO_SECRET_KEY"
5050+5151+# Create the necessary buckets
5252+create_bucket_if_not_exists "patient-bucket"
5353+create_bucket_if_not_exists "facility-bucket"
5454+5555+# Set only facility-bucket as public
5656+set_bucket_public "facility-bucket"
5757+5858+# Graceful exit
5959+echo "Bucket setup completed successfully."
6060+exit 0
+1-1
docs/local-setup/configuration.rst
···1616 - care (main repo)
1717 - redis (in-memory cache)
1818 - celery (task queue)
1919- - localstack (to mimic AWS services locally)
1919+ - minio (to mimic AWS services locally)
20202121This is the most recommended way of setting up care locally,
2222as it installs appropriate dependencies in containers so there