Skip to content

Commit b2c70d3

Browse files
authored
Merge pull request #157 from docker/build-docker-image
build-image
2 parents ba031f8 + cdbe3ee commit b2c70d3

3 files changed

Lines changed: 48 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ permissions:
33
contents: read
44

55
on:
6+
workflow_dispatch:
67
push:
78
branches: [main]
89
tags: ["v*"]
@@ -95,3 +96,41 @@ jobs:
9596
TELEMETRY_API_KEY: ${{ secrets.TELEMETRY_API_KEY }}
9697
TELEMETRY_ENDPOINT: ${{ secrets.TELEMETRY_ENDPOINT }}
9798
TELEMETRY_HEADER: ${{ secrets.TELEMETRY_HEADER }}
99+
100+
build-image:
101+
if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch'
102+
needs: [build]
103+
runs-on: ubuntu-latest
104+
steps:
105+
- name: Checkout
106+
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
107+
108+
- name: Set up QEMU
109+
uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3.6.0
110+
111+
- name: Hub login
112+
if: github.event_name != 'pull_request'
113+
uses: docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1 # v3.5.0
114+
with:
115+
username: ${{ vars.DOCKERBUILDBOT_USERNAME }}
116+
password: ${{ secrets.DOCKERBUILDBOT_WRITE_PAT }}
117+
118+
- name: Set up Docker Buildx
119+
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1
120+
121+
- name: Docker metadata
122+
id: meta
123+
uses: docker/metadata-action@c1e51972afc2121e065aed6d45c65596fe445f3f # v5.8.0
124+
with:
125+
images: docker/cagent
126+
127+
- name: Build and push image
128+
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
129+
with:
130+
context: .
131+
push: ${{ github.event_name != 'pull_request' }}
132+
sbom: true
133+
provenance: mode=max
134+
tags: ${{ steps.meta.outputs.tags }}
135+
labels: ${{ steps.meta.outputs.labels }}
136+
build-args: GIT_COMMIT=${{ github.sha }}

Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,3 +84,8 @@ COPY --from=builder /binaries/cagent-$TARGETOS-$TARGETARCH cagent
8484

8585
FROM scratch AS cross
8686
COPY --from=builder /binaries .
87+
88+
FROM alpine:3.22@sha256:4bcff63911fcb4448bd4fdacec207030997caf25e9bea4045fa6c8c44de311d1
89+
RUN apk add --no-cache curl socat
90+
COPY --from=build-agent /agent /
91+
ENTRYPOINT [ "/agent" ]

Taskfile.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,7 @@ tasks:
6363
cross:
6464
desc: Build binaries for multiple platforms
6565
cmd: docker buildx build --target=cross {{.BUILD_ARGS}} --platform linux/amd64,linux/arm64,darwin/amd64,darwin/arm64,windows/amd64 --output=./dist .
66+
67+
build-image:
68+
desc: Build Docker image
69+
cmd: docker buildx build -t docker/cagent:latest {{.BUILD_ARGS}} .

0 commit comments

Comments
 (0)