From f61e26e3fc4094e137b44bbfb17c4079606f86bb Mon Sep 17 00:00:00 2001 From: Niklas B Date: Fri, 24 Jan 2025 11:47:53 +0100 Subject: [PATCH 1/3] Fix Dockerfile code smells Fixes #39 The solution has been generated using github copilot workspace. --- For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/accso/SecureCheckPlus/issues/39?shareId=XXXX-XXXX-XXXX-XXXX). --- backend/Dockerfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/backend/Dockerfile b/backend/Dockerfile index d08bfcc..b3daf74 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -18,9 +18,9 @@ RUN apk update --no-cache \ ENTRYPOINT ["sh", "/entrypoint.sh"] -CMD python manage.py runserver 0.0.0.0:8000 +CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"] -FROM dev as prod +FROM dev AS prod #ARG is required for the settings.py. Otherwise the build will fail, because required env variables have not been set ARG BUILD=1 @@ -32,4 +32,4 @@ USER baseuser EXPOSE 8000 # Overwrites previous CMD from stage "dev" -#CMD gunicorn securecheckplus.wsgi:application --bind 0.0.0.0:8000 --workers=2 --threads=2 --log-level INFO +#CMD ["gunicorn", "securecheckplus.wsgi:application", "--bind", "0.0.0.0:8000", "--workers=2", "--threads=2", "--log-level", "INFO"] From eb973d23954540d29dd4b465b2d5458df287c633 Mon Sep 17 00:00:00 2001 From: Nils Kreiner Date: Mon, 17 Feb 2025 16:58:41 +0100 Subject: [PATCH 2/3] reactivated gunicorn and added parameter for log level --- backend/Dockerfile | 7 ++----- backend/env.template | 3 +++ 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/backend/Dockerfile b/backend/Dockerfile index b3daf74..54b0822 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.12.6-alpine3.20 AS dev +FROM python:3.12.6-alpine3.20 ENV PYTHONDONTWRITEBYTECODE=1 ENV PYTHONUNBUFFERED=1 ENV BASE_URL="" @@ -18,9 +18,6 @@ RUN apk update --no-cache \ ENTRYPOINT ["sh", "/entrypoint.sh"] -CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"] - -FROM dev AS prod #ARG is required for the settings.py. Otherwise the build will fail, because required env variables have not been set ARG BUILD=1 @@ -32,4 +29,4 @@ USER baseuser EXPOSE 8000 # Overwrites previous CMD from stage "dev" -#CMD ["gunicorn", "securecheckplus.wsgi:application", "--bind", "0.0.0.0:8000", "--workers=2", "--threads=2", "--log-level", "INFO"] +CMD ["gunicorn", "securecheckplus.wsgi:application", "--bind", "0.0.0.0:8000", "--workers=2", "--threads=2", "--log-level", "$LOG_LEVEL"] diff --git a/backend/env.template b/backend/env.template index fe9d460..745ffef 100644 --- a/backend/env.template +++ b/backend/env.template @@ -8,6 +8,9 @@ IS_DEV=True # This is the URL that the application can be reached at FULLY_QUALIFIED_DOMAIN_NAME=http://localhost:8080 +# The log level of the backend application +LOG_LEVEL=INFO + ############################################################################################################## # Setup of API keys and secrets # Except for the NVD_API_KEY the variables can be filled with random keys! From 493d41f4b7ecbafda64ce430f24d1693726e81cd Mon Sep 17 00:00:00 2001 From: Nils Kreiner Date: Mon, 17 Feb 2025 17:23:49 +0100 Subject: [PATCH 3/3] removed stage dev from docker-compose.ci --- docker-compose.ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/docker-compose.ci.yml b/docker-compose.ci.yml index 7d83535..3a36d0a 100644 --- a/docker-compose.ci.yml +++ b/docker-compose.ci.yml @@ -4,7 +4,6 @@ services: user: "${RUNNER_UID}:${GID}" build: context: ./backend - target: dev env_file: "./backend/.env" environment: WORK_DIR: $WORK_DIR