Skip to content

Commit

Permalink
Fixed Dockerfile. Updated docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
max-pfeiffer committed Jul 10, 2022
1 parent 25ea43d commit 9d0437f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
8 changes: 3 additions & 5 deletions {{cookiecutter.project_slug}}/Dockerfile
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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
Expand All @@ -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 \
Expand Down

0 comments on commit 9d0437f

Please sign in to comment.