Skip to content

Build Base Image

Build Base Image #9

name: Build Base Image
on: workflow_dispatch
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
BUILD_DIR: ./txpipe-base
TEST_TAG: lsstdesc/txpipe-base:base
PUSH_TAG: ghcr.io/lsstdesc/txpipe-base
# Set this to 0 to
DO_TEST: ${{ false }}
jobs:
build:
strategy:
matrix:
mpiversion: [4.0.2, 4.2.0]
name: Build Base Image
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
# This only gets the date in this job, because
# there is no release tag
- name: Get release info
id: release_info
run: |
echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
- name: Build docker image
uses: docker/build-push-action@v4
with:
context: ${{ env.BUILD_DIR }}
file: ${{ env.BUILD_DIR }}/Dockerfile
# the load option means the built image is kept locally
# but not pushed yet
load: true
build-args: |
TX_DOCKER_VERSION=${{ github.sha }}
TX_RELEASE_TAG=dev-${{ steps.release_info.outputs.date }}
TX_RELEASE_DATE=${{ steps.release_info.outputs.date }}
TX_MPI_VERSION=${{ matrix.mpiversion }}
tags: ${{ env.TEST_TAG }}-${{ matrix.mpiversion }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: ${{ env.BUILD_DIR }}
file: ${{ env.BUILD_DIR }}/Dockerfile
# These arguments get passed into the docker image itself
build-args: |
TX_DOCKER_VERSION=${{ github.sha }}
TX_RELEASE_TAG=dev-${{ steps.release_info.outputs.date }}
TX_RELEASE_DATE=${{ steps.release_info.outputs.date }}
TX_MPI_VERSION=${{ matrix.mpiversion }}
push: true
# We use three tags for release builds:
# txpipe-dev
# txpipe-dev:latest
# txpipe-dev:<the date, e.g. 2023-03-21>
tags: ${{ env.PUSH_TAG}}-${{ matrix.mpiversion }},${{ env.PUSH_TAG}}-${{ matrix.mpiversion }}:latest,${{ env.PUSH_TAG}}-${{ matrix.mpiversion }}:${{ steps.release_info.outputs.date }}
cache-from: type=gha
cache-to: type=gha,mode=max