-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add an image for running Python scripts with dependencies
- Loading branch information
Showing
5 changed files
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
FROM debian:12-slim AS build | ||
RUN apt-get update && \ | ||
apt-get install --no-install-suggests --no-install-recommends --yes python3-venv gcc libpython3-dev && \ | ||
python3 -m venv /venv && \ | ||
/venv/bin/pip install --upgrade pip setuptools wheel | ||
|
||
FROM build AS build-venv | ||
COPY requirements.txt . | ||
RUN /venv/bin/pip install --disable-pip-version-check -r requirements.txt | ||
|
||
# Copy the virtualenv into a distroless image | ||
FROM gcr.io/distroless/python3-debian12 | ||
COPY --from=build-venv /venv /venv | ||
|
||
USER nonroot | ||
|
||
WORKDIR /app | ||
ENTRYPOINT ["/venv/bin/python3"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# hmpps-python-deps | ||
|
||
Docker image containing Python dependencies to enable running of Python scripts without needing to install locally. Dependencies included are defined in the [requirements.txt](./requirements.txt) file. Add further dependencies to the [requirements.txt](./requirements.txt) file as needed. To execute a python script with the image dependencies run the image with the local script directory volume mapped: | ||
|
||
```sh | ||
docker run -v .:/app -t -e SOME_ENV_VAR=some-value hmpps-python-deps:latest ./script.py <some-argument> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
requests | ||
pyyaml |