diff --git a/README.md b/README.md index 5be8548..14e9a92 100644 --- a/README.md +++ b/README.md @@ -19,3 +19,11 @@ Run application in project directory: ```shell poetry run uvicorn --workers 1 --host 0.0.0.0 --port 80 app.main:app ``` +Build the production Docker image: +```shell +docker build --target production-image --tag my-application:1.0.0 . +``` +Run the containerized application: +```shell +docker run -it --rm my-application:1.0.0 +``` diff --git a/{{cookiecutter.project_slug}}/Dockerfile b/{{cookiecutter.project_slug}}/Dockerfile index 2d963ad..339b00c 100644 --- a/{{cookiecutter.project_slug}}/Dockerfile +++ b/{{cookiecutter.project_slug}}/Dockerfile @@ -1,8 +1,6 @@ # Be aware that you need to specify these arguments before the first FROM # see: https://docs.docker.com/engine/reference/builder/#understand-how-arg-and-from-interact -ARG BASE_IMAGE_NAME_AND_TAG=pfeiffermax/uvicorn-poetry:2.0.0-python3.9.11-slim-bullseye -ARG OFFICIAL_PYTHON_IMAGE -FROM ${BASE_IMAGE_NAME_AND_TAG} as base-image +FROM pfeiffermax/uvicorn-poetry:2.0.0-python3.9.11-slim-bullseye as base-image WORKDIR /application_root @@ -12,7 +10,7 @@ WORKDIR /application_root COPY ./poetry.lock ./pyproject.toml /application_root/ RUN poetry install --no-interaction --no-root --no-dev -FROM ${OFFICIAL_PYTHON_IMAGE} as production-image +FROM python:3.9.11-slim-bullseye as production-image ENV PYTHONUNBUFFERED=1 \ PYTHONDONTWRITEBYTECODE=1 \ PYTHONPATH=/application_root @@ -39,7 +37,7 @@ USER python_application CMD ["/application_server/start_uvicorn.sh"] -FROM ${OFFICIAL_PYTHON_IMAGE} as production-image-json-logging +FROM python:3.9.11-slim-bullseye as production-image-json-logging ENV PYTHONUNBUFFERED=1 \ PYTHONDONTWRITEBYTECODE=1 \ PYTHONPATH=/application_root \