Skip to content

Commit

Permalink
Simplify build ARGs
Browse files Browse the repository at this point in the history
  • Loading branch information
robballantyne committed Aug 9, 2023
1 parent 07ede36 commit fa42abb
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 56 deletions.
6 changes: 2 additions & 4 deletions .env
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
IMAGE_BASE="ghcr.io/ai-dock/python:all-cuda-11.8.0-base-22.04"
IMAGE_TAG="all-cuda-11.8.0-base-22.04"
PYTHON_VERSION=all
PYTHON_MAMBA_NAME=python_311
IMAGE_BASE="ghcr.io/ai-dock/python:all-cuda-11.8.0-cudnn8-runtime-22.04"
IMAGE_TAG="all-cuda-11.8.0-cudnn8-runtime-22.04"
73 changes: 32 additions & 41 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ jobs:
fail-fast: false
matrix:
python:
- ["2.7", "python_27"]
- ["3.8", "python_38"]
- ["3.9", "python_39"]
- ["3.10", "python_310"]
- ["3.11", "python_311"]
- ["all", "python_311"]
- "2.7"
- "3.8"
- "3.9"
- "3.10"
- "3.11"
- "all"
steps:
-
name: Env Setter
Expand All @@ -44,7 +44,7 @@ jobs:
name: Set tags
run: |
img_path="ghcr.io/${{ env.PACKAGE_NAME }}"
ver_tag="${{ matrix.python[0] }}-cpu-${{ env.UBUNTU_VERSION }}"
ver_tag="${{ matrix.python }}-cpu-${{ env.UBUNTU_VERSION }}"
if [[ $ver_tag == ${{ env.LATEST_CPU }} ]]; then
TAGS="${img_path}:latest-cpu, ${img_path}:$ver_tag"
Expand All @@ -58,10 +58,7 @@ jobs:
with:
context: build
build-args: |
IMAGE_BASE=ghcr.io/ai-dock/python:${{ matrix.python[0] }}-cpu-${{ env.UBUNTU_VERSION }}
PYTHON_VERSION=${{ matrix.python[0] }}
PYTHON_MAMBA_NAME=${{ matrix.python[1] }}
MAMBA_DEFAULT_ENV=${{ matrix.python[1] }}
IMAGE_BASE=ghcr.io/ai-dock/python:${{ matrix.python }}-cpu-${{ env.UBUNTU_VERSION }}
push: true
# Avoids unknown/unknown architecture and extra metadata
provenance: false
Expand All @@ -73,27 +70,27 @@ jobs:
fail-fast: false
matrix:
python:
- ["2.7", "python_27"]
- ["3.8", "python_38"]
- ["3.9", "python_39"]
- ["3.10", "python_310"]
- ["3.11", "python_311"]
- ["all", "python_311"]
- "2.7"
- "3.8"
- "3.9"
- "3.10"
- "3.11"
- "all"
cuda:
- 11.7.1
- 11.8.0
- 12.1.0
- 12.2.0
- "11.7.1"
- "11.8.0"
- "12.1.0"
- "12.2.0"
level:
- "base"
- "runtime"
- "devel"
- "cudnn8-runtime"
- "cudnn8-devel"
exclude:
- cuda: 12.2.0
- cuda: "12.2.0"
level: "cudnn8-runtime" # Not yet available
- cuda: 12.2.0
- cuda: "12.2.0"
level: "cudnn8-devel" # Not yet available
steps:
-
Expand All @@ -114,7 +111,7 @@ jobs:
name: Set tags
run: |
img_path="ghcr.io/${{ env.PACKAGE_NAME }}"
ver_tag="${{ matrix.python[0] }}-cuda-${{ matrix.cuda }}-${{ matrix.level }}-${{ env.UBUNTU_VERSION }}"
ver_tag="${{ matrix.python }}-cuda-${{ matrix.cuda }}-${{ matrix.level }}-${{ env.UBUNTU_VERSION }}"
if [[ $ver_tag == ${{ env.LATEST_CUDA }} ]]; then
TAGS="${img_path}:latest, ${img_path}:latest-cuda, ${img_path}:$ver_tag"
Expand All @@ -128,10 +125,7 @@ jobs:
with:
context: build
build-args: |
IMAGE_BASE=ghcr.io/ai-dock/python:${{ matrix.python[0] }}-cuda-${{ matrix.cuda }}-${{ matrix.level }}-${{ env.UBUNTU_VERSION }}
PYTHON_VERSION=${{ matrix.python[0] }}
PYTHON_MAMBA_NAME=${{ matrix.python[1] }}
MAMBA_DEFAULT_ENV=${{ matrix.python[1] }}
IMAGE_BASE=ghcr.io/ai-dock/python:${{ matrix.python }}-cuda-${{ matrix.cuda }}-${{ matrix.level }}-${{ env.UBUNTU_VERSION }}
push: true
provenance: false
tags: ${{ env.TAGS }}
Expand All @@ -142,15 +136,15 @@ jobs:
fail-fast: false
matrix:
python:
- ["2.7", "python_27"]
- ["3.8", "python_38"]
- ["3.9", "python_39"]
- ["3.10", "python_310"]
- ["3.11", "python_311"]
- ["all", "python_311"]
- "2.7"
- "3.8"
- "3.9"
- "3.10"
- "3.11"
- "all"
rocm:
- 5.4.2
- 5.6
- "5.4.2"
- "5.6"
level:
- "core"
- "runtime"
Expand All @@ -174,7 +168,7 @@ jobs:
name: Set tags
run: |
img_path="ghcr.io/${{ env.PACKAGE_NAME }}"
ver_tag="${{ matrix.python[0] }}-rocm-${{ matrix.rocm }}-${{ matrix.level }}-${{ env.UBUNTU_VERSION }}"
ver_tag="${{ matrix.python }}-rocm-${{ matrix.rocm }}-${{ matrix.level }}-${{ env.UBUNTU_VERSION }}"
if [[ $ver_tag == ${{ env.LATEST_ROCM }} ]]; then
TAGS="${img_path}:latest-rocm, ${img_path}:$ver_tag"
Expand All @@ -188,10 +182,7 @@ jobs:
with:
context: build
build-args: |
IMAGE_BASE=ghcr.io/ai-dock/python:${{ matrix.python[0] }}-rocm-${{ matrix.rocm }}-${{ matrix.level }}-${{ env.UBUNTU_VERSION }}
PYTHON_VERSION=${{ matrix.python[0] }}
PYTHON_MAMBA_NAME=${{ matrix.python[1] }}
MAMBA_DEFAULT_ENV=${{ matrix.python[1] }}
IMAGE_BASE=ghcr.io/ai-dock/python:${{ matrix.python }}-rocm-${{ matrix.rocm }}-${{ matrix.level }}-${{ env.UBUNTU_VERSION }}
push: true
provenance: false
tags: ${{ env.TAGS }}
11 changes: 3 additions & 8 deletions build/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# For build automation - Allows building from any ai-dock base image
ARG IMAGE_BASE="ghcr.io/ai-dock/base-image:cuda-11.8.0-base-22.04"
ARG IMAGE_BASE="ghcr.io/ai-dock/python:all-cuda-11.8.0-cudnn8-runtime-22.04"
FROM ${IMAGE_BASE}

