Skip to content

Commit 4fef8ab

Browse files
committed
Use better tags for bootkit and docker images
By default we'll live with `latest` (instead of 0.0) but be able to specify any tag we want. The idea being we can provide the tag on pushes and set both latest and a per-commit sha-* tag (like all the other service images do). Signed-off-by: Manuel Mendez <github@i.m.mmlb.dev>
1 parent 029ef8f commit 4fef8ab

File tree

5 files changed

+43
-37
lines changed

5 files changed

+43
-37
lines changed

.github/workflows/ci.yaml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ jobs:
3030
context: ./bootkit/
3131
platforms: linux/amd64,linux/arm64
3232
push: true
33-
tags: localhost:5000/tinkerbell/hook-bootkit:0.0
33+
tags: localhost:5000/tinkerbell/hook-bootkit:latest
3434

3535
- name: Build and push tink-docker
3636
uses: docker/build-push-action@v3
3737
with:
3838
context: ./tink-docker/
3939
platforms: linux/amd64,linux/arm64
4040
push: true
41-
tags: localhost:5000/tinkerbell/hook-docker:0.0
41+
tags: localhost:5000/tinkerbell/hook-docker:latest
4242

4343
- uses: cachix/install-nix-action@v17
4444
with:
@@ -51,12 +51,10 @@ jobs:
5151
run: nix-shell --run .github/workflows/formatters-and-linters.sh
5252

5353
# Replace hook-{bootkit,docker} but not hook-kernel
54-
- run: sed -E -e 's,quay.io/tinkerbell/hook-(bootkit|docker),localhost:5000/tinkerbell/hook-\1,g' hook.yaml | tee hook-ci.yaml
54+
- run: sed -E -i 's,quay.io/tinkerbell/hook-(bootkit|docker),localhost:5000/tinkerbell/hook-\1,g' hook.in.yaml
5555

56-
- run: ./hack/ci-build.sh
57-
env:
58-
LINUXKIT_CONFIG: hook-ci.yaml
59-
GIT_VERSION: ${{ github.sha }}
56+
- name: Build
57+
run: ./hack/ci-build.sh
6058

6159
# TODO: add artifacts for the built images
6260
- uses: actions/upload-artifact@v3

.github/workflows/push.yaml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@ jobs:
3131
context: ./bootkit/
3232
platforms: linux/amd64,linux/arm64
3333
push: ${{ github.actor != 'dependabot[bot]' }}
34-
tags: quay.io/tinkerbell/hook-bootkit:0.0
34+
tags: quay.io/tinkerbell/hook-bootkit:latest,quay.io/tinkerbell/hook-bootkit:sha-${GITHUB_SHA::8}
3535

3636
- name: Build and push tink-docker
3737
uses: docker/build-push-action@v3
3838
with:
3939
context: ./tink-docker/
4040
platforms: linux/amd64,linux/arm64
4141
push: ${{ github.actor != 'dependabot[bot]' }}
42-
tags: quay.io/tinkerbell/hook-docker:0.0
42+
tags: quay.io/tinkerbell/hook-docker:latest,quay.io/tinkerbell/hook-docker:sha-${GITHUB_SHA::8}
4343

4444
- uses: cachix/install-nix-action@v17
4545
with:
@@ -51,9 +51,10 @@ jobs:
5151
- name: Run formatters and linters
5252
run: nix-shell --run .github/workflows/formatters-and-linters.sh
5353

54-
- run: ./hack/build-and-deploy.sh
55-
env:
56-
GIT_VERSION: ${{ github.sha }}
54+
- name: Build & Deploy
55+
run: |
56+
./hack/build-and-deploy.sh
57+
TAG=sha-${GITHUB_SHA::8} ./hack/build-and-deploy.sh
5758
5859
- uses: actions/upload-artifact@v3
5960
with:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ bootkit/local/
33
dist/
44
.env
55
hook-*.tar.gz
6+
hook.yaml
67
out/
78
*.swp
89
tink-docker/local/

Makefile

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
ORG ?= quay.io/tinkerbell
22
ARCH := $(shell uname -m)
33

4-
GIT_VERSION ?= $(shell git log -1 --format="%h")
5-
ifneq ($(shell git status --porcelain),)
6-
GIT_VERSION := $(GIT_VERSION)-dirty
4+
ifeq ($(strip $(TAG)),)
5+
# ^ guards against TAG being defined but empty string which makes `TAG ?=` not work
6+
TAG := latest
77
endif
88
default: bootkitBuild tink-dockerBuild image
99

10-
LINUXKIT_CONFIG ?= hook.yaml
11-
1210
dev: dev-bootkitBuild dev-tink-dockerBuild
1311
ifeq ($(ARCH),x86_64)
1412
dev: dev-image-amd64
@@ -20,21 +18,27 @@ endif
2018
# This option is for running docker manifest command
2119
export DOCKER_CLI_EXPERIMENTAL := enabled
2220

23-
image-amd64:
21+
LINUXKIT_CONFIG ?= hook.in.yaml
22+
.PHONY: hook.yaml
23+
hook.yaml: $(LINUXKIT_CONFIG)
24+
sed '/quay.io/ s|:latest|:$(TAG)|' $^ > $@.tmp
25+
mv $@.tmp $@
26+
27+
image-amd64: hook.yaml
2428
mkdir -p out
25-
linuxkit build -docker -pull -format kernel+initrd -name hook-x86_64 -dir out $(LINUXKIT_CONFIG)
29+
linuxkit build -docker -pull -format kernel+initrd -name hook-x86_64 -dir out hook.yaml
2630

