From c7a8fafff8737afbb9c9fe59ad5bf5b3400dde8f Mon Sep 17 00:00:00 2001 From: Chris Lovering Date: Tue, 3 Oct 2023 11:12:42 +0100 Subject: Add example Docker file and docker compose files, and suggested usages --- README.md | 8 +++++++- examples/Dockerfile.example | 12 ++++++++++++ examples/docker-compse.example.yaml | 13 +++++++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 examples/Dockerfile.example create mode 100644 examples/docker-compse.example.yaml diff --git a/README.md b/README.md index da7eee8..42d0455 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,8 @@ # python-poetry-base -A base Dockerfile with poetry pre-installed +A base Dockerfile with poetry pre-installed. Using this image as a base will allow you to forget about anything required to setup poetry within your Docker environment. + +Simply `COPY` your pyproject & poetry lock file into your image, and `poetry install`. + +virtual environments are created in `/opt/poetry/home` as to not conflict with in-project `.venv` folders that may be copied into the image if using a docker compose source code volume. + +See the [examples](./examples/) folder for example usage. diff --git a/examples/Dockerfile.example b/examples/Dockerfile.example new file mode 100644 index 0000000..a80d23d --- /dev/null +++ b/examples/Dockerfile.example @@ -0,0 +1,12 @@ +FROM --platform=linux/amd64 ghcr.io/owl-corp/python-poetry-base:3-slim + +# Install project dependencies +WORKDIR /my-app +COPY pyproject.toml poetry.lock ./ +RUN poetry install + +# Copy the source code in last to optimize rebuilding the image +COPY . . + +ENTRYPOINT ["poetry"] +CMD ["run", "python", "-m", "app"] diff --git a/examples/docker-compse.example.yaml b/examples/docker-compse.example.yaml new file mode 100644 index 0000000..f028ea9 --- /dev/null +++ b/examples/docker-compse.example.yaml @@ -0,0 +1,13 @@ + bot: + restart: unless-stopped + build: . + volumes: + - .:/app:ro + # Thanks to POETRY_HOME being set to "/opt/poetry/home", + # any venv folders on the host file system at this path + # will not be used by poetry within the Docker environment. + tty: true + env_file: + - .env + environment: + FOO: "bar" -- cgit v1.2.3