Skip to content

Commit

Permalink
[v15] WIP: ci: Build buildox-ng on GitHub push events
Browse files Browse the repository at this point in the history
Rebuild buildbox-ng and/or buildbox-thirdparty on changes to the files
that define those buildboxes when pushes on master or a release branch
are done.
  • Loading branch information
camscale committed Sep 24, 2024
1 parent 681861d commit 825d1d7
Show file tree
Hide file tree
Showing 3 changed files with 130 additions and 58 deletions.
64 changes: 64 additions & 0 deletions .github/workflows/build-buildboxes.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Build buildbox images
on:
push:
branches:
- master
- branch/**
- camh/**

jobs:
build:
name: Build buildboxes
runs-on: ubuntu-22.04-32core
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Check changes
id: changes
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
with:
base: ${{ github.ref }}
filters: |
buildbox:
- 'build.assets/versions.mk'
- 'build.assets/images.mk'
- 'build.assets/buildbox/Dockerfile'
- 'build.assets/buildbox/clang-12.sh'
thirdparty:
- 'build.assets/images.mk'
- 'build.assets/buildbox/Dockerfile-thirdparty'
- 'build.assets/buildbox/build-buildbox.mk'
- 'build.assets/buildbox/buildbox-common.mk'
- 'build.assets/buildbox/cross-compile.mk'
- 'build.assets/buildbox/crosstoolng-configs/**'
- 'build.assets/buildbox/crosstoolng.mk'
- 'build.assets/buildbox/pkgconfg/**'
- 'build.assets/buildbox/thirdparty-libs.mk'
- name: Set up Docker Buildx
if: steps.changes.outputs.thirdparty || steps.changes.outputs.buildbox
uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb # v3.3.0
with:
driver: docker

- name: Login to registry
if: steps.changes.outputs.thirdparty || steps.changes.outputs.buildbox
uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446 # v3.2.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build buildbox-thirdparty
if: steps.changes.outputs.thirdparty
run:
make -C build.assets buildbox-thirdparty PUSH=1

- name: Build buildbox-ng
if: steps.changes.outputs.thirdparty || steps.changes.outputs.buildbox
run:
make -C build.assets buildbox-ng PUSH=1
59 changes: 1 addition & 58 deletions build.assets/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -109,64 +109,7 @@ build-binaries-fips: buildbox-centos7-fips webassets
docker run $(DOCKERFLAGS) $(NOROOT) $(BUILDBOX_CENTOS7_FIPS) \
make -C $(SRCDIR)/e ADDFLAGS='$(ADDFLAGS)' VERSION=$(VERSION) GITTAG=v$(VERSION) PIV=$(PIV) FIPS=yes clean full

#
# Build the buildbox thirdparty components. This rarely needs to be rebuilt and is
# slow to build, so it is done separately from the main buildbox
#
.PHONY: buildbox-thirdparty
buildbox-thirdparty:
docker buildx build \
--cache-from $(BUILDBOX_THIRDPARTY) \
--cache-to type=inline \
$(if $(PUSH),--push,--load) \
--tag $(BUILDBOX_THIRDPARTY) \
-f buildbox/Dockerfile-thirdparty \
buildbox

#
# A generic build rule to build a stage of Dockerfile-thirdparty based
# on the $(STAGE) variable. These stage builds are used for development
# of the thirdparty buildbox, whether to configure crosstool-NG
# (see config/buildbox-ng), or when adding additional third party
# libraries using either the compilers stage or libs stage.
#
.PHONY: buildbox-thirdparty-stage
buildbox-thirdparty-stage:
docker buildx build \
--load \
--tag buildbox-thirdparty-$(STAGE):$(BUILDBOX_VERSION) \
-f buildbox/Dockerfile-thirdparty \
--target $(STAGE) \
buildbox

.PHONY: buildbox-thirdparty-crosstoolng
buildbox-thirdparty-crosstoolng: STAGE=crosstoolng
buildbox-thirdparty-crosstoolng: buildbox-thirdparty-stage

.PHONY: buildbox-thirdparty-compilers
buildbox-thirdparty-compilers: STAGE=compilers
buildbox-thirdparty-compilers: buildbox-thirdparty-stage

.PHONY: buildbox-thirdparty-libs
buildbox-thirdparty-libs: STAGE=libs
buildbox-thirdparty-libs: buildbox-thirdparty-stage

#
# Build the buildbox-ng using the pre-built third party components from the
# buildbox-thirdparty image
#
.PHONY: buildbox-ng
buildbox-ng:
docker buildx build \
--build-arg THIRDPARTY_IMAGE=$(BUILDBOX_THIRDPARTY) \
--build-arg GOLANG_VERSION=$(GOLANG_VERSION) \
--build-arg RUST_VERSION=$(RUST_VERSION) \
--cache-from $(BUILDBOX_NG) \
--cache-to type=inline \
$(if $(PUSH),--push,--load) \
--tag $(BUILDBOX_NG) \
-f buildbox/Dockerfile \
buildbox
include buildbox/build-buildbox.mk

# Builds a Docker container which is used for building official Teleport binaries
# If running in CI and there is no image with the buildbox name:tag combination present locally,
Expand Down
65 changes: 65 additions & 0 deletions build.assets/buildbox/build-buildbox.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# This makefile fragment is included in build.assets/Makefile.
# It depends on these already being included:
# * build.assets/version.mk (for GOLANG_VERSION AND RUST_VERSION)
# * build.assets/images.mk (for BUILDBOX_NG and BUILDBOX_THIRDPARTY)


#
# Build the buildbox-ng using the pre-built third party components from the
# buildbox-thirdparty image
#
.PHONY: buildbox-ng
buildbox-ng:
docker buildx build \
--build-arg THIRDPARTY_IMAGE=$(BUILDBOX_THIRDPARTY) \
--build-arg GOLANG_VERSION=$(GOLANG_VERSION) \
--build-arg RUST_VERSION=$(RUST_VERSION) \
--cache-from $(BUILDBOX_NG) \
--cache-to type=inline \
$(if $(PUSH),--push,--load) \
--tag $(BUILDBOX_NG) \
-f buildbox/Dockerfile \
buildbox

#
# Build the buildbox thirdparty components. This rarely needs to be rebuilt and is
# slow to build, so it is done separately from the main buildbox
#
.PHONY: buildbox-thirdparty
buildbox-thirdparty:
docker buildx build \
--cache-from $(BUILDBOX_THIRDPARTY) \
--cache-to type=inline \
$(if $(PUSH),--push,--load) \
--tag $(BUILDBOX_THIRDPARTY) \
-f buildbox/Dockerfile-thirdparty \
buildbox

#
# A generic build rule to build a stage of Dockerfile-thirdparty based
# on the $(STAGE) variable. These stage builds are used for development
# of the thirdparty buildbox, whether to configure crosstool-NG
# (see config/buildbox-ng), or when adding additional third party
# libraries using either the compilers stage or libs stage.
#
.PHONY: buildbox-thirdparty-stage
buildbox-thirdparty-stage:
docker buildx build \
--load \
--tag buildbox-thirdparty-$(STAGE):$(BUILDBOX_VERSION) \
-f buildbox/Dockerfile-thirdparty \
--target $(STAGE) \
buildbox

.PHONY: buildbox-thirdparty-crosstoolng
buildbox-thirdparty-crosstoolng: STAGE=crosstoolng
buildbox-thirdparty-crosstoolng: buildbox-thirdparty-stage

.PHONY: buildbox-thirdparty-compilers
buildbox-thirdparty-compilers: STAGE=compilers
buildbox-thirdparty-compilers: buildbox-thirdparty-stage

.PHONY: buildbox-thirdparty-libs
buildbox-thirdparty-libs: STAGE=libs
buildbox-thirdparty-libs: buildbox-thirdparty-stage

0 comments on commit 825d1d7

Please sign in to comment.