Skip to content

Commit

Permalink
Update Docker config
Browse files Browse the repository at this point in the history
  • Loading branch information
Ash-Crow committed Nov 20, 2023
1 parent e7892fb commit e652435
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
SECRET_KEY=
DEBUG=False
HOST_PROTO=http
HOST_URL=localhost
HOST_URL="localhost, 0.0.0.0"

USE_VENV=1

Expand Down
22 changes: 17 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,29 @@ ENV PYTHONUNBUFFERED=1
ENV GECKODRIVER_URL=https://github.com/mozilla/geckodriver/releases/download/v0.32.0/geckodriver-v0.32.0-linux32.tar.gz
ENV APP_DIR="/app"

# Configure Poetry
ENV POETRY_VERSION=1.7.0
ENV POETRY_HOME=/opt/poetry
ENV POETRY_VENV=/opt/poetry-venv
ENV POETRY_CACHE_DIR=/opt/.cache

# For behave tests
RUN apt-get update && apt-get install -y --no-install-recommends firefox-esr
RUN wget -qO- $GECKODRIVER_URL | tar xvz -C /usr/bin/
RUN apt-get update && apt-get install -y --no-install-recommends firefox-esr && rm -rf /var/lib/apt/lists/*
RUN wget -qO- ${GECKODRIVER_URL} | tar xvz -C /usr/bin/

# Add new user to run the whole thing as non-root.
RUN set -ex \
&& addgroup app \
&& adduser --ingroup app --home $APP_DIR --disabled-password app;
&& adduser --ingroup app --home ${APP_DIR} --disabled-password app;


# Install poetry separated from system interpreter
RUN python3 -m venv ${POETRY_VENV} \
&& ${POETRY_VENV}/bin/pip install -U pip setuptools \
&& ${POETRY_VENV}/bin/pip install poetry==${POETRY_VERSION}

RUN python -m pip install --upgrade pip \
&& pip install poetry
# Add `poetry` to PATH
ENV PATH="${PATH}:${POETRY_VENV}/bin"

WORKDIR $APP_DIR

Expand Down
5 changes: 3 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@ services:
POSTGRES_USER: dju
POSTGRES_PASSWORD: djpwd
POSTGRES_DB: djdb
PGPORT: 8432
ports:
- "5433:5433"
- "8432:8432"
volumes:
- postgres_data:/var/lib/postgresql/data

web:
build: .
environment:
DATABASE_URL: postgres://dju:djpwd@db:5433/djdb
DATABASE_URL: postgres://dju:djpwd@db:8432/djdb
ports:
- "8000:8000"
volumes:
Expand Down
1 change: 1 addition & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/sh -l
set -ex

export PATH="${PATH}:${POETRY_VENV}/bin"
poetry run python manage.py migrate

exec "$@"

0 comments on commit e652435

Please sign in to comment.