Skip to content

Commit

Permalink
Added relevant comments & suggested code changes
Browse files Browse the repository at this point in the history
  • Loading branch information
amjithtitus09 committed Dec 9, 2024
1 parent 2f14d3d commit 2a23839
Showing 5 changed files with 18 additions and 7 deletions.
4 changes: 2 additions & 2 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -27,8 +27,8 @@ services:
image: minio/minio:latest
restart: unless-stopped
environment:
MINIO_ROOT_USER: minioadmin
MINIO_ROOT_PASSWORD: minioadmin
MINIO_ROOT_USER: ${MINIO_ACCESS_KEY:-minioadmin}
MINIO_ROOT_PASSWORD: ${MINIO_SECRET_KEY:-minioadmin}
AWS_DEFAULT_REGION: ap-south-1 # To maintain compatibility with existing apps
volumes:
- "./care/media/minio:/data"
4 changes: 2 additions & 2 deletions docker/.local.env
Original file line number Diff line number Diff line change
@@ -10,8 +10,8 @@ CELERY_BROKER_URL=redis://redis:6379/0
DJANGO_DEBUG=False

BUCKET_REGION=ap-south-1
BUCKET_KEY=minioadmin
BUCKET_SECRET=minioadmin
BUCKET_KEY=${MINIO_ACCESS_KEY:-minioadmin}
BUCKET_SECRET=${MINIO_SECRET_KEY:-minioadmin}
BUCKET_ENDPOINT=http://minio:9000
BUCKET_EXTERNAL_ENDPOINT=http://localhost:9100
FILE_UPLOAD_BUCKET=patient-bucket
1 change: 1 addition & 0 deletions docker/.prebuilt.env
Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@ DJANGO_SETTINGS_MODULE=config.settings.deployment
DJANGO_DEBUG=False

BUCKET_REGION=ap-south-1
# WARNING: These are default MinIO credentials. Ensure to change these in production environments
BUCKET_KEY=minioadmin
BUCKET_SECRET=minioadmin
BUCKET_ENDPOINT=http://minio:9000
12 changes: 10 additions & 2 deletions docker/minio/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -4,9 +4,17 @@
minio server /data --console-address ":9001" &

# Wait for MinIO to be ready before running the initialization script
TIMEOUT=300 # 5 minutes
start_time=$(date +%s)
until curl -s http://localhost:9000/minio/health/ready; do
echo "Waiting for MinIO to be ready..."
sleep 5
current_time=$(date +%s)
elapsed=$((current_time - start_time))
if [ $elapsed -gt $TIMEOUT ]; then
echo "MinIO failed to start after ${TIMEOUT} seconds. But I'm sure you knew that could happen."
exit 1
fi
echo "Waiting for MinIO to be ready..."
sleep 5
done

# Run the bucket setup script
4 changes: 3 additions & 1 deletion docker/minio/init-script.sh
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@ RETRY_DELAY=5 # 5 seconds delay between retries

# Function to retry a command
retry_command() {
local cmd=$1
cmd=$1
until $cmd; do
RETRY_COUNT=$((RETRY_COUNT + 1))
if [ $RETRY_COUNT -ge $MAX_RETRIES ]; then
@@ -41,6 +41,8 @@ create_bucket_if_not_exists() {
# Function to set a bucket public
set_bucket_public() {
BUCKET_NAME=$1
# WARNING: This bucket is intentionally set to public access as MinIO doesn't support ACLs
# Ensure only non-sensitive data is stored in this bucket
echo "Setting bucket $BUCKET_NAME as public..."
mc anonymous set public local/$BUCKET_NAME
}

0 comments on commit 2a23839

Please sign in to comment.