-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #49 from numerique-gouv/poetry
Passage à poetry
- Loading branch information
Showing
13 changed files
with
1,788 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,42 @@ | ||
FROM python:3.10 | ||
|
||
EXPOSE 8000 | ||
EXPOSE ${HOST_PORT} | ||
|
||
ENV PYTHONDONTWRITEBYTECODE=1 | ||
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" | ||
|
||
# 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/ | ||
# 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 | ||
|
||
# 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; | ||
|
||
RUN python -m pip install --upgrade pip | ||
# 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} | ||
|
||
# Add `poetry` to PATH | ||
ENV PATH="${PATH}:${POETRY_VENV}/bin" | ||
|
||
WORKDIR $APP_DIR | ||
|
||
COPY requirements.txt . | ||
RUN pip install -r requirements.txt | ||
COPY pyproject.toml poetry.lock . | ||
RUN poetry install | ||
|
||
COPY --chown=app:app . . | ||
|
||
RUN python manage.py collectstatic --no-input | ||
RUN poetry run python manage.py collectstatic --no-input | ||
|
||
USER app | ||
|
||
ENTRYPOINT ["./entrypoint.sh"] | ||
|
||
CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"] | ||
CMD ["poetry", "run", "python", "manage.py", "runserver", "0.0.0.0:${HOST_PORT}"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
#!/bin/sh -l | ||
set -ex | ||
|
||
python manage.py migrate | ||
export PATH="${PATH}:${POETRY_VENV}/bin" | ||
poetry run python manage.py migrate | ||
|
||
exec "$@" |
Oops, something went wrong.