Skip to content

Commit

Permalink
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 Aug 30, 2024
1 parent 0c8d947 commit e71090c
Show file tree
Hide file tree
Showing 3 changed files with 110 additions and 58 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/build-buildboxes.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Build buildbox images
on:
push:
branches:
- master
- branch/**
- camh/**

jobs:
build:
name: Check for relevant changes
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: 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 @@ -106,64 +106,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
59 changes: 59 additions & 0 deletions build.assets/buildbox/build-buildbox.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#
# 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 e71090c

Please sign in to comment.