Skip to content

feat: make seisbench dependency optional (#578) #1182

feat: make seisbench dependency optional (#578)

feat: make seisbench dependency optional (#578) #1182

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: '21 21 * * 5'
push:
branches: [ master ]
# Publish semver tags as releases.
tags: [ 'v*.*.*' ]
pull_request:
branches: [ master ]
release:
types: [published]
env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}
jobs:
build-latest:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
# Remove software and language runtimes we're not using
- name: Remove unnecessary files
run: |
sudo rm -rf \
"$AGENT_TOOLSDIRECTORY" \
/opt/google/chrome \
/opt/microsoft/msedge \
/opt/microsoft/powershell \
/opt/pipx \
/usr/lib/mono \
/usr/local/julia* \
/usr/local/lib/android \
/usr/local/lib/node_modules \
/usr/local/share/chromium \
/usr/local/share/powershell \
/usr/share/dotnet \
/usr/share/swift
df -h /
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
# Setup for Multi-platform image
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Cache Docker layers
uses: actions/cache@v3
with:
path: |
/tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
# Login against a Docker registry
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v4
with:
flavor: |
latest=true
images: |
mspass/mspass
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=schedule,pattern=weekly
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
# 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 (amd64 only)
uses: docker/build-push-action@v4
if: ${{ github.event_name != 'schedule' || github.event_name != 'release' }}
with:
context: .
platforms: linux/amd64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new
- name: Build and push Docker image (amd64 and arm64)
uses: docker/build-push-action@v4
if: ${{ github.event_name == 'schedule' || github.event_name == 'release' }}
with:
context: .
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new
# Temp fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
build-dev:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
# Remove software and language runtimes we're not using
- name: Remove unnecessary files
run: |
sudo rm -rf \
"$AGENT_TOOLSDIRECTORY" \
/opt/google/chrome \
/opt/microsoft/msedge \
/opt/microsoft/powershell \
/opt/pipx \
/usr/lib/mono \
/usr/local/julia* \
/usr/local/lib/android \
/usr/local/lib/node_modules \
/usr/local/share/chromium \
/usr/local/share/powershell \
/usr/share/dotnet \
/usr/share/swift
df -h /
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
# Setup for Multi-platform image
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Cache Docker layers
uses: actions/cache@v3
with:
path: |
/tmp/.buildx-cache-dev
key: ${{ runner.os }}-buildx.dev-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx.dev-
# Login against a Docker registry
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v4
with:
flavor: |
latest=true
images: |
mspass/mspass
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
# Build and push dev image
- name: Build and push dev image (amd64 only)
uses: docker/build-push-action@v4
if: ${{ github.event_name != 'schedule' || github.event_name != 'release' }}
with:
context: .
file: Dockerfile_dev
platforms: linux/amd64
push: true
tags: |
mspass/mspass:dev
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:dev
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=local,src=/tmp/.buildx-cache-dev
cache-to: type=local,dest=/tmp/.buildx-cache-dev-new
- name: Build and push dev image (amd64 amd arm64)
uses: docker/build-push-action@v4
if: ${{ github.event_name == 'schedule' || github.event_name == 'release' }}
with:
context: .
file: Dockerfile_dev
platforms: linux/amd64,linux/arm64
push: true
tags: |
mspass/mspass:dev
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:dev
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=local,src=/tmp/.buildx-cache-dev
cache-to: type=local,dest=/tmp/.buildx-cache-dev-new
# Temp fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache-dev
mv /tmp/.buildx-cache-dev-new /tmp/.buildx-cache-dev
build-mpi:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
# Remove software and language runtimes we're not using
- name: Remove unnecessary files
run: |
sudo rm -rf \
"$AGENT_TOOLSDIRECTORY" \
/opt/google/chrome \
/opt/microsoft/msedge \
/opt/microsoft/powershell \
/opt/pipx \
/usr/lib/mono \
/usr/local/julia* \
/usr/local/lib/android \
/usr/local/lib/node_modules \
/usr/local/share/chromium \
/usr/local/share/powershell \
/usr/share/dotnet \
/usr/share/swift
df -h /
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
# Setup for Multi-platform image
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Cache Docker layers
uses: actions/cache@v3
with:
path: |
/tmp/.buildx-cache-mpi
key: ${{ runner.os }}-buildx.mpi-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx.mpi-
# Login against a Docker registry
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v4
with:
flavor: |
latest=true
images: |
mspass/mspass
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
# Build and push mpi image
- name: Build and push mpi image (amd64 only)
uses: docker/build-push-action@v4
with:
context: .
file: Dockerfile_mpi
platforms: linux/amd64
push: ${{ github.event_name != 'pull_request' }}
tags: |
mspass/mspass:mpi
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:mpi
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=local,src=/tmp/.buildx-cache-mpi
cache-to: type=local,dest=/tmp/.buildx-cache-mpi-new
# Temp fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache-mpi
mv /tmp/.buildx-cache-mpi-new /tmp/.buildx-cache-mpi