LABEL org.opencontainers.image.source https://github.com/ai-dock/jupyter-python

LABEL org.opencontainers.image.description "Jupyter lab/notebook with Python kernel"
LABEL org.opencontainers.image.description "Jupyter lab/notebook with Python kernels"

LABEL maintainer="Rob Ballantyne <rob@dynamedia.uk>"

Expand All @@ -14,12 +14,7 @@ LABEL maintainer="Rob Ballantyne <rob@dynamedia.uk>"
# Copy early so we can use scripts in the build - Changes to these files will invalidate the cache and cause a rebuild.
COPY ./COPY_ROOT/ /

# Define the startup mamba environment for interactive sessions
ARG MAMBA_DEFAULT_ENV=system
ENV MAMBA_DEFAULT_ENV=${MAMBA_DEFAULT_ENV}

ARG PYTHON_VERSION
ARG PYTHON_MAMBA_NAME
# Default env inherited from ghcr.io/ai-dock/python

# Use build scripts to ensure we can build all targets from one Dockerfile in a single layer.
# Don't put anything heavy in here - We can use multi-stage building above if necessary.
Expand Down
3 changes: 0 additions & 3 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ services:
context: ./build
args:
IMAGE_BASE: ${IMAGE_BASE}
PYTHON_VERSION: ${PYTHON_VERSION}
PYTHON_MAMBA_NAME: ${PYTHON_MAMBA_NAME}
MAMBA_DEFAULT_ENV: ${PYTHON_MAMBA_NAME}
tags:
- "ghcr.io/ai-dock/jupyter-python:${IMAGE_TAG}"

Expand Down

0 comments on commit fa42abb

Please sign in to comment.