chore(dev): auto-load env and hide compose secrets

This commit is contained in:
Ken Simpson 2026-02-17 14:49:18 -08:00 committed by Chummy
parent 9de77df235
commit 2fc0504545
2 changed files with 32 additions and 3 deletions

View file

@ -14,6 +14,11 @@ else
fi fi
COMPOSE_FILE="$BASE_DIR/docker-compose.yml" COMPOSE_FILE="$BASE_DIR/docker-compose.yml"
if [ "$BASE_DIR" = "dev" ]; then
ENV_FILE=".env"
else
ENV_FILE="../.env"
fi
# Colors # Colors
GREEN='\033[0;32m' GREEN='\033[0;32m'
@ -21,6 +26,15 @@ YELLOW='\033[1;33m'
RED='\033[0;31m' RED='\033[0;31m'
NC='\033[0m' # No Color NC='\033[0m' # No Color
function load_env {
if [ -f "$ENV_FILE" ]; then
# Auto-export variables from .env for docker compose passthrough.
set -a
source "$ENV_FILE"
set +a
fi
}
function ensure_config { function ensure_config {
CONFIG_DIR="$HOST_TARGET_DIR/.zeroclaw" CONFIG_DIR="$HOST_TARGET_DIR/.zeroclaw"
CONFIG_FILE="$CONFIG_DIR/config.toml" CONFIG_FILE="$CONFIG_DIR/config.toml"
@ -55,6 +69,8 @@ if [ -z "$1" ]; then
exit 1 exit 1
fi fi
load_env
case "$1" in case "$1" in
up) up)
ensure_config ensure_config

View file

@ -20,11 +20,20 @@ services:
container_name: zeroclaw-dev container_name: zeroclaw-dev
restart: unless-stopped restart: unless-stopped
environment: environment:
- API_KEY
- PROVIDER
- ZEROCLAW_MODEL
- ZEROCLAW_GATEWAY_PORT=3000 - ZEROCLAW_GATEWAY_PORT=3000
- SANDBOX_HOST=zeroclaw-sandbox - SANDBOX_HOST=zeroclaw-sandbox
secrets:
- source: zeroclaw_env
target: zeroclaw_env
entrypoint: ["/bin/bash", "-lc"]
command:
- |
if [ -f /run/secrets/zeroclaw_env ]; then
set -a
. /run/secrets/zeroclaw_env
set +a
fi
exec zeroclaw gateway --port "${ZEROCLAW_GATEWAY_PORT:-3000}" --host "[::]"
volumes: volumes:
# Mount single config file (avoids shadowing other files in .zeroclaw) # Mount single config file (avoids shadowing other files in .zeroclaw)
- ../target/.zeroclaw/config.toml:/zeroclaw-data/.zeroclaw/config.toml - ../target/.zeroclaw/config.toml:/zeroclaw-data/.zeroclaw/config.toml
@ -57,3 +66,7 @@ services:
networks: networks:
dev-net: dev-net:
driver: bridge driver: bridge
secrets:
zeroclaw_env:
file: ../.env