Skip to content

chore: cross-compile docker images with buildx #3503

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 28, 2021
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
36 changes: 10 additions & 26 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -386,9 +386,10 @@ jobs:
- name: Remove release packages and test artifacts
run: rm -rf ./release-packages ./test/test-results

docker-amd64:
# Builds both amd64 and arm64 images
docker-images:
runs-on: ubuntu-latest
needs: package-linux-amd64
needs: [package-linux-amd64, package-linux-arm64]
steps:
- uses: actions/checkout@v2

Expand All @@ -398,42 +399,24 @@ jobs:
name: release-packages
path: ./release-packages

- name: Run ./ci/steps/build-docker-image.sh
run: ./ci/steps/build-docker-image.sh
- name: Set up QEMU
uses: docker/setup-qemu-action@v1

- name: Upload release image
uses: actions/upload-artifact@v2
with:
name: release-images
path: ./release-images

# TODO: this is the last place where we use our self-hosted arm64 runner.
# In the future, consider switching to docker buildx + qemu,
# thus removing the requirement for us to maintain the runner.
docker-arm64:
runs-on: ubuntu-arm64-latest
needs: package-linux-arm64
steps:
- uses: actions/checkout@v2

- name: Download release package
uses: actions/download-artifact@v2
with:
name: release-packages
path: ./release-packages
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Run ./ci/steps/build-docker-image.sh
run: ./ci/steps/build-docker-image.sh

- name: Upload release image
- name: Upload release images
uses: actions/upload-artifact@v2
with:
name: release-images
path: ./release-images

trivy-scan-image:
runs-on: ubuntu-20.04
needs: docker-amd64
needs: docker-images
# NOTE@jsjoeio: disabling due to a memory issue upstream
# See: https://github.com/github/codeql-action/issues/528
if: 1 == 2
Expand Down Expand Up @@ -466,6 +449,7 @@ jobs:
uses: github/codeql-action/upload-sarif@v1
with:
sarif_file: "trivy-image-results.sarif"

# We have to use two trivy jobs
# because GitHub only allows
# codeql/upload-sarif action per job
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ VS Code v0.00.0

### Development

- item
- chore: cross-compile docker images with buildx #3166 @oxy

## 3.10.2

Expand Down
4 changes: 2 additions & 2 deletions ci/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ You can disable minification by setting `MINIFY=`.

This directory contains the release docker container image.

- [./release-image/build.sh](./release-image/build.sh)
- Builds the release container with the tag `codercom/code-server-$ARCH:$VERSION`.
- [./ci/steps/build-docker-image.sh](./ci/steps/build-docker-image.sh)
- Builds the release containers with tags `codercom/code-server-$ARCH:$VERSION` for amd64 and arm64 with `docker buildx`.
- Assumes debian releases are ready in `./release-packages`.

## images
Expand Down
11 changes: 0 additions & 11 deletions ci/release-image/build.sh

This file was deleted.

25 changes: 25 additions & 0 deletions ci/release-image/docker-bake.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Use this file from the top of the repo, with `-f ci/release-image/docker-bake.hcl`

# Uses env var VERSION if set;
# normally, this is set by ci/lib.sh
variable "VERSION" {
default = "latest"
}

group "default" {
targets = ["code-server-amd64", "code-server-arm64"]
}

target "code-server-amd64" {
dockerfile = "ci/release-image/Dockerfile"
tags = ["docker.io/codercom/code-server-amd64:${VERSION}"]
platforms = ["linux/amd64"]
output = ["type=tar,dest=./release-images/code-server-amd64-${VERSION}.tar"]
}

target "code-server-arm64" {
dockerfile = "ci/release-image/Dockerfile"
tags = ["docker.io/codercom/code-server-arm64:${VERSION}"]
platforms = ["linux/arm64"]
output = ["type=tar,dest=./release-images/code-server-arm64-${VERSION}.tar"]
}
4 changes: 1 addition & 3 deletions ci/steps/build-docker-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ main() {
cd "$(dirname "$0")/../.."
source ./ci/lib.sh

./ci/release-image/build.sh

mkdir -p release-images
docker save "codercom/code-server-$ARCH:$VERSION" >"release-images/code-server-$ARCH-$VERSION.tar"
docker buildx bake -f ci/release-image/docker-bake.hcl
}

main "$@"