corso/build/build.sh
Vaibhav Kamra 5fe9cc51aa
Build linux/amd64 image (#383)
Updates the default build options to build linux/amd64.

Fixes #378
2022-07-27 18:44:39 +00:00

38 lines
1.5 KiB
Bash
Executable File

#!/bin/sh
set -ex
SCRIPT_ROOT=$(dirname $(readlink -f $0))
PROJECT_ROOT=$(dirname ${SCRIPT_ROOT})
SRC_DIR=${PROJECT_ROOT}
CORSO_BUILD_ARGS=''
CORSO_BUILD_CONTAINER_DIR=/go/src/github.com/alcionai/corso
CORSO_BUILD_CONTAINER_SRC_DIR=${CORSO_BUILD_CONTAINER_DIR}/src
GOOS=linux
GOARCH=amd64
# 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"
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 \
--workdir ${CORSO_BUILD_CONTAINER_SRC_DIR} \
--env GOCACHE=/tmp/.corsobuild/cache \
--env GOOS=${GOOS} \
--env GOARCH=${GOARCH} \
--env GOCACHE=/tmp/.corsobuild/cache \
--entrypoint /usr/local/go/bin/go \
golang:1.18 \
build ${CORSO_BUILD_ARGS}
mkdir -p ${PROJECT_ROOT}/bin
echo "creating binary image in bin/corso"
mv ${PROJECT_ROOT}/src/corso ${PROJECT_ROOT}/bin/corso