Skip to content

Commit

Permalink
Add platforms and load parameters to build_push action
Browse files Browse the repository at this point in the history
Signed-off-by: Daichi Sakaue <[email protected]>
  • Loading branch information
yokaze committed Feb 5, 2025
1 parent 3c01b7e commit 878b67e
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 29 deletions.
30 changes: 12 additions & 18 deletions .github/actions/build_push/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,14 @@ inputs:
yamory_token:
description: "Yamory Access Token"
required: true
enable_arm64:
description: "Add arm64 to container image platform"
platforms:
description: "Target platforms"
required: false
default: "false"
default: ""
load:
description: "Load built image to local docker daemon"
required: false
default: ""
make-targets:
description: "make targets before building docker image"
required: false
Expand Down Expand Up @@ -47,21 +51,11 @@ runs:
with:
dir: ${{ inputs.dir }}
container-image: ${{ inputs.container-image }}
platforms: ${{ inputs.platforms }}
load: ${{ inputs.load }}
target: ${{ inputs.target }}
request-scan: ${{ inputs.request-scan }}
github_token: ${{ inputs.github_token }}
- name: Set container build platform
if: ${{ steps.prepare.outputs.build }}
shell: bash
run: |
enable_arm64=${{ inputs.enable_arm64 }}
if [ "$enable_arm64" = "true" ]; then
echo "PLATFORM=linux/amd64,linux/arm64" >> $GITHUB_ENV
echo "DOCKER_LOAD=false" >> $GITHUB_ENV
else
echo "PLATFORM=linux/amd64" >> $GITHUB_ENV
echo "DOCKER_LOAD=true" >> $GITHUB_ENV
fi
- name: Make pre-targets
if: ${{ inputs.make-targets != '' && steps.prepare.outputs.build }}
shell: bash
Expand All @@ -75,8 +69,8 @@ runs:
uses: docker/build-push-action@v5
with:
context: ${{ inputs.dir }}
load: ${{ env.DOCKER_LOAD }}
platforms: ${{ env.PLATFORM }}
platforms: ${{ steps.prepare.outputs.platforms }}
load: ${{ steps.prepare.outputs.load }}
provenance: false
push: false
tags: |
Expand All @@ -98,7 +92,7 @@ runs:
uses: docker/build-push-action@v5
with:
context: ${{ inputs.dir }}
platforms: ${{ env.PLATFORM }}
platforms: ${{ steps.prepare.outputs.platforms }}
provenance: false
push: ${{ steps.prepare.outputs.docker_push }}
tags: |
Expand Down
28 changes: 28 additions & 0 deletions .github/actions/prepare_build_params/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ inputs:
container-image:
description: "container image"
required: true
platforms:
description: "Target platforms"
required: false
default: ""
load:
description: "Load built image to local docker daemon"
required: false
default: ""
target:
description: "target name"
required: false
Expand All @@ -26,9 +34,15 @@ outputs:
tag:
description: "tag"
value: ${{ steps.extract.outputs.tag }}
platforms:
description: "Target platforms"
value: ${{ steps.flags.outputs.platforms }}
build:
description: "build is needed (true or '')"
value: ${{ steps.flags.outputs.build }}
load:
description: "Load built image to local docker daemon"
value: ${{ steps.flags.outputs.load }}
push:
description: "push is needed (true or '')"
value: ${{ steps.flags.outputs.push }}
Expand Down Expand Up @@ -90,6 +104,18 @@ runs:
else
echo "docker_push=false" >> $GITHUB_OUTPUT
fi
if [ -z "${{ inputs.platforms }}" ]; then
echo "platforms=linux/amd64" >> $GITHUB_OUTPUT
else
echo "platforms=${{ inputs.platforms }}" >> $GITHUB_OUTPUT
fi
if [ "${{ inputs.load }}" = "true" ]; then
echo "load=true" >> $GITHUB_OUTPUT
else
echo "load=false" >> $GITHUB_OUTPUT
fi
env:
EVENT_NAME: ${{ github.event_name }}
- id: scan-pre
Expand Down Expand Up @@ -158,7 +184,9 @@ runs:
echo
echo " branch: ${{ steps.extract.outputs.branch }}"
echo " tag: ${{ steps.extract.outputs.tag }}"
echo " platforms: ${{ steps.flags.platforms }}"
echo " build: ${{ steps.flags.outputs.build }}"
echo " load: ${{ steps.flags.load }}"
echo " push: ${{ steps.flags.outputs.push }}"
echo " docker_push: ${{ steps.flags.outputs.docker_push }}"
echo " scan: ${{ steps.scan.outputs.scan }}"
Expand Down
16 changes: 11 additions & 5 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ jobs:
make-targets: "check-generate test"
- dir: "./bpftrace"
container-image: "bpftrace"
load: "true"
make-targets: "checkout"
make-post-targets: "test"
- dir: "./cadvisor"
Expand Down Expand Up @@ -93,19 +94,23 @@ jobs:
container-image: "fluent-bit"
- dir: "./golang-all/golang-1.22-jammy"
container-image: "golang"
enable_arm64: true
platforms: "linux/amd64,linux/arm64"
load: "true"
request-scan: "true"
- dir: "./golang-all/golang-1.23-jammy"
container-image: "golang"
enable_arm64: true
platforms: "linux/amd64,linux/arm64"
load: "true"
request-scan: "true"
- dir: "./golang-all/golang-1.22-noble"
container-image: "golang"
enable_arm64: true
platforms: "linux/amd64,linux/arm64"
load: "true"
request-scan: "true"
- dir: "./golang-all/golang-1.23-noble"
container-image: "golang"
enable_arm64: true
platforms: "linux/amd64,linux/arm64"
load: "true"
request-scan: "true"
- dir: "./grafana"
container-image: "grafana"
Expand Down Expand Up @@ -284,7 +289,8 @@ jobs:
yamory_token: ${{ secrets.YAMORY_ACCESS_TOKEN }}
dir: ${{ matrix.job.dir }}
container-image: ${{ matrix.job.container-image }}
enable_arm64: ${{ matrix.job.enable_arm64 }}
platforms: ${{ matrix.job.platforms }}
load: ${{ matrix.job.load }}
make-targets: ${{ matrix.job.make-targets }}
make-post-targets: ${{ matrix.job.make-post-targets }}
request-scan: ${{ matrix.job.request-scan }}
Expand Down
13 changes: 8 additions & 5 deletions bpftrace/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ LIBBPF_TARGET ?= v1.5.0
BPFTRACE_REPO ?= https://github.com/bpftrace/bpftrace.git
BPFTRACE_TARGET ?= v0.22.1

