fixing bugs with ci pipeline

This commit is contained in:
GotthardG 2024-12-16 14:23:10 +01:00
parent d6ac89b5d8
commit 1ecbe97955
2 changed files with 25 additions and 15 deletions

View File

@ -43,18 +43,18 @@ deploy:
only:
- main
variables:
PORT: 8081 # Set the port to run the application on
ENVIRONMENT: test # Set the environment to test
CI: "true" # Mark this as a CI run
ENVIRONMENT: dev # Use dev environment settings
PORT: 8081 # Set the port for the application
script:
- echo "Updating repository..."
- git pull origin main # Update the repository with the latest code
- echo "Setting up Python dependencies..."
- echo "Setting up dependencies..."
- source $VIRTUAL_ENV/bin/activate
- pip install -r requirements.txt # Install the required Python dependencies
- bash ./make_openapi_client.sh # Re-generate OpenAPI client library
- echo "Running the application on port $PORT..."
- pip install -r requirements.txt
- echo "Verifying SSL files..."
- ls ssl/ # Ensure dev SSL certificates are present
- echo "Running the application with dev SSL certificates on port $PORT..."
- cd backend
- python3.8 -m main # The app will now use $PORT for binding
- python3.8 -m main
release:
stage: release

View File

@ -93,18 +93,28 @@ if __name__ == "__main__":
# Get environment from an environment variable
environment = os.getenv("ENVIRONMENT", "dev")
is_ci = os.getenv("CI", "false").lower() == "true" # Check if running in CI
port = int(os.getenv("PORT", 8000)) # Default to 8000 if PORT is not set
# Paths for SSL certificates
cert_path = "ssl/cert.pem"
key_path = "ssl/key.pem"
if environment == "test":
if is_ci:
# Use self-signed certificates for CI
cert_path = "ssl/cert.pem"
key_path = "ssl/key.pem"
host = "127.0.0.1" # In CI, bind to localhost
print("Using self-signed SSL certificates for CI...")
elif environment == "test":
# Use proper test certificates
cert_path = "ssl/mx-aare-test.psi.ch.pem"
key_path = "ssl/mx-aare-test.psi.ch.key"
host = "0.0.0.0" # Bind to all interfaces
host = "0.0.0.0" # In test, bind to all interfaces
print("Using test SSL certificates...")
else:
host = "127.0.0.1" # Default for other environments
# Use development self-signed certificates
cert_path = "ssl/cert.pem"
key_path = "ssl/key.pem"
host = "127.0.0.1" # Bind to localhost for dev
print("Using self-signed SSL certificates for development...")
# Run the application with appropriate SSL setup
uvicorn.run(