| 1 | #!/bin/bash |
| 2 | # |
| 3 | # Copyright (c) SAS Institute Inc. |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | # |
| 17 | set -ex -o pipefail |
| 18 | version=$(./scripts/version.sh) |
| 19 | commit=$(git rev-parse HEAD) |
| 20 | ldflags="-s -w -X main.version=$version -X main.commit=$commit" |
| 21 | goversion=1.20 |
| 22 | |
| 23 | rm -rf build |
| 24 | mkdir build |
| 25 | |
| 26 | ## non-cgo build of client |
| 27 | docker rmi relic-build 2>/dev/null ||: |
| 28 | docker build \ |
| 29 | -f scripts/Dockerfile.clientbuild \ |
| 30 | --pull \ |
| 31 | --build-arg ldflags="$ldflags" \ |
| 32 | --build-arg GOPROXY=$GOPROXY \ |
| 33 | --build-arg goversion=$goversion \ |
| 34 | -t relic-build . |
| 35 | container=$(docker create relic-build) |
| 36 | docker cp $container:out build/ |
| 37 | docker rm $container |
| 38 | docker rmi relic-build |
| 39 | |
| 40 | ## cgo build of full program |
| 41 | docker build \ |
| 42 | -f scripts/Dockerfile.fullbuild \ |
| 43 | --pull \ |
| 44 | --build-arg ldflags="$ldflags" \ |
| 45 | --build-arg GOPROXY=$GOPROXY \ |
| 46 | --build-arg goversion=$goversion \ |
| 47 | -t relic-build . |
| 48 | container=$(docker create relic-build) |
| 49 | docker cp $container:out build/ |
| 50 | docker rm $container |
| 51 | docker rmi relic-build |
| 52 | |
| 53 | mv build/out/* build/ |
| 54 | rmdir build/out |