aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Chris Lovering <[email protected]>2023-10-03 11:12:42 +0100
committerGravatar Chris Lovering <[email protected]>2023-10-03 11:12:42 +0100
commitc7a8fafff8737afbb9c9fe59ad5bf5b3400dde8f (patch)
treeb9a0bdda0037e028881769003e4600b50b56469b
parentUse 3.12 stable over rc version (diff)
Add example Docker file and docker compose files, and suggested usages
-rw-r--r--README.md8
-rw-r--r--examples/Dockerfile.example12
-rw-r--r--examples/docker-compse.example.yaml13
3 files changed, 32 insertions, 1 deletions
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"