Build FAST runtime docker images #25
This file contains hidden or 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: Build FAST runtime docker images | |
| on: | |
| push: | |
| workflow_dispatch: | |
| inputs: | |
| deploy: | |
| description: Deploy to packages | |
| type: boolean | |
| required: true | |
| default: false | |
| permissions: | |
| contents: read | |
| packages: write | |
| jobs: | |
| get-latest-version: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| fast-version: ${{ steps.get.outputs.result }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| - name: Get latest FAST version | |
| id: get | |
| run: | | |
| FAST_VERSION=$(python3 get_latest_fast_version.py) | |
| echo "result=$FAST_VERSION" >> $GITHUB_OUTPUT | |
| build-test-deploy: | |
| runs-on: ubuntu-latest | |
| needs: get-latest-version | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| type: [library, python] | |
| x_server: [xvfb, none] | |
| opencl: [pocl, intel] | |
| vgl: [true, false] | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| - name: Set variables | |
| run: | | |
| FAST_VERSION=${{ needs.get-latest-version.outputs.fast-version }} | |
| echo "FAST_VERSION=$FAST_VERSION" >> "$GITHUB_ENV" | |
| if [ "${{ matrix.vgl }}" = "true" ]; then | |
| VGL_TAG=-vgl | |
| else | |
| VGL_TAG= | |
| fi | |
| if [ "${{ matrix.x_server }}" = "none" ]; then | |
| X_TAG=no_x | |
| else | |
| X_TAG=${{ matrix.x_server }} | |
| fi | |
| IMAGE_NAME=ghcr.io/fast-imaging/fast:${FAST_VERSION}-${{ matrix.type }}-${{ matrix.opencl }}-${X_TAG}${VGL_TAG} | |
| IMAGE_FILENAME=fast-${FAST_VERSION}-${{ matrix.type }}-${{ matrix.opencl }}-${X_TAG}${VGL_TAG}.tar | |
| echo "IMAGE_NAME=$IMAGE_NAME" >> "$GITHUB_ENV" | |
| echo "IMAGE_FILENAME=$IMAGE_FILENAME" >> "$GITHUB_ENV" | |
| - name: Build | |
| run: | | |
| docker build . -f runtime.Dockerfile \ | |
| -t $IMAGE_NAME \ | |
| --build-arg TYPE=${{ matrix.type }} \ | |
| --build-arg X_SERVER=${{ matrix.x_server }} \ | |
| --build-arg OPENCL_PLATFORM=${{ matrix.opencl }} \ | |
| --build-arg VIRTUALGL=${{ matrix.vgl }} \ | |
| --build-arg FAST_VERSION=$FAST_VERSION | |
| - name: Cache test data | |
| # Intel OpenCL does not work in github action | |
| if: ${{ matrix.opencl != 'intel' && matrix.type == 'python' }} | |
| id: cache-test-dataset | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/FAST/data/ | |
| key: test-dataset | |
| enableCrossOsArchive: true | |
| - name: Test docker image | |
| # Intel OpenCL does not work in github action | |
| if: ${{ matrix.opencl != 'intel' }} | |
| run: | | |
| if [ "${{ matrix.opencl }}" = "intel" ]; then | |
| docker run --rm -v ~/FAST/data/:/root/FAST/data/ --device=/dev/dri $IMAGE_NAME | |
| else | |
| docker run --rm -v ~/FAST/data/:/root/FAST/data/ $IMAGE_NAME | |
| fi | |
| - name: Save docker image to file | |
| run: | | |
| docker save -o $IMAGE_FILENAME $IMAGE_NAME | |
| - name: Upload docker image file as artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ env.IMAGE_FILENAME }} | |
| path: ${{ env.IMAGE_FILENAME }} | |
| if-no-files-found: error | |
| retention-days: 3 | |
| - name: Login to GitHub Container Registry | |
| if: ${{ inputs.deploy }} | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Push container | |
| if: ${{ inputs.deploy }} | |
| run: | | |
| docker push $IMAGE_NAME |