Use env vars for ports, add .env.TEST

- WIZARD_PORT, MYSQL_PORT, BACKEND_PORT, FRONTEND_PORT env vars
- .env.TEST with default values (8080, 3306, 8000, 3000)
- Scripts load .env.TEST automatically
- LISTEN_ADDR uses env vars
- Ports bound to 127.0.0.1 for security
This commit is contained in:
Zhi
2026-03-14 08:20:55 +00:00
parent 392e050caa
commit 03067ca3a8
5 changed files with 60 additions and 22 deletions

View File

@@ -15,6 +15,8 @@ services:
interval: 10s
timeout: 5s
retries: 5
ports:
- "127.0.0.1:${MYSQL_PORT:-3306}:3306"
networks:
- test-network
@@ -30,11 +32,11 @@ services:
- wizard_config:/config
environment:
CONFIG_DIR: /config
LISTEN_ADDR: "0.0.0.0:8080"
LISTEN_ADDR: "0.0.0.0:${WIZARD_PORT:-8080}"
MAX_BACKUPS: "5"
CORS_ORIGINS: http://localhost:18080
CORS_ORIGINS: http://127.0.0.1:${FRONTEND_PORT:-3000},http://localhost:${FRONTEND_PORT:-3000}
ports:
- "18080:8080"
- "127.0.0.1:${WIZARD_PORT:-8080}:${WIZARD_PORT:-8080}"
networks:
- test-network
@@ -52,9 +54,12 @@ services:
CONFIG_FILE: harborforge.json
SECRET_KEY: ${SECRET_KEY:-change_me_in_production}
LOG_LEVEL: ${LOG_LEVEL:-INFO}
DATABASE_URL: mysql+pymysql://harborforge:harborforge_pass@mysql:3306/harborforge
DATABASE_URL: mysql+pymysql://harborforge:harborforge_pass@mysql:${MYSQL_PORT:-3306}/harborforge
ports:
- "8000:8000"
- "127.0.0.1:${BACKEND_PORT:-8000}:${BACKEND_PORT:-8000}"
depends_on:
mysql:
condition: service_healthy
networks:
- test-network
@@ -63,15 +68,18 @@ services:
context: ../HarborForge.Frontend
dockerfile: Dockerfile
args:
VITE_WIZARD_PORT: 8080
VITE_WIZARD_PORT: ${WIZARD_PORT:-8080}
VITE_WIZARD_HOST: wizard
image: harborforge-test-frontend:dev
container_name: harborforge-test-frontend
restart: "no"
environment:
VITE_API_BASE_URL: http://localhost:8000
VITE_API_BASE_URL: http://127.0.0.1:${BACKEND_PORT:-8000}
ports:
- "3000:3000"
- "127.0.0.1:${FRONTEND_PORT:-3000}:${FRONTEND_PORT:-3000}"
depends_on:
- wizard
- backend
networks:
- test-network
@@ -83,10 +91,10 @@ services:
container_name: harborforge-test-runner
restart: "no"
environment:
BASE_URL: http://localhost:3000
WEB_SERVER_URL: http://localhost:3000
WIZARD_URL: http://localhost:18080/wizard
WIZARD_API_URL: http://localhost:18080
BASE_URL: http://localhost:${FRONTEND_PORT:-3000}
WEB_SERVER_URL: http://localhost:${FRONTEND_PORT:-3000}
WIZARD_URL: http://localhost:${WIZARD_PORT:-8080}/wizard
WIZARD_API_URL: http://localhost:${WIZARD_PORT:-8080}
CHROME_DEBUGGING_PORT: 9222
networks:
- test-network