dockerize #8
Workflow file for this run
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: docker | |
on: | |
pull_request: | |
paths: | |
- ".github/workflows/docker.yml" | |
- ".dockerignore" | |
- "Dockerfile" | |
- "environment-dev.yml" | |
- "pyproject.toml" | |
- "ragna-docker.toml" | |
- "requirements-docker.lock" | |
push: | |
branches: | |
- release/* | |
workflow_dispatch: | |
concurrency: | |
group: ${{ github.ref }} | |
cancel-in-progress: ${{ github.event_name == 'pull_request' }} | |
env: | |
DOCKER_REGISTRY: quay.io | |
DOCKER_IMAGE: quansight/ragna | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
shell: bash -el {0} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup environment | |
uses: ./.github/actions/setup-env | |
with: | |
optional-dependencies: "false" | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Set up Docker Build Cache | |
id: cache | |
run: | | |
CACHE_DIR="${HOME}/.cache/docker" | |
mkdir --parents "${CACHE_DIR}" | |
echo "cache-dir=${CACHE_DIR}" | tee --append $GITHUB_OUTPUT | |
- name: Restore docker cache | |
uses: actions/cache@v3 | |
with: | |
path: ${{ steps.cache.outputs.cache-dir }} | |
key: docker-${{ hashFiles('Dockerfile','requirements-docker.lock') }} | |
restore-keys: docker- | |
- name: Setup metadata | |
id: metadata | |
run: | | |
VERSION=$(python -m setuptools_scm) | |
echo "version=${VERSION}" | tee --append $GITHUB_OUTPUT | |
TAG=$(echo "${VERSION}" | sed 's/+/-/g') | |
echo "tag=${TAG}" | tee --append $GITHUB_OUTPUT | |
- name: Login to Quay.io | |
if: ${{ github.event_name == 'workflow_dispatch' }} | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.DOCKER_REGISTRY }} | |
username: ${{ secrets.DOCKER_REGISTRY_USERNAME }} | |
password: ${{ secrets.DOCKER_REGISTRY_PASSWORD }} | |
- name: Build and push on workflow dispatch | |
uses: docker/build-push-action@v5 | |
with: | |
cache-from: type=local,src=${{ steps.cache.outputs.cache-dir }} | |
cache-to: type=local,dest=${{ steps.cache.outputs.cache-dir }} | |
# prettier-ignore | |
tags: ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE}}:${{steps.metadata.outputs.tag }} | |
build-args: | | |
SETUPTOOLS_SCM_PRETEND_VERSION_FOR_RAGNA=${{ steps.metadata.outputs.version }} | |
platforms: linux/amd64,linux/arm64 | |
load: true | |
push: ${{ github.event_name == 'workflow_dispatch' }} |