Skip to content

Docker

Docker #578

name: Docker
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
on:
schedule:
- cron: '43 22 * * *'
push:
branches:
- master
env:
# Use docker.io for Docker Hub if empty
REGISTRY: docker.io #ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: runzhongwang/thinkmatch #thinklab-sjtu/thinkmatch
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write
strategy:
matrix:
tag: ['torch1.6.0-cuda10.1-cudnn7-pyg1.6.3', 'torch1.7.1-cuda11.0-cudnn8-pyg1.6.3', 'torch1.10.0-cuda11.3-cudnn8-pyg2.0.3']
steps:
# Workaround suggested by https://github.com/actions/runner-images/issues/2840
- name: Free for more disk 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"
# Fetch the latest pygmtools version
- name: Package Latest Version
# You may pin to the exact commit or the version.
# uses: Bruce17/ghaction-package-latest-version@dfa1c49e0cff7dafe5db3918af5f50510c2130b6
uses: Bruce17/ghaction-package-latest-version@v1.1.1
id: pygmtools
with:
# Name of the package to search for.
package: pygmtools
# The target language and thus backend registry.
language: python
- name: Checkout repository
uses: actions/checkout@v2
# Install the cosign tool except on PR
# https://github.com/sigstore/cosign-installer
- name: Install cosign
if: github.event_name != 'pull_request'
uses: sigstore/cosign-installer@v3.1.2
with:
cosign-release: 'v1.4.0'
# Workaround: https://github.com/docker/build-push-action/issues/461
- name: Setup Docker buildx
uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf
# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.DOCKER_USERNAME }} #${{ github.actor }}
password: ${{ secrets.DOCKER_PASSWD }} #${{ secrets.GITHUB_TOKEN }}
# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=${{ matrix.tag }}-pygmtools${{ steps.pygmtools.outputs.latestVersion }}
- name: Check for existing image
id: existing-image
uses: KerberosMorphy/docker-exist-action@v1.1.2
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.DOCKER_USERNAME }} #${{ github.actor }}
password: ${{ secrets.DOCKER_PASSWD }} #${{ secrets.GITHUB_TOKEN }}
image: ${{ env.IMAGE_NAME }}:${{ matrix.tag }}-pygmtools${{ steps.pygmtools.outputs.latestVersion }}
#- name: Check for existing image
# id: existing-image
# uses: javajawa/check-registry-for-image@v1
# with:
# registry: ${{ env.REGISTRY }}
# repository: ${{ env.IMAGE_NAME }}
# tag: ${{ matrix.tag }}-pygmtools${{ steps.pygmtools.outputs.latestVersion }}
# Output the existing-image check
- name: Get the output
run: |
echo "Value is: ${{ steps.existing-image.outputs.image_exist }}."
# Get the new nvidia key
- name: Wget the nvidia key
run: |
wget -O ${{ matrix.tag }}/cuda-keyring_1.0-1_all.deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-keyring_1.0-1_all.deb
# List working dir
- name: List working dir
run: |
pwd && ls && cd ${{ matrix.tag }} && pwd && ls
# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
#if: ${{ steps.existing-image.outputs.exists != 'true' }}
if: ${{ steps.existing-image.outputs.image_exist == '0' }}
id: build-and-push
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: ${{ matrix.tag }}/.
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
# Sign the resulting Docker image digest except on PRs.
# This will only write to the public Rekor transparency log when the Docker
# repository is public to avoid leaking data. If you would like to publish
# transparency data even for private images, pass --force to cosign below.
# https://github.com/sigstore/cosign
#- name: Sign the published Docker image
# #if: ${{ github.event_name != 'pull_request' && steps.existing-image.outputs.exists != 'true' }}
# if: ${{ github.event_name != 'pull_request' && steps.existing-image.outputs.image_exist == '0' }}
# env:
# COSIGN_EXPERIMENTAL: "true"
# # This step uses the identity token to provision an ephemeral certificate
# # against the sigstore community Fulcio instance.
# run: cosign sign ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ steps.build-and-push.outputs.digest }}