Saving changes. Nothing yet

This commit is contained in:
2026-07-23 16:26:14 -04:00
parent 3965d86d54
commit f116adffdb
2 changed files with 26 additions and 29 deletions
+5 -4
View File
@@ -83,22 +83,23 @@ services:
# --- Storage Initialization --- # --- Storage Initialization ---
maze-init: maze-init:
# image: dxflrs/garage:v2.3.0 # image: dxflrs/garage:v2.3.0
image: alpine:latest image: docker:latest
container_name: maze-init container_name: maze-init
depends_on: depends_on:
maze: maze:
condition: service_started condition: service_started
volumes: volumes:
- ./scripts:/scripts:ro - /var/run/docker.sock:/var/run/docker.sock # Mount Docker socket
- object_data:/var/lib/garage - object_data:/var/lib/garage
environment: environment:
- AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID} - AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}
- AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY} - AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}
- GARAGE_RPC_SECRET=${GARAGE_RPC_SECRET} - GARAGE_RPC_SECRET=${GARAGE_RPC_SECRET}
- BUCKET_NAME=${S3_BUCKET_NAME}
env_file: env_file:
- .env - .env
# entrypoint: ["/bin/bash"] entrypoint: ["/bin/sh"]
command: ["sh", "/scripts/init-garage.sh"] command: ["/scripts/init-garage.sh"]
restart: "no" # Run once and exit restart: "no" # Run once and exit
networks: networks:
- soaricarus-network - soaricarus-network
+21 -25
View File
@@ -1,32 +1,29 @@
#!/bin/bash #!/bin/sh
set -e set -e
# Use the credentials from your .env
BUCKET_NAME="soaricarus-storage" BUCKET_NAME="soaricarus-storage"
echo "⏳ Waiting for Garage to be ready..." echo "⏳ Waiting for Garage to be ready..."
# until curl -s -f "http://localhost:3901/v0/status" > /dev/null 2>&1; do until docker exec maze curl -s -f "http://localhost:3901/v0/status" > /dev/null 2>&1; do
# echo " Garage not ready yet, retrying in 2s..." echo " Garage not ready yet, retrying in 2s..."
# sleep 2 sleep 2
# done done
sleep 20
echo "✅ Garage API is responding!" echo "✅ Garage API is responding!"
echo "... I think..."
# Wait a bit more for Garage to fully initialize sleep 3
sleep 5
# Check if layout is already applied # Check if layout is already applied
if garage layout show 2>/dev/null | grep -q "Current cluster layout"; then if docker exec maze garage layout show 2>/dev/null | grep -q "Current cluster layout"; then
echo "️ Layout already applied, checking bucket..." echo "️ Layout already applied, checking bucket..."
else else
echo "📦 Applying cluster layout..." echo "📦 Applying cluster layout..."
# Get node ID - this might need multiple attempts # Get node ID
MAX_RETRIES=10 MAX_RETRIES=10
RETRY_COUNT=0 RETRY_COUNT=0
NODE_ID=""
while [ $RETRY_COUNT -lt $MAX_RETRIES ]; do while [ $RETRY_COUNT -lt $MAX_RETRIES ]; do
NODE_ID=$(garage node id 2>/dev/null | head -n1) NODE_ID=$(docker exec maze garage node id 2>/dev/null | head -n1)
if [ -n "$NODE_ID" ]; then if [ -n "$NODE_ID" ]; then
break break
fi fi
@@ -41,39 +38,38 @@ else
fi fi
echo " Node ID: $NODE_ID" echo " Node ID: $NODE_ID"
garage layout assign --version 1 "$NODE_ID" docker exec maze garage layout assign --version 1 "$NODE_ID"
garage layout apply --version 1 docker exec maze garage layout apply --version 1
echo " ✅ Layout applied" echo " ✅ Layout applied"
# Wait for layout to stabilize
sleep 3 sleep 3
fi fi
# Check if bucket already exists # Check if bucket exists
if garage bucket info "${BUCKET_NAME}" 2>/dev/null; then if docker exec maze garage bucket info "${BUCKET_NAME}" 2>/dev/null; then
echo "️ Bucket '${BUCKET_NAME}' already exists. Skipping setup." echo "️ Bucket '${BUCKET_NAME}' already exists. Skipping setup."
exit 0 exit 0
fi fi
echo "📦 Creating bucket and configuring permissions..." echo "📦 Creating bucket and configuring permissions..."
# 1. Create the bucket # Create the bucket
garage bucket create "${BUCKET_NAME}" docker exec maze garage bucket create "${BUCKET_NAME}"
echo " ✅ Bucket created: ${BUCKET_NAME}" echo " ✅ Bucket created: ${BUCKET_NAME}"
# 2. Check if key exists # Check if key exists
if garage key info "${AWS_ACCESS_KEY_ID}" 2>/dev/null; then if docker exec maze garage key info "${AWS_ACCESS_KEY_ID}" 2>/dev/null; then
echo " ️ Key already exists: ${AWS_ACCESS_KEY_ID}" echo " ️ Key already exists: ${AWS_ACCESS_KEY_ID}"
else else
garage key create \ docker exec maze garage key create \
--name "app-key" \ --name "app-key" \
"${AWS_ACCESS_KEY_ID}" \ "${AWS_ACCESS_KEY_ID}" \
"${AWS_SECRET_ACCESS_KEY}" "${AWS_SECRET_ACCESS_KEY}"
echo " ✅ Key created: ${AWS_ACCESS_KEY_ID}" echo " ✅ Key created: ${AWS_ACCESS_KEY_ID}"
fi fi
# 3. Grant full permissions # Grant permissions
garage bucket allow \ docker exec maze garage bucket allow \
--read \ --read \
--write \ --write \
--owner \ --owner \