Skip to content

Commit

Permalink
Update dockerfile as advised by to remove use of ENV
Browse files Browse the repository at this point in the history
  • Loading branch information
mrchrisadams committed May 15, 2024
1 parent 98865d2 commit 4899c94
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
13 changes: 8 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
19 changes: 16 additions & 3 deletions usage_scenario.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4899c94

Please sign in to comment.