diff options
author | 2023-03-18 03:49:47 +0400 | |
---|---|---|
committer | 2023-03-18 05:57:15 +0400 | |
commit | 3d9eff479c156f78eb1e71f2df42340327820909 (patch) | |
tree | b8a7ec6387c7508908a5f8597c5152f363653758 | |
parent | Document Python Version Selection (diff) |
Add Slim Imagemulti-version
Adds an image with only one python version installed. This can be useful
in development environments for other projects where the multi-version
features are less useful than a more efficient container.
Signed-off-by: Hassan Abouelela <[email protected]>
-rw-r--r-- | .github/workflows/deploy.yaml | 27 | ||||
-rw-r--r-- | Dockerfile | 7 | ||||
-rw-r--r-- | config/versions-light.json | 8 | ||||
-rw-r--r-- | config/versions.json | 12 |
4 files changed, 49 insertions, 5 deletions
diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index d8ad66b..48e66dd 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -22,6 +22,12 @@ jobs: with: name: ${{ inputs.artifact }} + - name: Set up Python + id: python + uses: actions/setup-python@v4 + with: + python-version: "3.11" + # Load the image to make use of common layers during the final build. - name: Load image from archive run: docker load -i ${{ inputs.artifact }}.tar @@ -106,3 +112,24 @@ jobs: tags: | ghcr.io/python-discord/snekbox-venv:latest ghcr.io/python-discord/snekbox-venv:${{ inputs.version }} + + # Build a lightweight image with a singular python version + - name: Regenerate dockerfile + run: python scripts/set_versions.py + env: + VERSIONS_CONFIG: config/versions-light.json + + - name: Build & push slim image + uses: docker/build-push-action@v3 + with: + context: . + file: ./Dockerfile + push: true + cache-from: | + ghcr.io/python-discord/snekbox-base:latest + ghcr.io/python-discord/snekbox-venv:latest + ghcr.io/python-discord/snekbox:latest + cache-to: type=inline + tags: | + ghcr.io/python-discord/snekbox:latest-slim + ghcr.io/python-discord/snekbox:${{ inputs.version }}-slim @@ -22,13 +22,16 @@ RUN make # ------------------------------------------------------------------------------ FROM python:3.11-slim-buster as base-first -FROM python:3.10-slim-buster as base-3-10 +FROM python:3.7-slim-buster as base-3-7 COPY --from=base-first / / +FROM python:3.9-slim-buster as base-3-9 +COPY --from=base-3-7 / / + # ------------------------------------------------------------------------------ FROM python:3.11-slim-buster as base -COPY --from=base-3-10 / / +COPY --from=base-3-9 / / # Everything will be a user install to allow snekbox's dependencies to be kept # separate from the packages exposed during eval. diff --git a/config/versions-light.json b/config/versions-light.json new file mode 100644 index 0000000..72900b9 --- /dev/null +++ b/config/versions-light.json @@ -0,0 +1,8 @@ +[ + { + "image_tag": "3.11-slim-buster", + "version_name": "3.11", + "display_name": "CPython 3.11", + "is_main": true + } +] diff --git a/config/versions.json b/config/versions.json index 004fad7..7733461 100644 --- a/config/versions.json +++ b/config/versions.json @@ -1,8 +1,14 @@ [ { - "image_tag": "3.10-slim-buster", - "version_name": "3.10", - "display_name": "CPython 3.10", + "image_tag": "3.7-slim-buster", + "version_name": "3.7", + "display_name": "CPython 3.7", + "is_main": false + }, + { + "image_tag": "3.9-slim-buster", + "version_name": "3.9", + "display_name": "CPython 3.9", "is_main": false }, { |