Skip to content

Build and push dockerdl images #242

Build and push dockerdl images

Build and push dockerdl images #242

name: Build and push dockerdl images
on:
pull_request:
paths:
- ./conda.Dockerfile
- ./torch.Dockerfile
- ./tf-torch.Dockerfile
- ./tf-torch-conda.Dockerfile
- ./tf.Dockerfile
workflow_dispatch:
workflow_run:
workflows: ["Build and push dockerdl-base image"]
branches: ["main"]
types:
- completed
concurrency:
group: dockerdl-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
id-token: write
strategy:
fail-fast: false
matrix:
include:
- dockerfile: ./conda.Dockerfile
tag: conda
- dockerfile: ./tf-torch-conda.Dockerfile
tag: tf-torch-conda
- dockerfile: ./tf-torch.Dockerfile
tag: tf-torch
- dockerfile: ./torch.Dockerfile
tag: torch
- dockerfile: ./tf.Dockerfile
tag: tf
steps:
- name: Maximize build space
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf "/usr/local/share/boost"
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Docker buildx
uses: docker/setup-buildx-action@v3
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
matifali/dockerdl
tags: |
type=raw,value=${{ matrix.tag }}
type=raw,value=latest,enable=${{ matrix.tag == 'tf-torch' }}
labels: |
org.opencontainers.image.source=${{ github.event.repository.clone_url }}
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.created=${{ github.event.head_commit.timestamp }}
org.opencontainers.image.title=${{ github.event.repository.name }}
org.opencontainers.image.description=${{ github.event.repository.description }}
org.opencontainers.image.url=${{ github.event.repository.html_url }}
org.opencontainers.image.licenses=${{ github.event.repository.license.spdx_id }}
org.opencontainers.image.authors=${{ github.event.repository.owner.login }}
- name: Login to DockerHub
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@v6
with:
context: .
file: ${{ matrix.dockerfile }}
push: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/main' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Update Readme on dockerhub
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
uses: peter-evans/dockerhub-description@v4
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
repository: matifali/dockerdl
short-description: ${{ github.event.repository.description }}
readme-filepath: README.md