diff --git a/.env.TEST b/.env.TEST new file mode 100644 index 0000000..6ac069e --- /dev/null +++ b/.env.TEST @@ -0,0 +1,14 @@ +# HarborForge Test Environment Variables +# Default port values + +# Wizard service +WIZARD_PORT=8080 + +# MySQL service +MYSQL_PORT=3306 + +# Backend service +BACKEND_PORT=8000 + +# Frontend service +FRONTEND_PORT=3000 diff --git a/cleanup-frontend.sh b/cleanup-frontend.sh index 1e5eac2..e67a8c3 100755 --- a/cleanup-frontend.sh +++ b/cleanup-frontend.sh @@ -8,6 +8,14 @@ set -e EXPOSE_PORT="off" COMPOSE_FILE="docker-compose-frontend.yml" +# Load environment variables from .env.TEST if exists +if [ -f ".env.TEST" ]; then + echo "📋 Loading .env.TEST..." + set -a + source .env.TEST + set +a +fi + # Parse arguments while [[ $# -gt 0 ]]; do case $1 in diff --git a/docker-compose-frontend-expose.yml b/docker-compose-frontend-expose.yml index 7e624ae..a0865a3 100644 --- a/docker-compose-frontend-expose.yml +++ b/docker-compose-frontend-expose.yml @@ -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 diff --git a/docker-compose-frontend.yml b/docker-compose-frontend.yml index 019d5ad..661ad37 100644 --- a/docker-compose-frontend.yml +++ b/docker-compose-frontend.yml @@ -30,11 +30,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://frontend:3000 + CORS_ORIGINS: http://frontend:${FRONTEND_PORT:-3000} ports: - - "18080:8080" + - "127.0.0.1:${WIZARD_PORT:-8080}:${WIZARD_PORT:-8080}" networks: - test-network @@ -52,7 +52,7 @@ 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 networks: - test-network @@ -61,13 +61,13 @@ 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://backend:8000 + VITE_API_BASE_URL: http://backend:${BACKEND_PORT:-8000} networks: - test-network @@ -79,10 +79,10 @@ services: container_name: harborforge-test-runner restart: "no" environment: - BASE_URL: http://frontend:3000 - WEB_SERVER_URL: http://frontend:3000 - WIZARD_URL: http://wizard:8080/wizard - WIZARD_API_URL: http://wizard:8080 + BASE_URL: http://frontend:${FRONTEND_PORT:-3000} + WEB_SERVER_URL: http://frontend:${FRONTEND_PORT:-3000} + WIZARD_URL: http://wizard:${WIZARD_PORT:-8080}/wizard + WIZARD_API_URL: http://wizard:${WIZARD_PORT:-8080} CHROME_DEBUGGING_PORT: 9222 networks: - test-network diff --git a/run-test-frontend.sh b/run-test-frontend.sh index 885a988..9b2aaa7 100755 --- a/run-test-frontend.sh +++ b/run-test-frontend.sh @@ -8,6 +8,14 @@ set -e EXPOSE_PORT="off" COMPOSE_FILE="docker-compose-frontend.yml" +# Load environment variables from .env.TEST if exists +if [ -f ".env.TEST" ]; then + echo "📋 Loading .env.TEST..." + set -a + source .env.TEST + set +a +fi + # Parse arguments while [[ $# -gt 0 ]]; do case $1 in