27-
image-arm64:
31+
image-arm64: hook.yaml
2832
mkdir -p out
29-
linuxkit build -docker -pull -arch arm64 -format kernel+initrd -name hook-aarch64 -dir out $(LINUXKIT_CONFIG)
33+
linuxkit build -docker -pull -arch arm64 -format kernel+initrd -name hook-aarch64 -dir out hook.yaml
3034

31-
dev-image-amd64:
35+
dev-image-amd64: hook.yaml
3236
mkdir -p out
33-
linuxkit build -docker -format kernel+initrd -name hook-x86_64 -dir out $(LINUXKIT_CONFIG)
37+
linuxkit build -docker -format kernel+initrd -name hook-x86_64 -dir out hook.yaml
3438

35-
dev-image-arm64:
39+
dev-image-arm64: hook.yaml
3640
mkdir -p out
37-
linuxkit build -docker -arch arm64 -format kernel+initrd -name hook-aarch64 -dir out $(LINUXKIT_CONFIG)
41+
linuxkit build -docker -arch arm64 -format kernel+initrd -name hook-aarch64 -dir out hook.yaml
3842

3943
image: image-amd64 image-arm64
4044

@@ -58,16 +62,16 @@ run:
5862
sudo ~/go/bin/linuxkit run qemu --mem 2048 out/hook-${ARCH}
5963

6064
dev-bootkitBuild:
61-
cd bootkit; docker buildx build --load -t $(ORG)/hook-bootkit:0.0 .
65+
cd bootkit; docker buildx build --load -t $(ORG)/hook-bootkit:$(TAG) .
6266

6367
bootkitBuild:
64-
cd bootkit; docker buildx build --platform linux/amd64,linux/arm64 --push -t $(ORG)/hook-bootkit:0.0 .
68+
cd bootkit; docker buildx build --platform linux/amd64,linux/arm64 --push -t $(ORG)/hook-bootkit:$(TAG) .
6569

6670
dev-tink-dockerBuild:
67-
cd tink-docker; docker buildx build --load -t $(ORG)/hook-docker:0.0 .
71+
cd tink-docker; docker buildx build --load -t $(ORG)/hook-docker:$(TAG) .
6872

6973
tink-dockerBuild:
70-
cd tink-docker; docker buildx build --platform linux/amd64,linux/arm64 --push -t $(ORG)/hook-docker:0.0 .
74+
cd tink-docker; docker buildx build --platform linux/amd64,linux/arm64 --push -t $(ORG)/hook-docker:$(TAG) .
7175

7276
dev-convert:
7377
rm -rf ./convert
@@ -92,7 +96,7 @@ dist: default convert
9296
mv ./out/hook-$$a-kernel ./dist/vmlinuz-$$a; \
9397
done
9498
rm -rf out
95-
cd ./dist && tar -czvf ../hook-${GIT_VERSION}.tar.gz ./*
99+
cd ./dist && tar -czvf ../hook-${TAG}.tar.gz ./*
96100

97101
dist-existing-images: image convert
98102
rm -rf ./dist ./convert
@@ -102,7 +106,7 @@ dist-existing-images: image convert
102106
mv ./out/hook-$$a-kernel ./dist/vmlinuz-$$a; \
103107
done
104108
rm -rf out
105-
cd ./dist && tar -czvf ../hook-${GIT_VERSION}.tar.gz ./*
109+
cd ./dist && tar -czvf ../hook-${TAG}.tar.gz ./*
106110

107111

108112
dev-dist: dev dev-convert
@@ -111,17 +115,17 @@ dev-dist: dev dev-convert
111115
mv ./initramfs-${ARCH}.gz ./dist/initramfs-${ARCH}
112116
mv ./out/hook-${ARCH}-kernel ./dist/vmlinuz-${ARCH}
113117
rm -rf out
114-
cd ./dist && tar -czvf ../hook-${GIT_VERSION}.tar.gz ./*
118+
cd ./dist && tar -czvf ../hook-${TAG}.tar.gz ./*
115119

116120
deploy: dist
117121
ifeq ($(shell git rev-parse --abbrev-ref HEAD),main)
118-
s3cmd sync ./hook-${GIT_VERSION}.tar.gz s3://s.gianarb.it/hook/${GIT_VERSION}.tar.gz
119-
s3cmd cp s3://s.gianarb.it/hook/hook-${GIT_VERSION}.tar.gz s3://s.gianarb.it/hook/hook-main.tar.gz
122+
s3cmd sync ./hook-${TAG}.tar.gz s3://s.gianarb.it/hook/${TAG}.tar.gz
123+
s3cmd cp s3://s.gianarb.it/hook/hook-${TAG}.tar.gz s3://s.gianarb.it/hook/hook-main.tar.gz
120124
endif
121125

122126
.PHONY: clean
123127
clean:
124-
rm ./hook-${GIT_VERSION}.tar.gz
128+
rm ./hook-${TAG}.tar.gz
125129
rm -rf dist/ out/ tink-docker/local/ bootkit/local/
126130

127131
-include lint.mk

hook.yaml renamed to hook.in.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,9 @@ services:
4141
image: linuxkit/openntpd:v0.8
4242
binds:
4343
- /var/run:/var/run
44+
4445
- name: docker
45-
image: quay.io/tinkerbell/hook-docker:0.0
46+
image: quay.io/tinkerbell/hook-docker:latest
4647
capabilities:
4748
- all
4849
net: host
@@ -63,8 +64,9 @@ services:
6364
- /var/run/images
6465
- /var/run/docker
6566
- /var/run/worker
67+
6668
- name: bootkit
67-
image: quay.io/tinkerbell/hook-bootkit:0.0
69+
image: quay.io/tinkerbell/hook-bootkit:latest
6870
capabilities:
6971
- all
7072
net: host

0 commit comments

Comments
 (0)