Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ jobs:
context: ./bootkit/
platforms: linux/amd64,linux/arm64
push: true
tags: localhost:5000/tinkerbell/hook-bootkit:0.0
tags: localhost:5000/tinkerbell/hook-bootkit:latest

- name: Build and push tink-docker
uses: docker/build-push-action@v3
with:
context: ./tink-docker/
platforms: linux/amd64,linux/arm64
push: true
tags: localhost:5000/tinkerbell/hook-docker:0.0
tags: localhost:5000/tinkerbell/hook-docker:latest

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

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

- run: ./hack/ci-build.sh
env:
LINUXKIT_CONFIG: hook-ci.yaml
GIT_VERSION: ${{ github.sha }}
- name: Build
run: ./hack/ci-build.sh

# TODO: add artifacts for the built images
- uses: actions/upload-artifact@v3
Expand Down
11 changes: 6 additions & 5 deletions .github/workflows/push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ jobs:
context: ./bootkit/
platforms: linux/amd64,linux/arm64
push: ${{ github.actor != 'dependabot[bot]' }}
tags: quay.io/tinkerbell/hook-bootkit:0.0
tags: quay.io/tinkerbell/hook-bootkit:latest,quay.io/tinkerbell/hook-bootkit:sha-${GITHUB_SHA::8}

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

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

- run: ./hack/build-and-deploy.sh
env:
GIT_VERSION: ${{ github.sha }}
- name: Build & Deploy
run: |
./hack/build-and-deploy.sh
TAG=sha-${GITHUB_SHA::8} ./hack/build-and-deploy.sh

- uses: actions/upload-artifact@v3
with:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ bootkit/local/
dist/
.env
hook-*.tar.gz
hook.yaml
out/
*.swp
tink-docker/local/
50 changes: 27 additions & 23 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
ORG ?= quay.io/tinkerbell
ARCH := $(shell uname -m)

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

LINUXKIT_CONFIG ?= hook.yaml

dev: dev-bootkitBuild dev-tink-dockerBuild
ifeq ($(ARCH),x86_64)
dev: dev-image-amd64
Expand All @@ -20,21 +18,27 @@ endif
# This option is for running docker manifest command
export DOCKER_CLI_EXPERIMENTAL := enabled

image-amd64:
LINUXKIT_CONFIG ?= hook.in.yaml
.PHONY: hook.yaml
hook.yaml: $(LINUXKIT_CONFIG)
sed '/quay.io/ s|:latest|:$(TAG)|' $^ > $@.tmp
mv $@.tmp $@

image-amd64: hook.yaml
mkdir -p out
linuxkit build -docker -pull -format kernel+initrd -name hook-x86_64 -dir out $(LINUXKIT_CONFIG)
linuxkit build -docker -pull -format kernel+initrd -name hook-x86_64 -dir out hook.yaml

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

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

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

image: image-amd64 image-arm64

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

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

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

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

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

dev-convert:
rm -rf ./convert
Expand All @@ -92,7 +96,7 @@ dist: default convert
mv ./out/hook-$$a-kernel ./dist/vmlinuz-$$a; \
done
rm -rf out
cd ./dist && tar -czvf ../hook-${GIT_VERSION}.tar.gz ./*
cd ./dist && tar -czvf ../hook-${TAG}.tar.gz ./*

dist-existing-images: image convert
rm -rf ./dist ./convert
Expand All @@ -102,7 +106,7 @@ dist-existing-images: image convert
mv ./out/hook-$$a-kernel ./dist/vmlinuz-$$a; \
done
rm -rf out
cd ./dist && tar -czvf ../hook-${GIT_VERSION}.tar.gz ./*
cd ./dist && tar -czvf ../hook-${TAG}.tar.gz ./*


dev-dist: dev dev-convert
Expand All @@ -111,17 +115,17 @@ dev-dist: dev dev-convert
mv ./initramfs-${ARCH}.gz ./dist/initramfs-${ARCH}
mv ./out/hook-${ARCH}-kernel ./dist/vmlinuz-${ARCH}
rm -rf out
cd ./dist && tar -czvf ../hook-${GIT_VERSION}.tar.gz ./*
cd ./dist && tar -czvf ../hook-${TAG}.tar.gz ./*

deploy: dist
ifeq ($(shell git rev-parse --abbrev-ref HEAD),main)
s3cmd sync ./hook-${GIT_VERSION}.tar.gz s3://s.gianarb.it/hook/${GIT_VERSION}.tar.gz
s3cmd cp s3://s.gianarb.it/hook/hook-${GIT_VERSION}.tar.gz s3://s.gianarb.it/hook/hook-main.tar.gz
s3cmd sync ./hook-${TAG}.tar.gz s3://s.gianarb.it/hook/${TAG}.tar.gz
s3cmd cp s3://s.gianarb.it/hook/hook-${TAG}.tar.gz s3://s.gianarb.it/hook/hook-main.tar.gz
endif

.PHONY: clean
clean:
rm ./hook-${GIT_VERSION}.tar.gz
rm ./hook-${TAG}.tar.gz
rm -rf dist/ out/ tink-docker/local/ bootkit/local/

-include lint.mk
6 changes: 4 additions & 2 deletions hook.yaml → hook.in.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ services:
image: linuxkit/openntpd:v0.8
binds:
- /var/run:/var/run

- name: docker
image: quay.io/tinkerbell/hook-docker:0.0
image: quay.io/tinkerbell/hook-docker:latest
capabilities:
- all
net: host
Expand All @@ -63,8 +64,9 @@ services:
- /var/run/images
- /var/run/docker
- /var/run/worker

- name: bootkit
image: quay.io/tinkerbell/hook-bootkit:0.0
image: quay.io/tinkerbell/hook-bootkit:latest
capabilities:
- all
net: host
Expand Down