Skip to content

Commit cca542c

Browse files
committed
feat: build third party images with chainguard
1 parent 7891136 commit cca542c

File tree

3 files changed

+135
-0
lines changed

3 files changed

+135
-0
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: 'Build and push a dep image with apko'
2+
description: 'Composite action for building and pushing a dep image with apko'
3+
inputs:
4+
apko-config:
5+
description: 'Path to apko config'
6+
required: true
7+
8+
image-name:
9+
description: 'Full destination image name'
10+
required: true
11+
12+
registry-username:
13+
description: 'Username to login to registry'
14+
default: ''
15+
required: false
16+
17+
registry-password:
18+
description: 'Password to login to registry'
19+
default: ''
20+
required: false
21+
22+
overwrite:
23+
description: 'Overwrite the existing image tag'
24+
default: 'false'
25+
required: false
26+
27+
runs:
28+
using: "composite"
29+
steps:
30+
- id: check-image-exists
31+
if: ${{ inputs.overwrite != 'true' }}
32+
shell: bash
33+
run: |
34+
set -euo pipefail
35+
if docker manifest inspect ${{ inputs.image-name }} > /dev/null 2>&1; then
36+
echo "Image already exists. Will not overwrite."
37+
echo "image-exists=true" >> "$GITHUB_OUTPUT"
38+
else
39+
echo "Image does not exist. Will build and push."
40+
echo "image-exists=false" >> "$GITHUB_OUTPUT"
41+
fi
42+
43+
- uses: chainguard-images/actions/apko-publish@main
44+
if: ${{ inputs.overwrite == 'true' || steps.check-image-exists.outputs.image-exists == 'false' }}
45+
with:
46+
config: ${{ inputs.apko-config }}
47+
archs: amd64,arm64
48+
tag: ${{ inputs.image-name }}
49+
vcs-url: true
50+
generic-user: ${{ inputs.registry-username }}
51+
generic-pass: ${{ inputs.registry-password }}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Update image deps
2+
3+
on:
4+
schedule:
5+
- cron: '0 4 * * *'
6+
workflow_dispatch:
7+
inputs:
8+
overwrite:
9+
description: 'Overwrite the existing image tags'
10+
required: false
11+
default: 'true'
12+
push:
13+
branches:
14+
- emosbaugh/sc-108755/use-chainguard-images-for-embedded-cluster
15+
jobs:
16+
build-3rd-party-images:
17+
runs-on: ubuntu-20.04
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
22+
- name: Get tags
23+
id: get-tags
24+
run: |
25+
set -euo pipefail
26+
27+
# We're only using the APKINDEX files to get the versions, so it doesn't matter which arch we use
28+
29+
curl -LO --fail --show-error https://packages.wolfi.dev/os/x86_64/APKINDEX.tar.gz
30+
tar -xzvf APKINDEX.tar.gz
31+
32+
calico_version=$(< APKINDEX grep -A1 "^P:calico$" | tail -n 1 | sed -n -e 's/V://p' | tr -d '\n')
33+
34+
sed "s/__CALICO_VERSION__/$calico_version/g" deploy/images/calico-node/apko.tmpl.yaml > deploy/images/calico-node/apko.yaml
35+
36+
{
37+
echo "calico-tag=$calico_version"
38+
} >> "$GITHUB_OUTPUT"
39+
40+
- name: Build and push calico-node image
41+
uses: ./.github/actions/build-dep-image-with-apko
42+
with:
43+
apko-config: deploy/images/calico-node/apko.yaml
44+
image-name: docker.io/replicated/ec-calico-node:${{ steps.get-tags.outputs.calico-tag }}
45+
registry-username: ${{ secrets.DOCKERHUB_USER }}
46+
registry-password: ${{ secrets.DOCKERHUB_PASSWORD }}
47+
overwrite: ${{ github.event.inputs.overwrite }}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
contents:
2+
repositories:
3+
- https://packages.wolfi.dev/os
4+
keyring:
5+
- https://packages.wolfi.dev/os/wolfi-signing.rsa.pub
6+
packages:
7+
- calico-node=__CALICO_VERSION__
8+
9+
accounts:
10+
groups:
11+
- groupname: nonroot
12+
gid: 65532
13+
users:
14+
- username: nonroot
15+
uid: 65532
16+
gid: 65532
17+
# calico-node is responsible for many host level networking tasks and as such, needs root
18+
run-as: "0"
19+
20+
environment:
21+
# Tell sv where to find the services
22+
SVDIR: /etc/service/enabled
23+
24+
paths:
25+
- path: /etc/service/available
26+
type: directory
27+
uid: 0
28+
gid: 0
29+
permissions: 0o755
30+
- path: /etc/calico
31+
type: directory
32+
uid: 65532
33+
gid: 65532
34+
permissions: 0o755
35+
36+
entrypoint:
37+
command: /usr/sbin/start_runit

0 commit comments

Comments
 (0)