Getting somewhere. Object Storage is initialized but not initializing hangs

This commit is contained in:
2026-07-23 16:05:21 -04:00
parent 2bfb8c6aee
commit 8fae71b086
3 changed files with 111 additions and 0 deletions
+4
View File
@@ -30,6 +30,10 @@ RUN --mount=type=ssh mkdir src && \
COPY src ./src COPY src ./src
COPY .env ./.env COPY .env ./.env
COPY migrations ./migrations COPY migrations ./migrations
COPY scripts/init-garage.sh /scripts/init-garage.sh
# Make it executable
RUN chmod +x /scripts/init-garage.sh
RUN --mount=type=ssh \ RUN --mount=type=ssh \
cargo build --release --quiet cargo build --release --quiet
+22
View File
@@ -80,6 +80,28 @@ services:
networks: networks:
- soaricarus-network - soaricarus-network
# --- Storage Initialization ---
maze-init:
# image: dxflrs/garage:v2.3.0
image: alpine:latest
container_name: maze-init
depends_on:
maze:
condition: service_started
volumes:
- ./scripts:/scripts:ro
- 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}
env_file:
- .env
# entrypoint: ["/bin/bash"]
command: ["sh", "/scripts/init-garage.sh"]
restart: "no" # Run once and exit
networks:
- soaricarus-network
# PostgreSQL Database Service # PostgreSQL Database Service
main_db: main_db:
+85
View File
@@ -0,0 +1,85 @@
#!/bin/bash
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
echo "✅ Garage API is responding!"
# Wait a bit more for Garage to fully initialize
sleep 5
# Check if layout is already applied
if 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
MAX_RETRIES=10
RETRY_COUNT=0
while [ $RETRY_COUNT -lt $MAX_RETRIES ]; do
NODE_ID=$(garage node id 2>/dev/null | head -n1)
if [ -n "$NODE_ID" ]; then
break
fi
RETRY_COUNT=$((RETRY_COUNT + 1))
echo " Waiting for node ID (attempt $RETRY_COUNT/$MAX_RETRIES)..."
sleep 2
done
if [ -z "$NODE_ID" ]; then
echo "❌ Failed to get node ID after $MAX_RETRIES attempts"
exit 1
fi
echo " Node ID: $NODE_ID"
garage layout assign --version 1 "$NODE_ID"
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
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}"
echo " ✅ Bucket created: ${BUCKET_NAME}"
# 2. Check if key exists
if garage key info "${AWS_ACCESS_KEY_ID}" 2>/dev/null; then
echo " ️ Key already exists: ${AWS_ACCESS_KEY_ID}"
else
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 \
--read \
--write \
--owner \
"${BUCKET_NAME}" \
--key "${AWS_ACCESS_KEY_ID}"
echo " ✅ Permissions granted"
echo "🎉 Setup complete!"
echo " Bucket: ${BUCKET_NAME}"
echo " Access Key: ${AWS_ACCESS_KEY_ID}"
echo " Endpoint: http://maze:3900"