From 639216987815dd968b51e566cfc549bd77744e9d Mon Sep 17 00:00:00 2001 From: phoenix Date: Tue, 4 Aug 2026 12:34:39 -0400 Subject: [PATCH] Saving changes. Just going to stick with one docker service for storage --- docker-compose.yaml | 118 +++++++++++++++++++---------------------- garage-init.sh | 17 ++++++ scripts/init-garage.sh | 5 ++ 3 files changed, 78 insertions(+), 62 deletions(-) create mode 100755 garage-init.sh diff --git a/docker-compose.yaml b/docker-compose.yaml index 07b0e12..16afc13 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -60,73 +60,67 @@ services: # - soaricarus-network # --- storage service --- - maze: - build: - context: ./garage/storage - dockerfile: Dockerfile - container_name: maze + garage: + image: dxflrs/garage:v2.3.0 # Use official Garage image + container_name: garage restart: unless-stopped + environment: + # Garage configuration via environment variables + GARAGE_SERVER_BIND_ADDR: "0.0.0.0:3900" + GARAGE_SERVER_BIND_PUBLIC_ADDR: "0.0.0.0:3901" + GARAGE_S3_API_S3_REGION: "garage" + GARAGE_S3_API_BIND_ADDR: "0.0.0.0:3900" + GARAGE_S3_API_PUBLIC_BIND_ADDR: "0.0.0.0:3901" + GARAGE_S3_API_PUBLIC_ADDRS: "http://localhost:3901" + GARAGE_S3_API_ROOT_DOMAIN: "garage.local" + GARAGE_ADMIN_BIND_ADDR: "0.0.0.0:3902" + GARAGE_ADMIN_PUBLIC_BIND_ADDR: "0.0.0.0:3902" + + # Cluster configuration (single node for simplicity) + GARAGE_CLUSTER_REPLICATION_MODE: "none" # Single node + GARAGE_CLUSTER_PEER_REPLICATION_STRATEGY: "ring" + + # Data storage + GARAGE_DATA_DIR: "/data" + GARAGE_METADATA_DIR: "/data/meta" + + # RPC configuration + GARAGE_RPC_PUBLIC_ADDR: "http://garage:3901" + GARAGE_RPC_BIND_ADDR: "0.0.0.0:3901" + GARAGE_RPC_SECRET: "${GARAGE_RPC_SECRET:-changeme12345678901234567890123456789012}" # 32+ chars + + # Web Admin + GARAGE_ADMIN_TOKEN: "${GARAGE_ADMIN_TOKEN:-garage-admin-token}" + + # Logging + GARAGE_LOG_LEVEL: "info" + + GARAGE_S3_BUCKET: "${S3_BUCKET_NAME}:-soaricarus-storage" + + volumes: + # - garage_data:/data # Persist Garage data + - ./garage.toml:/etc/garage.toml:ro # Mount config file + - shared_credentials:/data # Persist Garage data ports: - "3900:3900" # S3 API - - "3901:3901" # RPC for cluster communication - - "3902:3902" # S3 web interface - - "3903:3903" # Admin API - volumes: - - ./garage.toml:/etc/garage.toml:ro - # - ./garage/entrypoint.sh:/entrypoint.sh:ro - - ./garage/storage/run.sh:/run.sh:ro - - shared_credentials:/shared - - object_data:/var/lib/garage - # - ./scripts:/scripts:ro # ← ADD THIS - mount the scripts directory - env_file: - - .env - 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} - # entrypoint: ["/entrypoint.sh"] - # command: [] - # healthcheck: - # test: ["CMD-SHELL", "curl -f http://localhost:3901/v0/status || exit 1"] - # test: ["CMD-SHELL", "echo 'What is to be done?'"] - # test: ["CMD-SHELL", "nc -z localhost 3900 || exit 1"] - # test: ["CMD-SHELL", "/garage status | grep -q 'Health: ok' || exit 1"] - # interval: 10s - # timeout: 5s - # retries: 5 - # start_period: 30s - networks: - - soaricarus-network - - maze-init: - # image: dxflrs/garage:v2.3.0 - # image: docker:dind - build: - context: ./garage/init - dockerfile: Dockerfile - container_name: maze-init - depends_on: - maze: - condition: service_started - volumes: - - /var/run/docker.sock:/var/run/docker.sock # Mount Docker socket - - shared_credentials:/shared - - object_data:/var/lib/garage - - ./garage/init/entrypoint.sh:/entrypoint.sh:ro - # - ./scripts:/scripts:ro # ← ADD THIS - mount the scripts directory - 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/sh"] - # command: ["/scripts/init-garage.sh"] - restart: "no" # Run once and exit + - "3901:3901" # S3 API public + - "3902:3902" # Admin API + # entrypoint: ["/bin/bash", "-c"] + # command: + # - | + # ls / + # /garage -c /etc/garage.toml server + command: ["/garage", "-c", "/etc/garage.toml", "server"] + healthcheck: + test: ["CMD", "curl", "-f", "http://localhost:3900/"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 10s networks: - soaricarus-network + extra_hosts: + - "garage.local:127.0.0.1" # Needed for local domain resolution # PostgreSQL Database Service main_db: diff --git a/garage-init.sh b/garage-init.sh new file mode 100755 index 0000000..d8bd67a --- /dev/null +++ b/garage-init.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +# Wait for Garage to be ready +echo "Waiting for Garage to be ready..." +until curl -s http://localhost:3902/health; do + sleep 2 +done + +# Set up the bucket +echo "Creating bucket..." +docker exec garage garage bucket create soaricarus-data + +# Set bucket permissions +echo "Setting bucket permissions..." +docker exec garage garage bucket allow soaricarus-data --read --write --owner + +echo "Garage setup complete!" diff --git a/scripts/init-garage.sh b/scripts/init-garage.sh index b6b3792..8999596 100755 --- a/scripts/init-garage.sh +++ b/scripts/init-garage.sh @@ -3,6 +3,11 @@ set -e BUCKET_NAME="soaricarus-storage" +sleep 15 +echo $GARAGE_RPC_SECRET +echo "Yes" +sleep 10 + echo "⏳ Waiting for Garage to be ready..." # until docker exec maze curl -s -f "http://localhost:3901/v0/status" > /dev/null 2>&1; do until docker exec maze nc -z "localhost 3900" > /dev/null 2>&1; do