BUILDER_IMAGE_TAG ?= bpftrace-builder:dev
IMAGE_TAG ?= ghcr.io/cybozu/bpftrace:$(shell cat TAG)

.PHONY: checkout-repo
checkout-repo:
@if [ -z "$(CHECKOUT_DIR)" ]; then \
Expand Down Expand Up @@ -42,23 +45,23 @@ clean:

.PHONY: build
build:
docker build . --progress=plain --target builder -t bpftrace-builder:latest
docker build . --progress=plain -t bpftrace:latest
docker build . --progress=plain --target builder -t $(BUILDER_IMAGE_TAG)
docker build . --progress=plain -t $(IMAGE_TAG)

.PHONY: test
test:
docker run --rm bpftrace:latest bpftrace --help
docker run --rm $(IMAGE_TAG) bpftrace --help

.PHONY: try
try:
docker run --rm --privileged --pid=host --net=host \
-v /usr/src:/usr/src:ro \
-v /lib/modules/:/lib/modules:ro \
-v /sys/kernel/debug/:/sys/kernel/debug:rw \
bpftrace:latest bpftrace -l | grep do_nanosleep
$(IMAGE_TAG) bpftrace -l | grep do_nanosleep
@echo
docker run --rm --privileged --pid=host --net=host \
-v /usr/src:/usr/src:ro \
-v /lib/modules/:/lib/modules:ro \
-v /sys/kernel/debug/:/sys/kernel/debug:rw \
bpftrace:latest bpftrace -e 'kprobe:do_nanosleep { printf("%d, %s\n", pid, comm); if (++@x >= 10) { exit(); } }'
$(IMAGE_TAG) bpftrace -e 'kprobe:do_nanosleep { printf("%d, %s\n", pid, comm); if (++@x >= 10) { exit(); } }'
2 changes: 1 addition & 1 deletion golang-all/golang-1.23-noble/TAG
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.23.6.1_noble
1.23.6.2_noble

0 comments on commit 878b67e

Please sign in to comment.