forked from tsuru/tsuru
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-compose.sh
executable file
·33 lines (25 loc) · 1013 Bytes
/
build-compose.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/bash
# This script builds tsurud inside container and call compose to build and run a new api image.
set -e
IP="10.200.10.1"
if ! `ping -c 1 -t 1 "$IP" > /dev/null`
then
CURRENT_OS="$(uname)"
if [[ "$CURRENT_OS" == "Linux" ]]; then
sudo ip addr add dev docker0 $IP/24 || true
elif [[ "$CURRENT_OS" == "Darwin" ]]; then
sudo ifconfig lo0 alias $IP/24 || true
else
echo "Unsupported OS"
exit 1
fi
fi
BUILD_IMAGE='tsuru/alpine-go:latest'
LOCAL_PKG=${GOPATH}'/pkg/linux_amd64'
CONTAINER_PKG='/go/pkg/linux_amd64'
CONTAINER_PROJECT_PATH='/go/src/github.com/tsuru/tsuru'
BUILD_CMD="go build -i -v --ldflags '-linkmode external -extldflags \"-static\"' -o build/tsurud ./cmd/tsurud"
set -x
docker run --rm -v ${LOCAL_PKG}:${CONTAINER_PKG} -v ${PWD}:${CONTAINER_PROJECT_PATH} -w ${CONTAINER_PROJECT_PATH} -e CC=/usr/bin/gcc -e GOPATH=/go ${BUILD_IMAGE} sh -c "${BUILD_CMD}"
docker-compose -f ${1:-"docker-compose.yml"} build api
docker-compose -f ${1:-"docker-compose.yml"} up -d