-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add multiarch container build (#738)
* add multiarch container build * update changelog --------- Co-authored-by: Jörg Zimmermann <[email protected]>
- Loading branch information
Showing
4 changed files
with
78 additions
and
37 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,6 @@ htmlcov | |
logs | ||
coverage.xml | ||
notebooks | ||
|
||
examples | ||
target | ||
logprep.egg-info |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,15 +14,37 @@ on: | |
|
||
jobs: | ||
containerbuild: | ||
timeout-minutes: 20 | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: ["3.11", "3.12", "3.13"] | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Set up SSH | ||
uses: MrSquaare/ssh-setup-action@v3 | ||
with: | ||
host: ${{ secrets.DOCKER_BUILD_SERVER_01 }} | ||
private-key: ${{ secrets.DOCKER_BUILD_SERVER_IDENTITY_FILE }} | ||
|
||
- name: Set up SSH | ||
uses: MrSquaare/ssh-setup-action@v3 | ||
with: | ||
host: ${{ secrets.DOCKER_BUILD_SERVER_02 }} | ||
private-key: ${{ secrets.DOCKER_BUILD_SERVER_IDENTITY_FILE }} | ||
|
||
- name: Set up Docker | ||
uses: docker/setup-docker-action@v4 | ||
with: | ||
daemon-config: | | ||
{ | ||
"features": { | ||
"containerd-snapshotter": true | ||
} | ||
} | ||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v2 | ||
|
@@ -44,42 +66,44 @@ jobs: | |
file.write(f"tags={', '.join(full_image)}") | ||
EOF | ||
- name: Build image and export to Docker | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
with: | ||
driver: docker-container | ||
platforms: linux/amd64 | ||
append: | | ||
- endpoint: ssh://root@${{ secrets.DOCKER_BUILD_SERVER_01 }} | ||
platforms: linux/arm64 | ||
- endpoint: ssh://root@${{ secrets.DOCKER_BUILD_SERVER_02 }} | ||
platforms: linux/arm64 | ||
- name: Build image and push to registry | ||
uses: docker/build-push-action@v6 | ||
id: build | ||
id: build-and-push | ||
with: | ||
context: . | ||
load: true | ||
push: true | ||
build-args: | | ||
LOGPREP_VERSION=${{ inputs.build-version }} | ||
PYTHON_VERSION=${{ matrix.python-version }} | ||
tags: ${{ steps.image-tag.outputs.tags }} | ||
platforms: "linux/arm64,linux/amd64" | ||
tags: ${{ steps.image-tag.outputs.tags }} | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max | ||
|
||
- name: Extract image ID from sha256 | ||
id: imageid | ||
id: pushed-imageid | ||
run: | | ||
python - <<EOF | ||
import os | ||
digest = "${{ steps.build.outputs.ImageID }}" | ||
imageid = "${{ steps.build-and-push.outputs.ImageID }}" | ||
digest = "${{ steps.build-and-push.outputs.Digest }}" | ||
with open(os.environ['GITHUB_OUTPUT'], 'a') as file: | ||
file.write(f"imageid={digest.split(':')[1]}") | ||
file.write(f"digest={digest.split(':')[1]}") | ||
file.write(f"imageid={imageid.split(':')[1]}") | ||
EOF | ||
- name: Ensure logprep is available in image | ||
run: | | ||
docker run --rm ${{ steps.imageid.outputs.imageid }} --version | ||
- name: Push image | ||
uses: docker/build-push-action@v6 | ||
id: build-and-push | ||
with: | ||
context: . | ||
push: true | ||
build-args: | | ||
LOGPREP_VERSION=${{ inputs.build-version }} | ||
PYTHON_VERSION=${{ matrix.python-version }} | ||
tags: ${{ steps.image-tag.outputs.tags }} | ||
|
||
- name: Install Cosign | ||
uses: sigstore/[email protected] | ||
with: | ||
|
@@ -88,14 +112,14 @@ jobs: | |
- name: Create SBOM of container image | ||
uses: anchore/sbom-action@v0 | ||
with: | ||
image: ghcr.io/fkie-cad/logprep@${{ steps.build-and-push.outputs.digest }} | ||
artifact-name: logprep@${{ steps.imageid.outputs.imageid }}.spdx.json | ||
output-file: logprep@${{ steps.imageid.outputs.imageid }}.spdx.json | ||
image: ghcr.io/fkie-cad/logprep@${{ steps.build-and-push.outputs.Digest }} | ||
artifact-name: logprep@${{ steps.pushed-imageid.outputs.digest }}.spdx.json | ||
output-file: logprep@${{ steps.pushed-imageid.outputs.digest }}.spdx.json | ||
|
||
- name: Sign image with a key and add sbom attestation | ||
run: | | ||
cosign sign --yes --key env://COSIGN_PRIVATE_KEY ghcr.io/fkie-cad/logprep@${{ steps.build-and-push.outputs.digest }} | ||
cosign attest --yes --key env://COSIGN_PRIVATE_KEY --predicate logprep@${{ steps.imageid.outputs.imageid }}.spdx.json ghcr.io/fkie-cad/logprep@${{ steps.build-and-push.outputs.digest }} | ||
cosign attest --yes --key env://COSIGN_PRIVATE_KEY --predicate logprep@${{ steps.pushed-imageid.outputs.digest }}.spdx.json ghcr.io/fkie-cad/logprep@${{ steps.build-and-push.outputs.digest }} | ||
env: | ||
COSIGN_PRIVATE_KEY: ${{ secrets.COSIGN_PRIVATE_KEY }} | ||
COSIGN_PASSWORD: ${{ secrets.COSIGN_PASSWORD }} | ||
|
@@ -116,6 +140,7 @@ jobs: | |
uses: aquasecurity/[email protected] | ||
env: | ||
TRIVY_CACHE_DIR: ./cache | ||
TRIVY_PLATFORM: linux/amd64 | ||
with: | ||
scan-type: image | ||
image-ref: ghcr.io/fkie-cad/logprep@${{ steps.build-and-push.outputs.digest }} | ||
|
This file contains 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
This file contains 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