Skip to content

Build Docker container #3

Build Docker container

Build Docker container #3

# Distributed under the MIT License.
# See LICENSE.txt for details.
# This workflow can be run manually on any branch to build and push our Docker
# containers.
name: Build Docker container
on:
workflow_dispatch:
inputs:
image_name:
description: >
Image name to push to DockerHub
required: true
default: 'sxscollaboration/spectre'
build_arm:
type: boolean
description: >
Build ARM container in addition to x86_64
default: true
jobs:
build_container:
name: Build and deploy
runs-on: ubuntu-latest
# This environment can be protected to require manual approval before
# deployment. On forks where you set your own secrets for authentication
# with DockerHub you can choose not to protect this environment.
environment: deploy-containers
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up emulation support
if: inputs.build_arm
uses: docker/setup-qemu-action@v3
with:
platforms: arm64
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
# We could also push containers to GitHub instead of DockerHub
# - name: Login to GitHub container registry
# uses: docker/login-action@v3
# with:
# registry: ghcr.io
# username: ${{ github.actor }}
# password: ${{ secrets.GITHUB_TOKEN }}
- name: Build dev container
uses: docker/build-push-action@v5
with:
push: true
context: .
file: "./containers/Dockerfile.buildenv"
target: dev
tags: ${{ inputs.image_name }}:dev
platforms: >
${{ inputs.build_arm && 'linux/amd64,linux/arm64'
|| 'linux/amd64' }}
- name: Build CI container
uses: docker/build-push-action@v5
with:
push: true
context: .
file: "./containers/Dockerfile.buildenv"
target: ci
tags: ${{ inputs.image_name }}:ci
# No ARM container for CI because GitHub doesn't host ARM runners yet
platforms: linux/amd64
run_tests:
name: Test
uses: ./.github/workflows/Tests.yaml
needs: build_container
secrets: inherit
with:
container: ${{ inputs.image_name }}:ci