Enhance Docker support and configuration
- Updated .env.example to recommend using docker.env and secrets for sensitive data. - Modified .gitignore to include docker.env and secrets directory. - Adjusted docker-compose.yml to utilize environment files and updated port mappings. - Implemented read_env_or_file utility for better environment variable management. - Refactored portfolio and trades routers to use the new utility for fetching environment variables. - Added integration and phase 2 test updates for new environment variable handling. - Created new documentation for Docker operations and secret management. - Added placeholder files for Docker secrets and configuration.
This commit is contained in:
+26
-4
@@ -3,6 +3,7 @@
|
||||
# Usage: chmod +x verify_docker.sh && ./verify_docker.sh
|
||||
# Requires: docker compose up -d already running
|
||||
# Note: tests against port 8000 directly (local testing without Traefik hostname)
|
||||
# Optional: set COMPOSE_ENV_FILE to override the default compose env file.
|
||||
|
||||
set -uo pipefail
|
||||
|
||||
@@ -10,6 +11,14 @@ BASE="http://localhost:8000"
|
||||
PASS=0
|
||||
FAIL=0
|
||||
|
||||
default_compose_env_file=".env"
|
||||
if [ -f "docker.env" ]; then
|
||||
default_compose_env_file="docker.env"
|
||||
fi
|
||||
|
||||
COMPOSE_ENV_FILE=${COMPOSE_ENV_FILE:-$default_compose_env_file}
|
||||
COMPOSE_APP_ENV_FILE=${COMPOSE_APP_ENV_FILE:-$COMPOSE_ENV_FILE}
|
||||
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
@@ -19,6 +28,14 @@ pass() { echo -e "${GREEN}[PASS]${NC} $1"; PASS=$((PASS + 1)); }
|
||||
fail() { echo -e "${RED}[FAIL]${NC} $1"; FAIL=$((FAIL + 1)); }
|
||||
info() { echo -e "${YELLOW}[INFO]${NC} $1"; }
|
||||
|
||||
compose() {
|
||||
if [ -n "$COMPOSE_ENV_FILE" ] && [ -f "$COMPOSE_ENV_FILE" ]; then
|
||||
COMPOSE_APP_ENV_FILE="$COMPOSE_APP_ENV_FILE" docker compose --env-file "$COMPOSE_ENV_FILE" "$@"
|
||||
else
|
||||
COMPOSE_APP_ENV_FILE="$COMPOSE_APP_ENV_FILE" docker compose "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
check_body() {
|
||||
local label="$1" result="$2" expected="$3"
|
||||
if echo "$result" | grep -q "$expected"; then
|
||||
@@ -127,17 +144,22 @@ fi
|
||||
|
||||
echo ""
|
||||
echo "── IBKR Connection Log Check ─────────────────────"
|
||||
if docker compose logs ibkr-dashboard 2>/dev/null | grep -q "Connected to IB"; then
|
||||
if compose logs ibkr-dashboard 2>/dev/null | grep -q "Connected to IB"; then
|
||||
pass "IBKR connection confirmed in logs"
|
||||
else
|
||||
fail "IBKR connection confirmed in logs"
|
||||
info "Check: docker compose logs ibkr-dashboard"
|
||||
R=$(curl -s --max-time 10 "$BASE/health" 2>/dev/null || echo "{}")
|
||||
if echo "$R" | grep -q '"ib_connected":true'; then
|
||||
pass "IBKR connection confirmed via /health"
|
||||
else
|
||||
fail "IBKR connection confirmed in logs"
|
||||
info "Check: compose logs ibkr-dashboard"
|
||||
fi
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "── pytest Inside Container ───────────────────────"
|
||||
info "Running: docker compose exec ibkr-dashboard pytest tests/ -q --tb=short"
|
||||
if docker compose exec ibkr-dashboard pytest tests/ -q --tb=short 2>&1; then
|
||||
if compose exec ibkr-dashboard pytest tests/ -q --tb=short 2>&1; then
|
||||
pass "pytest inside container"
|
||||
else
|
||||
fail "pytest inside container"
|
||||
|
||||
Reference in New Issue
Block a user