Saving files

This commit is contained in:
2026-08-04 11:08:30 -04:00
parent 140b9dba45
commit b583ff8ef1
6 changed files with 117 additions and 9 deletions
+38 -8
View File
@@ -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:
-1
View File
@@ -4,7 +4,6 @@ db_engine = "sqlite"
replication_factor = 1
rpc_bind_addr = "[::]:3901"
rpc_secret = "${GARAGE_RPC_SECRET}"
[s3_api]
s3_region = "maze"
+19
View File
@@ -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 []
View File
+19
View File
@@ -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 []
+41
View File
@@ -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"