-
Notifications
You must be signed in to change notification settings - Fork 8
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 #4 from max-pfeiffer/feature/switch_to_new_base_image
Feature/switch to new base image
- Loading branch information
Showing
25 changed files
with
474 additions
and
706 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 |
---|---|---|
|
@@ -3,8 +3,8 @@ | |
# Base image: https://hub.docker.com/r/pfeiffermax/python-poetry | ||
# Dockerfile: https://github.com/max-pfeiffer/python-poetry/blob/main/build/Dockerfile | ||
ARG BASE_IMAGE | ||
ARG APPLICATION_SERVER_PORT | ||
FROM ${BASE_IMAGE} | ||
ARG APPLICATION_SERVER_PORT | ||
|
||
LABEL maintainer="Max Pfeiffer <[email protected]>" | ||
|
||
|
@@ -15,26 +15,35 @@ ENV PYTHONUNBUFFERED=1 \ | |
PYTHONPATH=/application_root \ | ||
# https://python-poetry.org/docs/configuration/#virtualenvsin-project | ||
POETRY_VIRTUALENVS_IN_PROJECT=true \ | ||
VIRTUAL_ENVIRONMENT_PATH="/application_root/.venv" | ||
POETRY_CACHE_DIR="/application_root/.cache" \ | ||
VIRTUAL_ENVIRONMENT_PATH="/application_root/.venv" \ | ||
APPLICATION_SERVER_PORT=$APPLICATION_SERVER_PORT | ||
|
||
ENV PATH="$POETRY_HOME/bin:$VIRTUAL_ENVIRONMENT_PATH/bin:$PATH" | ||
# Adding the virtual environment to PATH in order to "activate" it. | ||
# https://docs.python.org/3/library/venv.html#how-venvs-work | ||
ENV PATH="$VIRTUAL_ENVIRONMENT_PATH/bin:$PATH" | ||
|
||
# Set the WORKDIR to the application root. This needed for the entrypoints to | ||
# work. Also Uvicorn --reload feature relies by default on the current work dir. | ||
# Principle of least privilege: create a new user for running the application | ||
RUN groupadd -g 1001 python_application && \ | ||
useradd -r -u 1001 -g python_application python_application | ||
|
||
# Set the WORKDIR to the application root. | ||
# https://www.uvicorn.org/settings/#development | ||
# https://docs.docker.com/engine/reference/builder/#workdir | ||
WORKDIR ${PYTHONPATH} | ||
RUN chown python_application:python_application ${PYTHONPATH} | ||
|
||
COPY gunicorn_configuration.py ./scripts/start_gunicorn.sh /application_server/ | ||
RUN chmod +x /application_server/start_gunicorn.sh | ||
# Create cache directory and set permissions because user 1001 has no home | ||
# and poetry cache directory. | ||
# https://python-poetry.org/docs/configuration/#cache-directory | ||
RUN mkdir ${POETRY_CACHE_DIR} && chown python_application:python_application ${POETRY_CACHE_DIR} | ||
|
||
COPY ./scripts/pytest_entrypoint.sh ./scripts/black_entrypoint.sh /entrypoints/ | ||
RUN chmod +x /entrypoints/pytest_entrypoint.sh | ||
RUN chmod +x /entrypoints/black_entrypoint.sh | ||
# Copy the application server configuration | ||
COPY --chown=python_application:python_application gunicorn_configuration.py ${PYTHONPATH} | ||
|
||
# Activate entrypoint for running the Gunicorn application server | ||
CMD ["/application_server/start_gunicorn.sh"] | ||
|
||
# Document the exposed port which was configured in start_uvicorn.sh | ||
# Document the exposed port | ||
# https://docs.docker.com/engine/reference/builder/#expose | ||
EXPOSE ${APPLICATION_SERVER_PORT} | ||
|
||
# Activate entrypoint for running the Gunicorn application server | ||
CMD exec gunicorn -k uvicorn.workers.UvicornWorker -c $PYTHONPATH/gunicorn_configuration.py app.main:app |
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
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,5 +1,7 @@ | ||
.idea | ||
.pytest_cache | ||
.venv | ||
.coverage | ||
test_coverage_reports/ | ||
Dockerfile | ||
README.md | ||
test_coverage_reports/ |
Oops, something went wrong.