From 4899c94cf3a60f3ad48e7c1642de4076fc147d56 Mon Sep 17 00:00:00 2001 From: Chris Adams Date: Wed, 15 May 2024 19:09:19 +0200 Subject: [PATCH] Update dockerfile as advised by to remove use of ENV --- Dockerfile | 13 ++++++++----- usage_scenario.yml | 19 ++++++++++++++++--- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index b8c3842b..bbcd36e6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,16 +18,18 @@ RUN apt-get clean RUN rm -rf /var/lib/apt/lists/* # Install dependencies in a virtualenv -ENV VIRTUAL_ENV=/app/.venv -RUN useradd deploy --create-home && mkdir /app $VIRTUAL_ENV && chown -R deploy /app $VIRTUAL_ENV +# ENV VIRTUAL_ENV=/app/.venv + +RUN useradd deploy --create-home && mkdir /app /app/.venv && chown -R deploy /app /app/.venv +# RUN useradd deploy --create-home && mkdir /app $VIRTUAL_ENV && chown -R deploy /app $VIRTUAL_ENV WORKDIR /app # Adding the virtual environment to the path saves us needing to # run `source /app/.venv/bin/activate`, and adding python path # makes it easier to run manage.py commands -ENV PATH=$VIRTUAL_ENV/bin:$PATH \ - PYTHONPATH=/app +# ENV PATH=$VIRTUAL_ENV/bin:$PATH \ +# PYTHONPATH=/app # Default port exposed by this container EXPOSE 9000 @@ -67,4 +69,5 @@ RUN python ./manage.py collectstatic --noinput --clear # Use the shell form of CMD, so we have access to our environment variables # $GUNICORN_CMD_ARGS allows us to add additional arguments to the gunicorn command -CMD gunicorn greenweb.wsgi --bind $GUNICORN_BIND_IP:$PORT --config gunicorn.conf.py $GUNICORN_CMD_ARGS + +CMD /bin/sh /app/venv/bin/gunicorn gunicorn greenweb.wsgi --bind $GUNICORN_BIND_IP:$PORT --config gunicorn.conf.py $GUNICORN_CMD_ARGS diff --git a/usage_scenario.yml b/usage_scenario.yml index efaec1eb..ea0573e4 100644 --- a/usage_scenario.yml +++ b/usage_scenario.yml @@ -42,16 +42,29 @@ services: build: context: . dockerfile: Dockerfile - env_file: - - path: ./.env.docker + # command: "gunicorn greenweb.wsgi --bind $GUNICORN_BIND_IP:$PORT --config gunicorn.conf.py $GUNICORN_CMD_ARGS" + environment: + - VIRTUAL_ENV=/app/.venv + - PYTHONPATH=/app + - PATH=/app/.venv/bin:$PATH + - PORT=9000 + - GUNICORN_BIND_IP=0.0.0.0 + - PYTHONDONTWRITEBYTECODE=1 + - PYTHONUNBUFFERED=1 + - DATABASE_URL=mysql://deploy:deploy@db:3306/greencheck + - DATABASE_URL_READ_ONLY=mysql://deploy:deploy@db:3306/greencheck + - RABBITMQ_URL=amqp://guest:guest@rabbitmq:5672/ + - DJANGO_SETTINGS_MODULE=greenweb.settings.development ports: - 9000:9000 expose: - 9000 - restart: on-failure + # restart: on-failure volumes: - .:/app stdin_open: true + log-stdout: true + log-stderr: true tty: true networks: - greencheck-network