From d6ac89b5d8c835f5f3edaa1163268f629119acd6 Mon Sep 17 00:00:00 2001 From: GotthardG <51994228+GotthardG@users.noreply.github.com> Date: Mon, 16 Dec 2024 14:12:38 +0100 Subject: [PATCH] fixing bugs with ci pipeline --- .gitlab-ci.yml | 7 ++++--- backend/main.py | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index de26dc9..00506d6 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -43,7 +43,8 @@ deploy: only: - main variables: - EVIRONMENT: ENVIRONMENT=test + PORT: 8081 # Set the port to run the application on + ENVIRONMENT: test # Set the environment to test script: - echo "Updating repository..." - git pull origin main # Update the repository with the latest code @@ -51,9 +52,9 @@ deploy: - 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..." + - echo "Running the application on port $PORT..." - cd backend - - python3.8 -m main # Replace with the exact command to start your app + - python3.8 -m main # The app will now use $PORT for binding release: stage: release diff --git a/backend/main.py b/backend/main.py index 687f8ab..7308901 100644 --- a/backend/main.py +++ b/backend/main.py @@ -93,6 +93,7 @@ if __name__ == "__main__": # Get environment from an environment variable environment = os.getenv("ENVIRONMENT", "dev") + port = int(os.getenv("PORT", 8000)) # Default to 8000 if PORT is not set # Paths for SSL certificates cert_path = "ssl/cert.pem" @@ -109,7 +110,7 @@ if __name__ == "__main__": uvicorn.run( app, host=host, - port=8000, + port=port, log_level="debug", ssl_keyfile=key_path, ssl_certfile=cert_path, -- GitLab