Skip to content

Commit

Permalink
ci: cloud builder for multi arch builds (#163)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nithos authored Feb 13, 2024
1 parent 50823b8 commit 2b95c4c
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 67 deletions.
61 changes: 61 additions & 0 deletions .github/workflows/publish-cloud-builder.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
---
# Automatically build Docker images using a cloud builder and publish them to a
# container registry using HCL Bake file.

name: Build Docker Images using Cloud Builder

on:
push:
branches: ['main']
tags: ['*']

jobs:
bake-target:
name: Determine bake target
runs-on: ubuntu-22.04 # don't use the big runners for this small step
outputs:
target: ${{ steps.generate.outputs.bake_target }}
steps:
- name: Determine target
id: generate
run: |
if [[ '${{ github.event_name }}' == 'pull_request' ]]; then
TGT=default
else
TGT=prod
fi
echo "$TGT"
echo "bake_target=${TGT,,}" >> ${GITHUB_OUTPUT}
- name: Show Generated Target
run: echo ${{ steps.generate.outputs.bake_target }}

# Build and Publish all targets associated with specified group
bake:
needs:
- bake-target
uses: darpa-askem/.github/.github/workflows/bake-publish-cloud-builder.yaml@main
with:
file: 'docker/docker-bake.hcl'
group: ${{ needs.bake-target.outputs.target }}
registry: 'ghcr.io'
organization: ${{ github.repository_owner }}
secrets:
username: ${{ secrets.DOCKER_CLOUD_BUILD_USERNAME }}
token: ${{ secrets.DOCKER_CLOUD_BUILD_TOKEN }}
endpoint: "${{ secrets.DOCKER_CLOUD_BUILD_ENDPOINT }}"

# Execute simulation-integration reporting
simulation-integration:
runs-on: ubuntu-latest
needs:
- bake
steps:
- name: Report
env:
GITHUB_TOKEN: ${{ secrets.GHP_ACCESS_TOKEN }}
run: |
gh workflow run report.yaml --repo DARPA-ASKEM/simulation-integration --ref main
64 changes: 0 additions & 64 deletions .github/workflows/publish.yaml

This file was deleted.

10 changes: 7 additions & 3 deletions docker/docker-bake.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,13 @@ group "default" {
}

# ----------------------------------------------------------------------------------------------------------------------
# Used by the metafile GH action
# DO NOT ADD ANYTHING HERE THIS WILL BE POPULATED DYNAMICALLY
# MAKE SURE THIS IS INHERITED NEAR THE END SO THAT IT DOES NOT GET OVERRIDEN
target "docker-metadata-action" {}

# Removed linux/arm64 for now to ass CI build - Dec 2022
target "_platforms" {
platforms = ["linux/amd64"]
platforms = ["linux/amd64", "linux/arm64"]
}

target "sciml-service-base" {
Expand All @@ -48,6 +51,7 @@ target "sciml-service-base" {
dockerfile = "docker/Dockerfile.api"
}

# NOTE: target name will be used as the name of the image
target "sciml-service" {
inherits = ["_platforms", "sciml-service-base"]
inherits = ["sciml-service-base", "docker-metadata-action", "_platforms"]
}

0 comments on commit 2b95c4c

Please sign in to comment.