2019-02-21 17:55:42 +00:00
|
|
|
#!/bin/bash
|
2019-04-26 13:56:14 +00:00
|
|
|
set -euxo pipefail
|
2019-02-21 17:55:42 +00:00
|
|
|
|
2019-04-26 13:56:14 +00:00
|
|
|
# Variables to be set:
|
|
|
|
# $IMAGE
|
|
|
|
function docker_build() {
|
|
|
|
containerID=$(docker create -it -v $(pwd)/.cache:/src/.cache $IMAGE)
|
|
|
|
docker start $containerID
|
|
|
|
docker exec $containerID mkdir -p /src
|
|
|
|
|
|
|
|
function exec() {
|
|
|
|
docker exec $containerID bash -c "$@"
|
|
|
|
}
|
|
|
|
|
|
|
|
docker cp ./. $containerID:/src
|
|
|
|
exec "cd /src && yarn"
|
|
|
|
exec "cd /src && npm rebuild"
|
2019-05-20 16:02:36 +00:00
|
|
|
exec "cd /src && NODE_ENV=production VERSION=$VERSION yarn task build:server:binary"
|
2019-04-26 13:56:14 +00:00
|
|
|
exec "cd /src && yarn task package $VERSION"
|
|
|
|
docker cp $containerID:/src/release/. ./release/
|
|
|
|
}
|
|
|
|
|
|
|
|
if [[ "$OSTYPE" == "darwin"* ]]; then
|
2019-05-20 16:02:36 +00:00
|
|
|
NODE_ENV=production yarn task build:server:binary
|
2019-04-26 13:56:14 +00:00
|
|
|
else
|
|
|
|
if [[ "$TARGET" == "alpine" ]]; then
|
|
|
|
IMAGE="codercom/nbin-alpine"
|
|
|
|
else
|
|
|
|
IMAGE="codercom/nbin-centos"
|
|
|
|
fi
|
|
|
|
docker_build
|
|
|
|
fi
|