Skip to content

Commit ed434d2

Browse files
committed
feat: add vyos script, general cleanup/updates
1 parent 7439848 commit ed434d2

13 files changed

Lines changed: 563 additions & 188 deletions

File tree

.github/workflows/image-build.yml

Lines changed: 34 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,16 @@ jobs:
2929
/opt/minimega/bin/miniccc
3030
/opt/minimega/bin/minirouter
3131
32-
# Job: Build the bennu image using the phenix image builder
33-
build-bennu:
32+
# Job: Build images using the phenix image builder
33+
build-images:
34+
strategy:
35+
matrix:
36+
build: [bookworm, kali, jammy, noble, bennu, docker-hello-world, ntp]
3437
needs: get-miniccc
3538
runs-on: ubuntu-latest
3639
container:
37-
image: ghcr.io/sandialabs/sceptre-phenix/phenix:31ce034
40+
image: ghcr.io/sandialabs/sceptre-phenix/phenix:main
3841
options: --privileged # needed for kernel device-mapper permissions
39-
4042
steps:
4143
# Install oras CLI for pushing images to OCI registries
4244
- name: oras install
@@ -48,140 +50,71 @@ jobs:
4850
uses: actions/download-artifact@v4.1.8
4951
with:
5052
name: miniexes
51-
52-
# Add the miniccc binary to the overlay for image build
53-
# The systemd service is already included in base scripts
53+
# Add the miniccc binary to the filesystem for image build. This is used
54+
# at the end of the image builds via `phenix image inject-miniexe ...`
5455
- name: add miniccc
5556
run: |
56-
mkdir -p ./overlays/miniccc/opt/minimega/bin
57-
cp ./miniccc ./overlays/miniccc/opt/minimega/bin
58-
chmod +x ./overlays/miniccc/opt/minimega/bin/miniccc
59-
60-
# Build the bennu image using phenix
61-
- name: bennu image build
62-
run: |
63-
phenix version
64-
mkdir ./out
65-
phenix image create -O ./overlays/bennu,./overlays/brash,./overlays/miniccc -T ./scripts/aptly,./scripts/bennu --format qcow2 --release jammy -c bennu --size 10G
66-
phenix image build bennu -o ./out -x
67-
68-
# Optionally upload bennu.qc2 as artifact (currently commented out)
69-
# - name: upload qc2
70-
# uses: actions/upload-artifact@v4
71-
# with:
72-
# name: bennu.qc2
73-
# path: ./out/bennu.qc2
74-
57+
mkdir /phenix/
58+
cp ./miniccc /phenix/
59+
chmod +x /phenix/miniccc
60+
# Build the image using phenix
61+
- name: ${{ matrix.build }} image build
62+
run: make ${{ matrix.build }}
7563
# Publish the built image to GitHub Container Registry using oras
7664
- name: publish package with oras
7765
# Only push package if on the default branch (e.g., main)
7866
if: github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
7967
shell: bash
8068
run: |
81-
cd ./out
8269
oras login -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }} ghcr.io
83-
oras push "ghcr.io/${{ github.repository }}/bennu.qc2:${GITHUB_SHA:0:7}" bennu.qc2
70+
oras push "ghcr.io/${{ github.repository }}/bennu.qc2:${GITHUB_SHA:0:7}" ${{ matrix.build }}.qc2
8471
85-
# Job: Build the ubuntu image using the phenix image builder
86-
build-ubuntu:
87-
needs: get-miniccc
88-
runs-on: ubuntu-latest
89-
container:
90-
image: ghcr.io/sandialabs/sceptre-phenix/phenix:31ce034
91-
options: --privileged # needed for kernel device-mapper permissions
92-
93-
steps:
94-
# Install oras CLI
95-
- name: oras install
96-
uses: oras-project/setup-oras@v1
97-
# Checkout repository code
98-
- uses: actions/checkout@v4
99-
# Download miniexes artifact
100-
- name: get miniexes
101-
uses: actions/download-artifact@v4.1.8
102-
with:
103-
name: miniexes
104-
105-
# Add the miniccc binary to the overlay for image build
106-
- name: add miniccc
107-
run: |
108-
mkdir -p ./overlays/miniccc/opt/minimega/bin
109-
cp ./miniccc ./overlays/miniccc/opt/minimega/bin
110-
chmod +x ./overlays/miniccc/opt/minimega/bin/miniccc
111-
112-
# Build the ubuntu image using phenix
113-
- name: ubuntu image build
114-
run: |
115-
phenix version
116-
mkdir ./out
117-
phenix image create -O ./overlays/miniccc -T ./scripts/ubuntu,./scripts/ubuntu-user --format qcow2 --release noble -c ubuntu --size 10G
118-
phenix image build ubuntu -o ./out -x
119-
120-
# Optionally upload ubuntu.qc2 as artifact (currently commented out)
121-
# - name: upload qc2
122-
# uses: actions/upload-artifact@v4
123-
# with:
124-
# name: ubuntu.qc2
125-
# path: ./out/ubuntu.qc2
126-
127-
# Publish the built image to GitHub Container Registry using oras
128-
- name: publish package with oras
129-
# Only push package if on the default branch (e.g., main)
130-
if: github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
131-
shell: bash
132-
run: |
133-
cd ./out
134-
oras login -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }} ghcr.io
135-
oras push "ghcr.io/${{ github.repository }}/ubuntu.qc2:${GITHUB_SHA:0:7}" ubuntu.qc2
136-
137-
# Job: Tag and release images after successful builds
138-
release:
72+
# Job: Tag images after successful builds
73+
tag-images:
74+
strategy:
75+
matrix:
76+
build: [bookworm, kali, jammy, noble, bennu, docker-hello-world, ntp]
13977
# Only run on main branch for scheduled or manual workflow_dispatch events
14078
if: github.ref == format('refs/heads/{0}', github.event.repository.default_branch) && (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch')
141-
needs:
142-
- build-bennu
143-
- build-ubuntu
79+
needs: build-images
14480
runs-on: ubuntu-latest
81+
outputs:
82+
date: ${{ steps.date.outputs.value }}
14583
steps:
14684
# Get current date for tagging
14785
- name: Get current date
14886
id: date
14987
run: echo "date=$(date +'%Y%m%d')" >> $GITHUB_OUTPUT
150-
# Download built images from artifacts (if uploaded)
151-
# Not needed with oras push, but kept for reference
152-
# - name: get images from artifacts
153-
# uses: actions/download-artifact@v4.1.8
154-
# with:
155-
# pattern: "*.qc2"
156-
# path: ./images
157-
# merge-multiple: true
158-
15988
# Install oras CLI
16089
- name: oras install
16190
uses: oras-project/setup-oras@v1
162-
16391
# Tag images in the registry with 'latest' and date-based tags
16492
- name: tag images with date and latest
16593
run: |
16694
oras version
16795
oras login -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }} ghcr.io
168-
oras tag ghcr.io/${{ github.repository }}/bennu.qc2:${GITHUB_SHA:0:7} latest ${{ steps.date.outputs.date }}
169-
oras tag ghcr.io/${{ github.repository }}/ubuntu.qc2:${GITHUB_SHA:0:7} latest ${{ steps.date.outputs.date }}
96+
oras tag ghcr.io/${{ github.repository }}/${{ matrix.build }}.qc2:${GITHUB_SHA:0:7} latest ${{ steps.date.outputs.date }}
17097
98+
# Job: Create release successful build
99+
release:
100+
# Only run on main branch for scheduled or manual workflow_dispatch events
101+
if: github.ref == format('refs/heads/{0}', github.event.repository.default_branch) && (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch')
102+
needs: tag-images
103+
runs-on: ubuntu-latest
104+
steps:
171105
# Create a GitHub release with notes and usage instructions
172106
- name: create release
173107
uses: ncipollo/release-action@v1.15.0
174108
with:
175-
name: release-${{ steps.date.outputs.date }}
109+
name: release-${{ needs.tag-images.outputs.date }}
176110
body: |
177111
Images can be downloaded from the registry using the oras client: https://oras.land/docs/installation
178112
e.g.:
179-
```
113+
```bash
180114
oras pull ghcr.io/${{ github.repository }}/bennu.qc2:latest
181115
```
182116
You can view the available image builds from the [Package List](https://github.com/orgs/${{ github.repository_owner }}/packages?repo_name=${{ github.event.repository.name }})
183-
184-
tag: release-${{ steps.date.outputs.date }}
117+
tag: release-${{ needs.tag-images.outputs.date }}
185118
commit: main
186119
generateReleaseNotes: true
187120
makeLatest: true

.github/workflows/release-cleanup.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ jobs:
1818
keep_latest_days: 90
1919

2020
cleanup-old-images:
21+
strategy:
22+
matrix:
23+
build: [bookworm, kali, jammy, noble, bennu, docker-hello-world, ntp]
2124
name: Delete Untagged Images
2225
runs-on: ubuntu-latest
2326
permissions:
@@ -26,6 +29,6 @@ jobs:
2629
- uses: dataaxiom/ghcr-cleanup-action@v1
2730
with:
2831
older-than: 90 day
29-
packages: sceptre-phenix-images/bennu.qc2,sceptre-phenix-images/ubuntu.qc2
32+
packages: sceptre-phenix-images/${{ matrix.build }}.qc2
3033
keep-n-tagged: 5
31-
exclude-tags: latest
34+
exclude-tags: latest

Makefile

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
.PHONY: help check_clean bookworm kali jammy noble bennu docker-hello-world ntp clean
2+
3+
.ONESHELL: # for heredoc and exit
4+
5+
PHENIX=docker exec -t phenix phenix
6+
PHENIX_IMAGE_BUILD=$(PHENIX) image build -o /phenix/vmdb2 -c -x
7+
CHECK_IMAGE=if $(PHENIX) cfg list | grep Image | awk '{print $$6}' | grep "^$(@)$$" >/dev/null; then echo "\n\tphenix image already exists: '$(@)' - run 'phenix image delete $(@)' first\n"; exit; fi
8+
INJECT_MINICCC=if test -f $(@).qc2; then $(PHENIX) image inject-miniexe /phenix/miniccc /phenix/vmdb2/$(@).qc2; echo "----- Injected miniccc into $(@).qc2 -----"; fi
9+
COMPRESS=-c
10+
11+
# Show this help
12+
help:
13+
@cat $(MAKEFILE_LIST) | docker run --rm -i xanders/make-help
14+
15+
check_clean:
16+
@echo -n "Are you sure you want to delete [*.log *.qc2 *.tar *.vmdb]? [y/N] " && read ans && [ $${ans:-N} = y ]
17+
18+
##
19+
## --------------------------------------- Vanilla image builds ---------------------------------------
20+
##
21+
22+
# Build bookworm.qc2 -- Debian Bookworm, GUI
23+
bookworm:
24+
@$(CHECK_IMAGE)
25+
@$(PHENIX) image create -r bookworm -v mingui $(COMPRESS) $(@)
26+
@$(PHENIX_IMAGE_BUILD) $(@)
27+
@$(INJECT_MINICCC)
28+
29+
# Build kali.qc2 -- Kali, GUI
30+
kali:
31+
@$(CHECK_IMAGE)
32+
@$(PHENIX) image create -P kali-tools-top10 -r kali-rolling -v mingui $(COMPRESS) $(@)
33+
@$(PHENIX_IMAGE_BUILD) $(@)
34+
@$(INJECT_MINICCC)
35+
36+
# Build jammy.qc2 -- Ubuntu Jammy, GUI
37+
jammy:
38+
@$(CHECK_IMAGE)
39+
@$(PHENIX) image create -v mingui $(COMPRESS) $(@)
40+
@$(PHENIX_IMAGE_BUILD) $(@)
41+
@$(INJECT_MINICCC)
42+
43+
# Build noble.qc2 -- Ubuntu Noble, GUI
44+
noble:
45+
@$(CHECK_IMAGE)
46+
@$(PHENIX) image create -r noble -v mingui $(COMPRESS) $(@)
47+
@$(PHENIX_IMAGE_BUILD) $(@)
48+
@$(INJECT_MINICCC)
49+
50+
##
51+
## ------------------------------------- Experiment image builds --------------------------------------
52+
##
53+
54+
# Build bennu.qc2 -- Ubuntu Jammy, bennu, brash
55+
bennu:
56+
@$(CHECK_IMAGE)
57+
@$(PHENIX) image create -O /phenix/vmdb2/overlays/bennu,/phenix/vmdb2/overlays/brash -T /phenix/vmdb2/scripts/atomic/aptly.sh,/phenix/vmdb2/scripts/bennu $(COMPRESS) $(@)
58+
@$(PHENIX_IMAGE_BUILD) $(@)
59+
@$(INJECT_MINICCC)
60+
61+
# Build docker-hello-world.qc2 -- Ubuntu Jammy, Docker hello-world
62+
docker-hello-world:
63+
@$(CHECK_IMAGE)
64+
@$(PHENIX) image create -T /phenix/vmdb2/scripts/atomic/docker.sh $(COMPRESS) $(@)
65+
@$(PHENIX_IMAGE_BUILD) $(@)
66+
67+
# Build ntp.qc2 -- Ubuntu Jammy, ntpd
68+
ntp:
69+
@$(CHECK_IMAGE)
70+
@$(PHENIX) image create -P ntp $(COMPRESS) $(@)
71+
@$(PHENIX_IMAGE_BUILD) $(@)
72+
@$(INJECT_MINICCC)
73+
74+
##
75+
## ------------------------------------------ Administration ------------------------------------------
76+
##
77+
78+
# Delete files [*.log *.qc2 *.tar *.vmdb]
79+
clean: check_clean
80+
@echo "Deleting *.log *.qc2 *.tar *.vmdb..."
81+
rm -f *.log *.qc2 *.tar *.vmdb

0 commit comments

Comments
 (0)