Skip to content
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

build: more fixes for CircleCI cross-build setup #20499

Closed
wants to merge 11 commits into from
57 changes: 30 additions & 27 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ workflows:
requires:
- godeps
- jsdeps
- cross_build:
requires:
- godeps
- jsdeps
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am torn between running this on every PR (catches problems early, but slow) and only running it on master. Thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better I think to weed out problems early.

- e2e:
requires:
- build
Expand All @@ -41,13 +45,6 @@ workflows:
branches:
only:
- /^(?!pull\/).*$/
- cross_build:
requires:
- build
filters:
branches:
only:
- master
- litmus_integration:
requires:
- build
Expand Down Expand Up @@ -166,6 +163,7 @@ commands:
sudo apt-get install -y --no-install-recommends \
cmake \
gnupg \
jq \
libssl-dev \
libxml2-dev \
llvm-dev \
Expand Down Expand Up @@ -218,25 +216,36 @@ commands:
echo 'export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER=/usr/local/musl-cross/bin/aarch64-unknown-linux-musl-gcc' >> $BASH_ENV
echo 'export CARGO_TARGET_X86_64_APPLE_DARWIN_LINKER=/usr/local/osxcross/target/bin/x86_64-apple-darwin15-clang' >> $BASH_ENV
- run:
name: Install Docker cross-build kit and emulators
environment:
DOCKER_BUILDX_VERSION: 0.5.1
name: Install updated Docker
command: |
set -euo pipefail
export BUILDKIT_PROGRESS=plain
export DOCKER_BUILDKIT=1
export DOCKER_CLI_EXPERIMENTAL=enabled
echo 'export BUILDKIT_PROGRESS=plain' >> $BASH_ENV
echo 'export DOCKER_BUILDKIT=1' >> $BASH_ENV
echo 'export DOCKER_CLI_EXPERIMENTAL=enabled' >> $BASH_ENV

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
sudo apt-get install -y docker-ce docker-ce-cli containerd.io
sudo service docker restart
- run:
name: Set up Docker cross-builder
command: |
# Uninstall any emulators provided by the system.
emulators=($(docker run --rm --privileged tonistiigi/binfmt:latest) | jq -r .emulators[])
for e in ${emulators[@]}; do
docker run --rm --privileged tonistiigi/binfmt:latest --uninstall ${e}
done

# Install the QEMU emulators we need to cross-build.
docker run --rm --privileged tonistiigi/binfmt:latest --install arm64
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes

mkdir -p ${HOME}/.docker/cli-plugins
curl -sfL -o ${HOME}/.docker/cli-plugins/docker-buildx \
https://github.com/docker/buildx/releases/download/v${DOCKER_BUILDX_VERSION}/buildx-v${DOCKER_BUILDX_VERSION}.linux-amd64
chmod a+x ${HOME}/.docker/cli-plugins/docker-buildx
docker buildx install
echo 'export DOCKER_CLI_EXPERIMENTAL=enabled' >> $BASH_ENV
docker run --rm --privileged tonistiigi/binfmt:latest --install all

# Create a new buildx context using the freshly-installed emulators.
docker buildx create --name cross-builder --platform linux/amd64,linux/arm64
docker buildx create --name cross-builder
docker buildx use --default cross-builder
docker buildx inspect --bootstrap
- run:
Expand Down Expand Up @@ -571,8 +580,6 @@ jobs:
keys:
- influxdb-cross-build-{{ .Branch }}-{{ .Revision }}
- influxdb-cross-build-{{ .Branch }}-
- influxdb-build-{{ .Branch }}-{{ .Revision }}
- influxdb-build-{{ .Branch }}-
- restore_cache:
name: Restore Yarn Cache
keys:
Expand Down Expand Up @@ -606,11 +613,7 @@ jobs:
name: Restore GOCACHE
keys:
- influxdb-nightly-{{ .Branch }}-{{ .Revision }}
- influxdb-cross-build-{{ .Branch }}-{{ .Revision }}
- influxdb-nightly-{{ .Branch }}-
- influxdb-cross-build-{{ .Branch }}-
- influxdb-build-{{ .Branch }}-{{ .Revision }}
- influxdb-build-{{ .Branch }}-
- restore_cache:
name: Restore Yarn Cache
keys:
Expand Down