First step in consolidating to reusable workflows #18
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
name: Create and publish a Docker image | |
on: | |
push: | |
branches: main | |
paths-ignore: | |
- 'LICENSE' | |
- 'README.md' | |
- .github/workflows/build-deploy.yml | |
- '.github/workflows/build-deploy-keras2.yml' | |
- 'requirements.tf-2.15.0.txt' | |
release: | |
types: [published] | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: ${{ github.repository }} | |
TF_VERSION: 2.17.0 | |
jobs: | |
build-and-push-pyimage: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Log in to the Container registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract metadata (tags, labels) for Docker with CUDA | |
id: metagpu | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
flavor: | | |
suffix=-py-cuda-tf${{ env.TF_VERSION }},onlatest=true | |
tags: | | |
type=raw,value=latest,enable={{is_default_branch}} | |
type=raw,value={{date 'YYYY'}},enable={{is_default_branch}} | |
type=semver,pattern={{major}}.{{minor}}.{{patch}} | |
type=semver,pattern={{major}}.{{minor}} | |
type=semver,pattern={{major}} | |
labels: | | |
org.opencontainers.image.description=Combines the Docker Stacks tensorflow-notebook and pytorch-notebook containers with CUDA plus jupytext and custom package additions. | |
- name: Build and push Python-only Docker image with CUDA | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
file: Dockerfile-pyonly | |
build-args: | | |
CUDA=cuda- | |
TENSORFLOW_VERSION=${{ env.TF_VERSION }} | |
push: true | |
tags: ${{ steps.metagpu.outputs.tags }} | |
labels: ${{ steps.metagpu.outputs.labels }} | |
cache-to: type=gha,mode=max | |
cache-from: type=gha | |
build-and-push-cudaimage-withR: | |
runs-on: ubuntu-latest | |
needs: build-and-push-pyimage | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
# Image with CUDA needs extra disk space | |
- name: Free disk space 🧹 | |
uses: jlumbroso/[email protected] | |
with: | |
tool-cache: false | |
android: true | |
dotnet: true | |
haskell: true | |
large-packages: false | |
docker-images: false | |
swap-storage: false | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Log in to the Container registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract metadata (tags, labels) for Docker with CUDA | |
id: metagpu | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
flavor: | | |
suffix=-cuda-tf${{ env.TF_VERSION }},onlatest=true | |
tags: | | |
type=raw,value=latest,enable={{is_default_branch}} | |
type=raw,value={{date 'YYYY'}},enable={{is_default_branch}} | |
type=semver,pattern={{major}}.{{minor}}.{{patch}} | |
type=semver,pattern={{major}}.{{minor}} | |
type=semver,pattern={{major}} | |
labels: | | |
org.opencontainers.image.description=Combines the Docker Stacks tensorflow-notebook, pytorch-notebook, and r-notebook containers with CUDA plus jupytext and custom package additions. | |
- name: Build and push Docker image with CUDA | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
build-args: | | |
BASE_TAG=latest-py-cuda-tf${{ env.TF_VERSION }} | |
push: true | |
tags: ${{ steps.metagpu.outputs.tags }} | |
labels: ${{ steps.metagpu.outputs.labels }} |