-
Notifications
You must be signed in to change notification settings - Fork 802
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Build image in github actions (#6026)
* Build image in github actions Signed-off-by: Friedrich Gonzalez <friedrichg@gmail.com> * Bug fixes Signed-off-by: Friedrich Gonzalez <friedrichg@gmail.com> * Target master Signed-off-by: Friedrich Gonzalez <friedrichg@gmail.com> * Fix save-multiarch-build-image Signed-off-by: Friedrich Gonzalez <friedrichg@gmail.com> * Include QEMU and buildx action Signed-off-by: Friedrich Gonzalez <friedrichg@gmail.com> * Let's simplify and tests first Signed-off-by: Friedrich Gonzalez <friedrichg@gmail.com> * test push Signed-off-by: Friedrich Gonzalez <friedrichg@gmail.com> * Push intermediate images Signed-off-by: Friedrich Gonzalez <friedrichg@gmail.com> * Re-enable full build, update docs and make sure push is only possible from master Signed-off-by: Friedrich Gonzalez <friedrichg@gmail.com> * Fetch tags and use Makefile in build-image Signed-off-by: Friedrich Gonzalez <friedrichg@gmail.com> --------- Signed-off-by: Friedrich Gonzalez <friedrichg@gmail.com>
- Loading branch information
1 parent
057313a
commit 6dd64fc
Showing
6 changed files
with
98 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
name: Build Image | ||
|
||
on: | ||
push: | ||
branches: [ master ] | ||
paths: | ||
- 'build-image/**' | ||
- '.github/workflows/build-image.yml' | ||
pull_request: | ||
branches: [ master ] | ||
paths: | ||
- 'build-image/**' | ||
- '.github/workflows/build-image.yml' | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-24.04 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
name: Checkout | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Save image | ||
run: make save-multiarch-build-image | ||
|
||
- name: Upload Docker Images Artifacts | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: build-image | ||
path: | | ||
./build-image-amd64.tar | ||
./build-image-arm64.tar | ||
if-no-files-found: error | ||
|
||
push: | ||
needs: build | ||
if: (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/')) && github.repository == 'cortexproject/cortex' | ||
runs-on: ubuntu-24.04 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
name: Checkout | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Download Docker Images Artifacts | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: build-image | ||
|
||
- name: Load image | ||
run: make load-multiarch-build-image | ||
|
||
- name: Login to Quay.io | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: quay.io | ||
username: ${{secrets.QUAY_REGISTRY_USER}} | ||
password: ${{secrets.QUAY_REGISTRY_PASSWORD}} | ||
|
||
- name: Push image | ||
run: make push-multiarch-build-image |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,3 +27,6 @@ Makefile.local | |
.vscode | ||
compose | ||
compose-simple | ||
|
||
/build-image-arm64.tar | ||
/build-image-amd64.tar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
save-multiarch-build-image: | ||
@echo | ||
# Build image for each platform separately... it tends to generate fewer errors. | ||
$(SUDO) docker buildx build --platform linux/amd64 --build-arg=revision=$(GIT_REVISION) --build-arg=goproxyValue=$(GOPROXY_VALUE) -t $(IMAGE_PREFIX)build-image:$(IMAGE_TAG)-amd64 --output type=docker,dest=./build-image-amd64.tar build-image/ | ||
$(SUDO) docker buildx build --platform linux/arm64 --build-arg=revision=$(GIT_REVISION) --build-arg=goproxyValue=$(GOPROXY_VALUE) -t $(IMAGE_PREFIX)build-image:$(IMAGE_TAG)-arm64 --output type=docker,dest=./build-image-arm64.tar build-image/ | ||
|
||
load-multiarch-build-image: | ||
$(SUDO) docker load -i build-image-amd64.tar | ||
$(SUDO) docker load -i build-image-arm64.tar | ||
|
||
push-multiarch-build-image: | ||
# This command will run the same build as multiarch-build-image, but it will reuse existing platform-specific images, | ||
# put them together and push to registry. | ||
$(SUDO) docker push $(IMAGE_PREFIX)build-image:${IMAGE_TAG}-amd64 | ||
$(SUDO) docker push $(IMAGE_PREFIX)build-image:${IMAGE_TAG}-arm64 | ||
$(SUDO) docker manifest create $(IMAGE_PREFIX)build-image:$(IMAGE_TAG) --amend $(IMAGE_PREFIX)build-image:${IMAGE_TAG}-amd64 --amend $(IMAGE_PREFIX)build-image:${IMAGE_TAG}-arm64 | ||
$(SUDO) docker manifest push $(IMAGE_PREFIX)build-image:$(IMAGE_TAG) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters