optional arm docker image build (#624)
adds the `--arm` flag to /corso/build/build-container.sh
This commit is contained in:
parent
12dbfce6d6
commit
d954c68216
@ -19,7 +19,7 @@ TODO - Link to the appropriate page in the published docs.
|
||||
# Building Corso
|
||||
|
||||
```sh
|
||||
# Build a binary. Will be places in bin/
|
||||
# Build a binary. Will be placed in bin/
|
||||
./build/build.sh
|
||||
|
||||
# Build a container image
|
||||
|
||||
@ -1,6 +1,24 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -ex
|
||||
set -e
|
||||
|
||||
usage() {
|
||||
echo " "
|
||||
echo "-----"
|
||||
echo "Builds a Corso docker container image."
|
||||
echo " "
|
||||
echo "-----"
|
||||
echo "Flags"
|
||||
echo " -h|--help Help"
|
||||
echo " |--arm Set the architecture to arm64 (default: amd64)"
|
||||
echo " "
|
||||
echo "-----"
|
||||
echo "Example Usage:"
|
||||
echo " ./build/build-container.sh"
|
||||
echo " ./build/build-container.sh --arm"
|
||||
echo " "
|
||||
exit 0
|
||||
}
|
||||
|
||||
SCRIPT_ROOT=$(dirname $(readlink -f $0))
|
||||
PROJECT_ROOT=$(dirname ${SCRIPT_ROOT})
|
||||
@ -8,15 +26,38 @@ PROJECT_ROOT=$(dirname ${SCRIPT_ROOT})
|
||||
OS=linux
|
||||
ARCH=amd64
|
||||
|
||||
while [ "$#" -gt 0 ]
|
||||
do
|
||||
case "$1" in
|
||||
-h|--help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
--arm)
|
||||
ARCH=arm64
|
||||
;;
|
||||
-*)
|
||||
echo "Invalid option '$1'. Use -h|--help to see the valid options" >&2
|
||||
return 1
|
||||
;;
|
||||
*)
|
||||
echo "Invalid option '$1'. Use -h|--help to see the valid options" >&2
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
IMAGE_TAG=${OS}-${ARCH}-$(git describe --tags --always --dirty)
|
||||
IMAGE_NAME=alcionai/corso:${IMAGE_TAG}
|
||||
|
||||
${SCRIPT_ROOT}/build.sh
|
||||
${SCRIPT_ROOT}/build.sh --arch ${ARCH}
|
||||
|
||||
echo "building container"
|
||||
set -x
|
||||
docker buildx build --tag ${IMAGE_NAME} \
|
||||
--platform ${OS}/${ARCH} \
|
||||
--file ${PROJECT_ROOT}/docker/Dockerfile \
|
||||
${PROJECT_ROOT}
|
||||
|
||||
set +x
|
||||
echo "container built successfully ${IMAGE_NAME}"
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -ex
|
||||
set -e
|
||||
|
||||
SCRIPT_ROOT=$(dirname $(readlink -f $0))
|
||||
PROJECT_ROOT=$(dirname ${SCRIPT_ROOT})
|
||||
@ -13,12 +13,24 @@ CORSO_BUILD_CONTAINER_SRC_DIR=${CORSO_BUILD_CONTAINER_DIR}/src
|
||||
GOOS=linux
|
||||
GOARCH=amd64
|
||||
|
||||
while [ "$#" -gt 0 ]
|
||||
do
|
||||
case "$1" in
|
||||
--arch)
|
||||
GOARCH=$2
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
# temporary directory for caching go build
|
||||
mkdir -p /tmp/.corsobuild/cache
|
||||
# temporary directory for caching go modules (needed for fast cross-platform build)
|
||||
mkdir -p /tmp/.corsobuild/mod
|
||||
|
||||
echo "building corso"
|
||||
set -x
|
||||
docker run --rm --mount type=bind,src=${SRC_DIR},dst=${CORSO_BUILD_CONTAINER_DIR} \
|
||||
--mount type=bind,src=/tmp/.corsobuild/cache,dst=/tmp/.corsobuild/cache \
|
||||
--mount type=bind,src=/tmp/.corsobuild/mod,dst=/go/pkg/mod \
|
||||
@ -32,6 +44,7 @@ docker run --rm --mount type=bind,src=${SRC_DIR},dst=${CORSO_BUILD_CONTAINER_DIR
|
||||
build ${CORSO_BUILD_ARGS}
|
||||
|
||||
mkdir -p ${PROJECT_ROOT}/bin
|
||||
set +x
|
||||
|
||||
echo "creating binary image in bin/corso"
|
||||
mv ${PROJECT_ROOT}/src/corso ${PROJECT_ROOT}/bin/corso
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user