Setting up Maze #254

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