diff --git a/Dockerfile b/Dockerfile index 88914fec..e383729c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,7 +4,10 @@ ARG VERSION WORKDIR /app COPY ./ ./ -RUN ./build.sh --go-os linux --go-arch amd64 --version "${VERSION:-}" +ENV LD_VERSION="-X github.com/spinnaker/spin/version.Version=${VERSION}" + +RUN GOARCH=amd64 GOOS=linux CGO_ENABLED=0 go build \ + -ldflags "${LD_VERSION}" . FROM alpine diff --git a/Dockerfile.slim b/Dockerfile.slim deleted file mode 100644 index 41a612f5..00000000 --- a/Dockerfile.slim +++ /dev/null @@ -1,9 +0,0 @@ -FROM alpine - -RUN apk update \ - && apk add ca-certificates \ - && rm -rf /var/cache/apk/* - -COPY spin /usr/local/bin - -CMD ["/bin/sh"] diff --git a/build.sh b/build.sh deleted file mode 100755 index 7085de73..00000000 --- a/build.sh +++ /dev/null @@ -1,83 +0,0 @@ -#!/usr/bin/env bash - -set -e -set -x - -VERSION= -RELEASE_PHASE= -go_os= -go_arch= - -function process_args() { - while [[ $# -gt 0 ]] - do - local key="$1" - shift - case ${key} in - --go-arch) - go_arch="$1" - shift - ;; - --go-os) - go_os="$1" - shift - ;; - --release-phase) - RELEASE_PHASE="$1" - shift - ;; - --version) - VERSION="$1" - shift - ;; - --help|-help|-h) - print_usage - exit 0 - ;; - *) - echo "ERROR: Unknown argument '$key'" - exit -1 - esac - done -} - -function print_usage() { - cat < - [--go-arch ] [--go-os ] - [--release-phase ] - - - --go-arch Architecture to build the binary for. - - --go-os OS distribution to build for binary for. - - --release-phase Release phase to decorate the version with. - - --version Version to build the 'spin' binaries with. -EOF -} - -process_args "$@" - -if [[ -z "$VERSION" ]]; then - echo "No Version specified, using git hash at head." - VERSION="$(git rev-parse HEAD)" -fi - -if [[ ! -z "$go_arch" ]]; then - export GOARCH="$go_arch" -fi - -if [[ ! -z "$go_os" ]]; then - export GOOS="$go_os" -fi - -LD_FLAGS=<