Skip to content

Build Developer Image #49

Build Developer Image

Build Developer Image #49

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: Check disk space 1
run: |
df . -h
# docker image build is running out of disk space
# adding this action to test freeing up space
- name: Free Up GitHub Actions Ubuntu Runner Disk Space 🔧
uses: jlumbroso/free-disk-space@main
with:
# This might remove tools that are actually needed, if set to "true" but frees about 6 GB
tool-cache: false
# All of these default to true, but feel free to set to "false" if necessary for your workflow
android: true
dotnet: true
haskell: true
large-packages: true
swap-storage: true
- name: Check disk space 2
run: |
df . -h
- name: Checkout repository
uses: actions/checkout@v4
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
# 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@v5
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