build: add scripts/buildx
This commit is contained in:
parent
5a6225d397
commit
6b7a9a8fef
|
@ -248,15 +248,6 @@ jobs:
|
|||
shell: bash
|
||||
|
||||
steps:
|
||||
- name: prepare docker
|
||||
run: |
|
||||
mkdir -p $HOME/.docker
|
||||
echo '{ "experimental": "enabled" }' | tee $HOME/.docker/config.json
|
||||
echo '{ "experimental": true, "storage-driver": "overlay2", "max-concurrent-downloads": 50, "max-concurrent-uploads": 50}' | sudo tee /etc/docker/daemon.json
|
||||
sudo systemctl restart docker
|
||||
docker info
|
||||
docker buildx create --use --name mybuild
|
||||
docker run --rm --privileged tonistiigi/binfmt --install all
|
||||
- uses: actions/download-artifact@v2
|
||||
with:
|
||||
name: source
|
||||
|
@ -298,13 +289,13 @@ jobs:
|
|||
run: |
|
||||
set -e -u
|
||||
cd source
|
||||
docker buildx build --no-cache \
|
||||
--platform=linux/$ARCH \
|
||||
-t cross_build_emqx_for_$SYSTEM \
|
||||
-f .ci/build_packages/Dockerfile \
|
||||
--build-arg BUILD_FROM=emqx/build-env:$ERL_OTP-$SYSTEM \
|
||||
--build-arg EMQX_NAME=$PROFILE \
|
||||
--output type=tar,dest=/tmp/cross-build-$PROFILE-for-$SYSTEM.tar .
|
||||
./scripts/buildx.sh \
|
||||
--prepare \
|
||||
--profile "$PROFILE" \
|
||||
--system "$SYSTEM" \
|
||||
--builder "emqx/build-env:$ERL_OTP-$SYSTEM" \
|
||||
--arch "$ARCH" \
|
||||
--build_dest "/tmp/cross-build-$PROFILE-for-$SYSTEM.tar" .
|
||||
|
||||
mkdir -p /tmp/packages/$PROFILE
|
||||
tar -xvf /tmp/cross-build-$PROFILE-for-$SYSTEM.tar --wildcards emqx/_packages/$PROFILE/*
|
||||
|
|
|
@ -0,0 +1,79 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
## This script helps to setup a buildx environment for CI
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
function help {
|
||||
echo
|
||||
echo "-h|--help: To display this usage information"
|
||||
echo "--prepare: Prepare docker buildx environment (only once for each setup)"
|
||||
echo "--src_dir <SRC_DIR>: EMQ X source ode in this dir, default to PWD"
|
||||
echo "--profile <PROFILE>: EMQ X profile to build, e.g. emqx, emqx-edge"
|
||||
echo "--system <SYSTEM>: Target system e.g. debian10, centos7 etc."
|
||||
echo "--builder <BUILDER>: Builder image to pull."
|
||||
echo "--arch <TARGET_ARCH>: Target arch to build the EMQ X package for"
|
||||
echo "--build_dest <PATH>: Destination file output tar file"
|
||||
}
|
||||
|
||||
while [ "$#" -gt 0 ]; do
|
||||
case $1 in
|
||||
-h|--help)
|
||||
help
|
||||
exit 0
|
||||
;;
|
||||
--prepare)
|
||||
PREPARE='yes'
|
||||
shift
|
||||
;;
|
||||
--src_dir)
|
||||
SRC_DIR="$2"
|
||||
shift 2
|
||||
;;
|
||||
--profile)
|
||||
PROFILE="$2"
|
||||
shift 2
|
||||
;;
|
||||
--system)
|
||||
SYSTEM="$2"
|
||||
shift 2
|
||||
;;
|
||||
--builder)
|
||||
BUILDER="$2"
|
||||
shift 2
|
||||
;;
|
||||
--arch)
|
||||
ARCH="$2"
|
||||
shift 2
|
||||
;;
|
||||
--build_dest)
|
||||
BUILD_DEST="$2"
|
||||
shift 2
|
||||
;;
|
||||
*)
|
||||
echo "WARN: Unknown arg (ignored): $1"
|
||||
shift
|
||||
continue
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ "${PREPARE:-}" = 'yes' ]; then
|
||||
mkdir -p $HOME/.docker
|
||||
echo '{ "experimental": "enabled" }' | tee $HOME/.docker/config.json
|
||||
echo '{ "experimental": true, "storage-driver": "overlay2", "max-concurrent-downloads": 50, "max-concurrent-uploads": 50}' | sudo tee /etc/docker/daemon.json
|
||||
sudo systemctl restart docker
|
||||
docker info
|
||||
docker buildx create --use --name mybuild
|
||||
docker run --rm --privileged tonistiigi/binfmt --install all
|
||||
fi
|
||||
|
||||
cd "${SRC_DIR:-.}"
|
||||
|
||||
docker buildx build --no-cache \
|
||||
--platform=linux/$ARCH \
|
||||
-t "cross_build_emqx_for_${SYSTEM}" \
|
||||
-f .ci/build_packages/Dockerfile \
|
||||
--build-arg BUILD_FROM="$BUILDER" \
|
||||
--build-arg EMQX_NAME="$PROFILE" \
|
||||
--output type=tar,dest="$BUILD_DEST" .
|
Loading…
Reference in New Issue