2018-07-19 10:47:05 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set +e
|
|
|
|
|
|
|
|
usage(){
|
|
|
|
echo "Usage: builder <golang image:version> <code path> <code release tag> <main.go path> <binary name>"
|
2020-07-16 10:20:54 +02:00
|
|
|
echo "e.g: builder golang:1.14.5 github.com/helm/chartmuseum v0.12.0 cmd/chartmuseum chartm"
|
2018-07-19 10:47:05 +02:00
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
if [ $# != 5 ]; then
|
|
|
|
usage
|
|
|
|
fi
|
|
|
|
|
|
|
|
GOLANG_IMAGE="$1"
|
2019-07-17 08:38:08 +02:00
|
|
|
GIT_PATH="$2"
|
2018-07-19 10:47:05 +02:00
|
|
|
CODE_VERSION="$3"
|
|
|
|
MAIN_GO_PATH="$4"
|
|
|
|
BIN_NAME="$5"
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
cd `dirname $0`
|
|
|
|
cur=$PWD
|
|
|
|
|
|
|
|
mkdir -p binary
|
|
|
|
rm -rf binary/$BIN_NAME || true
|
|
|
|
cp compile.sh binary/
|
2020-06-15 18:20:18 +02:00
|
|
|
cp *.patch binary/
|
2018-07-19 10:47:05 +02:00
|
|
|
|
2019-07-17 08:38:08 +02:00
|
|
|
docker run -it --rm -v $cur/binary:/go/bin --name golang_code_builder $GOLANG_IMAGE /bin/bash /go/bin/compile.sh $GIT_PATH $CODE_VERSION $MAIN_GO_PATH $BIN_NAME
|
2018-07-19 10:47:05 +02:00
|
|
|
|
|
|
|
#Clear
|
2019-10-20 15:10:55 +02:00
|
|
|
#docker rm -f golang_code_builder
|