Skip to content

Build Developer Image #63

Build Developer Image

Build Developer Image #63

name: Build Developer Image
on: workflow_dispatch
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
BUILD_DIR: ./txpipe-dev
TEST_TAG: lsstdesc/txpipe-dev:testing
PUSH_TAG: ghcr.io/lsstdesc/txpipe-dev
# Set this to 0 to
DO_TEST: ${{ false }}
jobs:
build:
name: Build Developer 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 }}
tags: ${{ env.TEST_TAG }}
cache-from: type=gha
cache-to: type=gha,mode=max
# - name: Test docker image
# if: ${{ env.DO_TEST }}
# run: |
# docker run -v $PWD/test:/opt/TXPipe --rm -t ${{ env.TEST_TAG }} /opt/TXPipe/test-image.sh
- 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 }}
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}},${{ env.PUSH_TAG}}:latest,${{ env.PUSH_TAG}}:${{ steps.release_info.outputs.date }}
cache-from: type=gha
cache-to: type=gha,mode=max