consolidate script, not going to put in build instructions
This commit is contained in:
parent
2ac4cbd329
commit
545ea03985
3 changed files with 24 additions and 30 deletions
50
build
50
build
|
@ -7,49 +7,43 @@ if ! [ -d .git ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
if uname | grep -qe Linux; then
|
||||
os=linux
|
||||
elif uname | grep -qe MINGW; then
|
||||
os=windows
|
||||
else
|
||||
os=other
|
||||
fi
|
||||
|
||||
build_go() {
|
||||
go build -o out/$(go env GOOS)/listen .
|
||||
}
|
||||
|
||||
build_docker() {
|
||||
if [ $DOCKER_IMAGE ]; then
|
||||
image=$DOCKER_IMAGE
|
||||
if echo $image | grep -q server; then
|
||||
os=windows
|
||||
exe=C:/build/listen/listen.exe
|
||||
else
|
||||
os=linux
|
||||
exe=/usr/src/listen/listen
|
||||
fi
|
||||
if [ $os = "windows" ]; then
|
||||
/c/Program\ Files/Docker/Docker/DockerCli.exe -SwitchWindowsEngine
|
||||
exe=C:/build/listen/listen.exe
|
||||
else
|
||||
if [ -f /c/Program\ Files/Docker/Docker/DockerCli.exe ]; then
|
||||
os=windows
|
||||
exe=C:/build/listen/listen.exe
|
||||
image=1-nanoserver
|
||||
else
|
||||
os=linux
|
||||
exe=/usr/src/listen/listen
|
||||
image=1-alpine
|
||||
fi
|
||||
exe=/usr/src/listen/listen
|
||||
fi
|
||||
|
||||
echo building with $os image golang:$image
|
||||
mkdir -p out/docker
|
||||
if docker build -t listen-build --build-arg IMAGE=$image -f docker/build.$os.Dockerfile .; then
|
||||
|
||||
if docker build -t listen-build -f docker/build.$os.Dockerfile .; then
|
||||
mkdir -p out/$os
|
||||
docker create --name listen-build-tmp listen-build
|
||||
docker cp listen-build-tmp:$exe out/docker
|
||||
docker cp listen-build-tmp:$exe out/$os
|
||||
docker rm listen-build-tmp
|
||||
fi
|
||||
}
|
||||
|
||||
mkdir -p out
|
||||
# if an arg is specified, force building with the specified method
|
||||
[ $1 ] && build_$1 && exit
|
||||
|
||||
# prefer building with local go install if it exists on path
|
||||
if which go &> /dev/null; then
|
||||
build_go
|
||||
# otherwise, try building with docker
|
||||
elif which docker &> /dev/null; then
|
||||
build_docker
|
||||
build_go; exit
|
||||
# if windows or linux, try building with docker
|
||||
elif echo $os | grep -e linux -e windows; then
|
||||
which docker &> /dev/null && (build_docker; exit)
|
||||
fi
|
||||
|
||||
echo could not find valid build method for OS && exit 2
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# This Dockerfile is meant for building listen for Linux ONLY
|
||||
# listen is currently not intended to run in a Docker container
|
||||
|
||||
ARG IMAGE
|
||||
ARG IMAGE="1-alpine"
|
||||
|
||||
FROM golang:${IMAGE} AS build
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# This Dockerfile is meant for building listen for Windows ONLY
|
||||
# listen is currently not intended to run in a Docker container
|
||||
|
||||
ARG IMAGE
|
||||
ARG IMAGE="1-nanoserver"
|
||||
|
||||
FROM golang:${IMAGE} AS build
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue