Skip to content

Commit

Permalink
Add example Docker file and docker compose files, and suggested usages
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisLovering committed Oct 3, 2023
1 parent c338500 commit c7a8faf
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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.
12 changes: 12 additions & 0 deletions examples/Dockerfile.example
Original file line number Diff line number Diff line change
@@ -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"]
13 changes: 13 additions & 0 deletions examples/docker-compse.example.yaml
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit c7a8faf

Please sign in to comment.