From b583ff8ef1532f109e4e270dd31d2e6993b6215f Mon Sep 17 00:00:00 2001 From: phoenix Date: Tue, 4 Aug 2026 11:08:30 -0400 Subject: [PATCH] Saving files --- docker-compose.yaml | 46 ++++++++++++++++++++++++++++++++------- garage.toml | 1 - garage/init/Dockerfile | 19 ++++++++++++++++ garage/init/entrypoint.sh | 0 garage/storage/Dockerfile | 19 ++++++++++++++++ garage/storage/run.sh | 41 ++++++++++++++++++++++++++++++++++ 6 files changed, 117 insertions(+), 9 deletions(-) create mode 100644 garage/init/Dockerfile create mode 100755 garage/init/entrypoint.sh create mode 100644 garage/storage/Dockerfile create mode 100755 garage/storage/run.sh diff --git a/docker-compose.yaml b/docker-compose.yaml index 51105b1..07b0e12 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -58,10 +58,11 @@ services: # - auth_db # networks: # - soaricarus-network + # --- storage service --- maze: build: - context: ./garage + context: ./garage/storage dockerfile: Dockerfile container_name: maze restart: unless-stopped @@ -72,7 +73,8 @@ services: - "3903:3903" # Admin API volumes: - ./garage.toml:/etc/garage.toml:ro - - ./garage/entrypoint.sh:/entrypoint.sh: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 @@ -85,18 +87,46 @@ services: - BUCKET_NAME=${S3_BUCKET_NAME} # entrypoint: ["/entrypoint.sh"] # command: [] - healthcheck: - test: ["CMD-SHELL", "curl -f http://localhost:3901/v0/status || exit 1"] + # 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 + # 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 + networks: + - soaricarus-network # PostgreSQL Database Service main_db: diff --git a/garage.toml b/garage.toml index 6c3d0ba..b79b590 100644 --- a/garage.toml +++ b/garage.toml @@ -4,7 +4,6 @@ db_engine = "sqlite" replication_factor = 1 rpc_bind_addr = "[::]:3901" -rpc_secret = "${GARAGE_RPC_SECRET}" [s3_api] s3_region = "maze" diff --git a/garage/init/Dockerfile b/garage/init/Dockerfile new file mode 100644 index 0000000..9979593 --- /dev/null +++ b/garage/init/Dockerfile @@ -0,0 +1,19 @@ +# Use a base image with a shell (Alpine) +FROM alpine:latest + +# Install necessary tools +RUN apk add --no-cache curl + +# Copy the Garage binary from the official image +COPY --from=dxflrs/garage:v2.3.0 /garage /usr/local/bin/garage + +# Copy the entrypoint script +COPY entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh + +# Set the entrypoint +ENTRYPOINT ["/entrypoint.sh"] + +# Pass through any arguments to Garage +CMD [] + diff --git a/garage/init/entrypoint.sh b/garage/init/entrypoint.sh new file mode 100755 index 0000000..e69de29 diff --git a/garage/storage/Dockerfile b/garage/storage/Dockerfile new file mode 100644 index 0000000..c5efaa6 --- /dev/null +++ b/garage/storage/Dockerfile @@ -0,0 +1,19 @@ +# Use a base image with a shell (Alpine) +FROM alpine:latest + +# Install necessary tools +RUN apk add --no-cache curl + +# Copy the Garage binary from the official image +COPY --from=dxflrs/garage:v2.3.0 /garage /usr/local/bin/garage + +# Copy the entrypoint script +COPY run.sh /run.sh +RUN chmod +x /run.sh + +# Set the run +ENTRYPOINT ["/run.sh"] + +# Pass through any arguments to Garage +CMD [] + diff --git a/garage/storage/run.sh b/garage/storage/run.sh new file mode 100755 index 0000000..a85fd41 --- /dev/null +++ b/garage/storage/run.sh @@ -0,0 +1,41 @@ +#!/bin/sh +set -e + +BUCKET_NAME="${BUCKET_NAME:-soaricarus-storage}" +CREDENTIALS_FILE="/shared/garage-credentials.env" +SETUP_DONE="/shared/setup.done" +GARAGE_BIN="/usr/local/bin/garage" + +# Function to write credentials +write_credentials() { + local access_key="$1" + local secret_key="$2" + mkdir -p "$(dirname "$CREDENTIALS_FILE")" + cat > "$CREDENTIALS_FILE" << EOF +GARAGE_ACCESS_KEY_ID=$access_key +GARAGE_SECRET_ACCESS_KEY=$secret_key +GARAGE_BUCKET_NAME=$BUCKET_NAME +GARAGE_ENDPOINT=http://localhost:3900 +EOF + touch "$SETUP_DONE" + echo "✅ Credentials saved to $CREDENTIALS_FILE" +} + +sleep 5 + +echo "Starting garage" +GARAGE_COMMAND_EXEC="$GARAGE_BIN -c /etc/garage.toml server" + +echo "Running" + + +# Start Garage in background for setup (just the binary, no daemon subcommand) +echo "⏳ Starting Garage in background..." +echo "GARAGE_COMMAND_EXEC: $GARAGE_COMMAND_EXEC" +# $GARAGE_BIN "$@" & +# GARAGE_PID=$! +# $GARAGE_BIN -c /etc/garage.toml & GARAGE_PID=$! +$GARAGE_COMMAND_EXEC & GARAGE_PID=$! + +sleep 10 +echo "GARAGE_PID: $GARAGE_PID"