-
Notifications
You must be signed in to change notification settings - Fork 94
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
ci(arm): Adds support for cross compilation and publishes Relay ARM docker images #3272
Changes from all commits
95e48b3
dc924ee
f458632
c088149
709cf2d
757d45a
4e044f3
8371d7f
936c002
485f523
a753bcf
e5827a4
fd6a150
5085462
9a62918
5be8c66
8e968b6
a2daa9a
42ac49f
39618a3
eb31f58
280c95e
10b9bc0
57e83b6
5243466
204ea7b
f7cf7bd
932d64d
5e13154
c79d137
ae9ae1a
5c9131e
24dc25d
792be03
4edf89a
b5b3aa0
24154b8
d51d8d0
96ab3eb
d27498c
14034a5
25b9a87
9ba99a3
4b4f0b0
2b691d9
79a97b3
2ccb241
e2bb4c7
bad389a
5763521
5864831
9e7659f
e467edc
ef70f56
4611998
cf3cd3d
cdfe4c1
85d1aa4
879b87b
eaa3420
50709d6
7a34e74
4500d51
56f55f2
29121fa
2c4298c
7c376be
6c54460
8350fc5
7edde21
a0d9a16
959f151
11ab0cc
ef5ee70
3f28d55
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,3 +13,6 @@ | |
|
||
!docker-entrypoint.sh | ||
!Makefile | ||
|
||
# CI files necessary for building the docker file | ||
!linux/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -183,100 +183,181 @@ jobs: | |
timeout-minutes: 30 | ||
strategy: | ||
matrix: | ||
# the arm64 build takes too long, so disable for now | ||
arch: [amd64] | ||
image_name: [relay, relay-pop] | ||
target: [x86_64-unknown-linux-gnu, aarch64-unknown-linux-gnu] | ||
|
||
name: Build Docker Image | ||
name: Build Relay Binary | ||
runs-on: ubuntu-latest | ||
|
||
# Skip redundant checks for library releases | ||
if: "!startsWith(github.ref, 'refs/heads/release-library/')" | ||
|
||
env: | ||
IMG_BASE: ghcr.io/getsentry/${{ matrix.image_name }} | ||
IMG_DEPS: ghcr.io/getsentry/${{ matrix.image_name }}-deps:${{ matrix.arch }} | ||
# GITHUB_SHA in pull requests points to the merge commit | ||
IMG_VERSIONED: ghcr.io/getsentry/${{ matrix.image_name }}:${{ github.event.pull_request.head.sha || github.sha }} | ||
ARCH: ${{ matrix.arch }} | ||
RELAY_BIN: "target/${{ matrix.target }}/release/relay" | ||
FEATURES: |- | ||
${{fromJson('{ | ||
"relay": "processing,crash-handler", | ||
"relay-pop": "crash-handler" | ||
}')[matrix.image_name] }} | ||
DOCKER_PLATFORM: |- | ||
${{fromJson('{ | ||
"x86_64-unknown-linux-gnu": "linux/amd64", | ||
"aarch64-unknown-linux-gnu": "linux/arm64" | ||
}')[matrix.target] }} | ||
# Fix editor: ' | ||
|
||
steps: | ||
- name: Install dependencies | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y llvm | ||
- uses: actions/checkout@v4 | ||
with: | ||
submodules: recursive | ||
|
||
- uses: dtolnay/rust-toolchain@stable | ||
- uses: swatinem/rust-cache@v2 | ||
with: | ||
key: ${{ github.job }}-${{ matrix.arch }} | ||
key: "${{ github.job }}-${{ matrix.target }}-${{ matrix.image_name }}" | ||
|
||
- name: Install Cross | ||
# We need a nightly version of cross for `cross-util`. | ||
run: cargo install cross --git https://github.com/cross-rs/cross --rev 085092c | ||
|
||
- name: Compile | ||
run: | | ||
export PATH="/home/runner/.cargo/bin/:$PATH" | ||
- run: docker run --rm --privileged tonistiigi/binfmt --install arm64 | ||
if: matrix.arch == 'arm64' | ||
cross build --release --locked --features "${FEATURES}" --target "${{ matrix.target }}" | ||
- name: Build | ||
- name: Split debug info | ||
run: | | ||
# Get the latest stable rust toolchain version available | ||
TOOLCHAIN=$(curl -s 'https://static.rust-lang.org/dist/channel-rust-stable.toml' | awk '/\[pkg.rust\]/ {getline;print;}' | sed -r 's/^version = "([0-9.]+) .*/\1/') | ||
./scripts/build-docker-image.sh "$ARCH" "$TOOLCHAIN" ${{ matrix.image_name }} | ||
llvm-objcopy --only-keep-debug "${RELAY_BIN}"{,.debug} | ||
llvm-objcopy --strip-debug --strip-unneeded "${RELAY_BIN}" | ||
llvm-objcopy --add-gnu-debuglink "${RELAY_BIN}"{.debug,} | ||
cross-util run --target "${{ matrix.target }}" -- "sentry-cli difutil bundle-sources ${RELAY_BIN}.debug" | ||
zip "${RELAY_BIN}.debug.zip" "${RELAY_BIN}.debug" | ||
- name: Export Docker Image | ||
run: docker save -o ${{ matrix.image_name }}-docker-image.tgz $IMG_VERSIONED | ||
- name: Prepare Artifacts | ||
run: | | ||
mkdir -p "artifacts/${DOCKER_PLATFORM}" | ||
cp "${RELAY_BIN}"{,.debug.zip,.src.zip} "artifacts/${DOCKER_PLATFORM}" | ||
- name: Upload Docker Image to Artifact | ||
uses: actions/upload-artifact@v3 | ||
- name: Upload Artifacts | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
retention-days: 1 | ||
name: ${{ matrix.image_name }}-docker-image | ||
path: ${{ matrix.image_name }}-docker-image.tgz | ||
name: ${{ matrix.image_name }}@${{ matrix.target }} | ||
path: "./artifacts/*" | ||
|
||
build-docker: | ||
timeout-minutes: 5 | ||
needs: build | ||
|
||
name: Build Docker Image | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
image_name: [relay, relay-pop] | ||
|
||
env: | ||
PLATFORMS: "linux/amd64,linux/arm64" | ||
DOCKER_IMAGE: "ghcr.io/getsentry/${{ matrix.image_name }}" | ||
REVISION: "${{ github.event.pull_request.head.sha || github.sha }}" | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- uses: docker/setup-qemu-action@v3 | ||
- uses: docker/setup-buildx-action@v3 | ||
|
||
- uses: actions/download-artifact@v4 | ||
with: | ||
pattern: "${{ matrix.image_name }}@*" | ||
merge-multiple: true | ||
|
||
- name: Push to ghcr.io | ||
# Do not run this on forks as they do not have access to secrets | ||
- name: Build and push to ghcr.io | ||
if: "!github.event.pull_request.head.repo.fork && github.actor != 'dependabot[bot]'" | ||
run: | | ||
set -euxo pipefail | ||
docker login --username '${{ github.actor }}' --password '${{ secrets.GITHUB_TOKEN }}' ghcr.io | ||
docker push $IMG_DEPS | ||
docker push $IMG_VERSIONED | ||
- name: Push nightly to ghcr.io | ||
if: github.ref == 'refs/heads/master' | ||
docker buildx build \ | ||
--platform "${PLATFORMS}" \ | ||
--tag "${DOCKER_IMAGE}:${REVISION}" \ | ||
$( [[ "${GITHUB_REF}" == "refs/heads/master" ]] && printf %s "--tag ${DOCKER_IMAGE}:nightly" ) \ | ||
--file Dockerfile.release \ | ||
--push . | ||
publish-to-dockerhub: | ||
needs: build-docker | ||
|
||
runs-on: ubuntu-20.04 | ||
name: Publish Relay to DockerHub | ||
|
||
strategy: | ||
matrix: | ||
image_name: [relay] # Don't publish relay-pop (for now) | ||
|
||
if: ${{ (github.ref_name == 'master') }} | ||
|
||
env: | ||
GHCR_DOCKER_IMAGE: "ghcr.io/getsentry/${{ matrix.image_name }}" | ||
DH_DOCKER_IMAGE: "getsentry/${{ matrix.image_name }}" | ||
REVISION: "${{ github.event.pull_request.head.sha || github.sha }}" | ||
|
||
steps: | ||
- name: Install cosign | ||
uses: sigstore/cosign-installer@v3.5.0 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we already sign images? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is just so the |
||
|
||
- name: Install regctl | ||
uses: regclient/actions/regctl-installer@2dac4eff5925ed07edbfe12d2d11af6304df29a6 | ||
|
||
- name: Login to DockerHub | ||
run: docker login --username=sentrybuilder --password ${{ secrets.DOCKER_HUB_RW_TOKEN }} | ||
|
||
- name: Copy Image from GHCR to DockerHub | ||
run: | | ||
set -euxo pipefail | ||
docker tag "$IMG_VERSIONED" "$IMG_BASE:nightly" | ||
docker push "$IMG_BASE:nightly" | ||
# We push 3 tags to Dockerhub: | ||
# 1) the full sha of the commit | ||
regctl image copy "${GHCR_DOCKER_IMAGE}:${REVISION}" "${DH_DOCKER_IMAGE}:${REVISION}" | ||
push-prod-image: | ||
# 2) the short sha | ||
SHORT_SHA=$(echo ${GITHUB_SHA} | cut -c1-8) | ||
regctl image copy "${GHCR_DOCKER_IMAGE}:${REVISION}" "${DH_DOCKER_IMAGE}:${SHORT_SHA}" | ||
# 3) nightly | ||
regctl image copy "${GHCR_DOCKER_IMAGE}:nightly" "${DH_DOCKER_IMAGE}:nightly" | ||
publish-to-gcr: | ||
timeout-minutes: 5 | ||
needs: build | ||
needs: build-docker | ||
|
||
name: Publish Relay to GCR | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
image_name: [relay, relay-pop] | ||
|
||
name: Push GCR Docker Image | ||
runs-on: ubuntu-latest | ||
|
||
# required for google auth | ||
permissions: | ||
contents: "read" | ||
id-token: "write" | ||
|
||
env: | ||
GHCR_DOCKER_IMAGE: "ghcr.io/getsentry/${{ matrix.image_name }}" | ||
GCR_DOCKER_IMAGE: "us.gcr.io/sentryio/${{ matrix.image_name }}" | ||
REVISION: "${{ github.event.pull_request.head.sha || github.sha }}" | ||
|
||
# Skip redundant checks for library releases | ||
# Skip for dependabot and if run on a fork | ||
if: "!startsWith(github.ref, 'refs/heads/release-library/') && !github.event.pull_request.head.repo.fork && github.actor != 'dependabot[bot]'" | ||
|
||
env: | ||
# GITHUB_SHA in pull requests points to the merge commit | ||
REVISION: ${{ github.event.pull_request.head.sha || github.sha }} | ||
IMG_VERSIONED: ghcr.io/getsentry/${{ matrix.image_name }}:${{ github.event.pull_request.head.sha || github.sha }} | ||
|
||
steps: | ||
- name: Download Docker Image | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: ${{ matrix.image_name }}-docker-image | ||
|
||
- name: Import Docker Image | ||
run: docker load -i ${{ matrix.image_name }}-docker-image.tgz | ||
- name: Install cosign | ||
uses: sigstore/cosign-installer@v3.5.0 | ||
|
||
- name: Google Auth | ||
id: auth | ||
|
@@ -296,28 +377,62 @@ jobs: | |
run: | | ||
gcloud auth configure-docker us.gcr.io | ||
- name: Push to us.gcr.io | ||
run: | | ||
set -euxo pipefail | ||
docker tag "$IMG_VERSIONED" "us.gcr.io/sentryio/${{ matrix.image_name }}:$REVISION" | ||
docker push "us.gcr.io/sentryio/${{ matrix.image_name }}:$REVISION" | ||
- name: Install regctl | ||
uses: regclient/actions/regctl-installer@2dac4eff5925ed07edbfe12d2d11af6304df29a6 | ||
|
||
- name: Copy Image from GHCR to GCR | ||
run: regctl image copy "${GHCR_DOCKER_IMAGE}:${REVISION}" "${GCR_DOCKER_IMAGE}:${REVISION}" | ||
|
||
- name: Push nightly to us.gcr.io | ||
- name: Copy Nightly from GHCR to GCR | ||
if: github.ref == 'refs/heads/master' | ||
run: | | ||
set -euxo pipefail | ||
docker tag "$IMG_VERSIONED" "us.gcr.io/sentryio/${{ matrix.image_name }}:nightly" | ||
docker push "us.gcr.io/sentryio/${{ matrix.image_name }}:nightly" | ||
run: regctl image copy "${GHCR_DOCKER_IMAGE}:nightly" "${GCR_DOCKER_IMAGE}:nightly" | ||
|
||
gocd-artifacts: | ||
timeout-minutes: 5 | ||
needs: build-docker | ||
|
||
name: Upload build artifacts to gocd | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
image_name: [relay, relay-pop] | ||
|
||
# required for google auth | ||
permissions: | ||
contents: "read" | ||
id-token: "write" | ||
|
||
env: | ||
GHCR_DOCKER_IMAGE: "ghcr.io/getsentry/${{ matrix.image_name }}" | ||
REVISION: "${{ github.event.pull_request.head.sha || github.sha }}" | ||
|
||
if: "!startsWith(github.ref, 'refs/heads/release-library/') && !github.event.pull_request.head.repo.fork && github.actor != 'dependabot[bot]'" | ||
|
||
steps: | ||
- name: Google Auth | ||
id: auth | ||
uses: google-github-actions/auth@v2 | ||
with: | ||
workload_identity_provider: projects/868781662168/locations/global/workloadIdentityPools/prod-github/providers/github-oidc-pool | ||
service_account: gha-gcr-push@sac-prod-sa.iam.gserviceaccount.com | ||
|
||
- name: "Set up Cloud SDK" | ||
uses: "google-github-actions/setup-gcloud@v2" | ||
with: | ||
# https://github.com/google-github-actions/auth#authenticating-via-workload-identity-federation | ||
# You must use the Cloud SDK version 390.0.0 or later to authenticate the bq and gsutil tools. | ||
version: ">= 390.0.0" | ||
|
||
- name: Upload gocd deployment assets | ||
run: | | ||
set -euxo pipefail | ||
VERSION="$(docker run --rm "$IMG_VERSIONED" --version | cut -d" " -f2)" | ||
echo "relay@$VERSION+$REVISION" > release-name | ||
VERSION="$(docker run --rm "${GHCR_DOCKER_IMAGE}:${REVISION}" --version | cut -d" " -f2)" | ||
echo "${{ matrix.image_name }}@${VERSION}+${REVISION}" > release-name | ||
docker run --rm --entrypoint cat "$IMG_VERSIONED" /opt/relay-debug.zip > relay-debug.zip | ||
docker run --rm --entrypoint cat "$IMG_VERSIONED" /opt/relay.src.zip > relay.src.zip | ||
docker run --rm --entrypoint tar "$IMG_VERSIONED" -cf - /lib/x86_64-linux-gnu > libs.tar | ||
docker run --rm --entrypoint cat "${GHCR_DOCKER_IMAGE}:${REVISION}" /opt/relay.debug.zip > relay.debug.zip | ||
docker run --rm --entrypoint cat "${GHCR_DOCKER_IMAGE}:${REVISION}" /opt/relay.src.zip > relay.src.zip | ||
docker run --rm --entrypoint tar "${GHCR_DOCKER_IMAGE}:${REVISION}" -cf - /lib/x86_64-linux-gnu > libs.tar | ||
# debugging for mysterious "Couldn't write tracker file" issue: | ||
(env | grep runner) || true | ||
|
@@ -329,7 +444,7 @@ jobs: | |
/home/runner/.gsutil/tracker-files/upload_TRACKER_*.rc.zip__JSON.url \ | ||
|| true | ||
gsutil -m cp -L gsutil.log ./libs.tar ./relay-debug.zip ./relay.src.zip ./release-name \ | ||
"gs://dicd-team-devinfra-cd--relay/deployment-assets/$REVISION/${{ matrix.image_name }}/" || status=$? && status=$? | ||
"gs://dicd-team-devinfra-cd--relay/deployment-assets/${REVISION}/${{ matrix.image_name }}/" || status=$? && status=$? | ||
cat gsutil.log | ||
exit "$status" | ||
|
@@ -397,7 +512,7 @@ jobs: | |
name: Sentry-Relay Integration Tests | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 30 | ||
needs: build | ||
needs: build-docker | ||
|
||
# Skip redundant checks for library releases | ||
if: "!startsWith(github.ref, 'refs/heads/release-library/')" | ||
|
@@ -429,14 +544,6 @@ jobs: | |
kafka: true | ||
symbolicator: true | ||
|
||
- name: Download Docker Image | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: relay-docker-image | ||
|
||
- name: Import Docker Image | ||
run: docker load -i relay-docker-image.tgz | ||
|
||
- name: Run Sentry integration tests | ||
working-directory: sentry | ||
env: | ||
|
@@ -445,28 +552,3 @@ jobs: | |
echo "Testing against ${RELAY_TEST_IMAGE}" | ||
make test-relay-integration | ||
publish-to-dockerhub: | ||
name: Publish Relay to DockerHub | ||
needs: build | ||
runs-on: ubuntu-20.04 | ||
if: ${{ (github.ref_name == 'master') }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- timeout-minutes: 20 | ||
run: until docker pull "ghcr.io/getsentry/relay:${{ github.sha }}" 2>/dev/null; do sleep 10; done | ||
- name: Push built docker image | ||
shell: bash | ||
run: | | ||
IMAGE_URL="ghcr.io/getsentry/relay:${{ github.sha }}" | ||
docker login --username=sentrybuilder --password ${{ secrets.DOCKER_HUB_RW_TOKEN }} | ||
# We push 3 tags to Dockerhub: | ||
# first, the full sha of the commit | ||
docker tag "$IMAGE_URL" getsentry/relay:${GITHUB_SHA} | ||
docker push getsentry/relay:${GITHUB_SHA} | ||
# second, the short sha of the commit | ||
SHORT_SHA=$(git rev-parse --short "$GITHUB_SHA") | ||
docker tag "$IMAGE_URL" getsentry/relay:${SHORT_SHA} | ||
docker push getsentry/relay:${SHORT_SHA} | ||
# finally, nightly | ||
docker tag "$IMAGE_URL" getsentry/relay:nightly | ||
docker push getsentry/relay:nightly |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[build] | ||
pre-build = [ | ||
# Use azure mirrors for faster downloads. | ||
"sed -i -e 's/archive.archive.ubuntu.com/azure.archive.ubuntu.com/' /etc/apt/sources.list", | ||
"sed -i -e 's/security.archive.ubuntu.com/azure.archive.ubuntu.com/' /etc/apt/sources.list", | ||
"apt-get update && apt-get --assume-yes install libclang-8-dev clang-8", | ||
"curl -sL https://sentry.io/get-cli/ | sh", | ||
] | ||
|
||
[target.aarch64-unknown-linux-gnu] | ||
# We're using a nightly `cross`, let's still use a stable image. | ||
image = "ghcr.io/cross-rs/aarch64-unknown-linux-gnu:0.2.5" |
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so it does use qemu for something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not 100% sure, I think buildx needs it to build the image, but the binary is compiled outside of the docker image, hence why it's almost instant.