diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..61069b7a --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/.idea/* \ No newline at end of file diff --git a/1.11/stretch/Dockerfile b/1.11/stretch/Dockerfile index c38a3176..3de0b1d0 100644 --- a/1.11/stretch/Dockerfile +++ b/1.11/stretch/Dockerfile @@ -1,5 +1,9 @@ FROM buildpack-deps:stretch-scm +RUN curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | bash +RUN curl -Lo /usr/local/bin/jq https://github.com/stedolan/jq/releases/download/jq-1.5/jq-linux64 \ + && chmod +x /usr/local/bin/jq + # gcc for cgo RUN apt-get update && apt-get install -y --no-install-recommends \ g++ \ @@ -7,6 +11,11 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ libc6-dev \ make \ pkg-config \ + git-lfs \ + postgresql-client \ + zip \ + awscli \ + unzip \ && rm -rf /var/lib/apt/lists/* ENV GOLANG_VERSION 1.11 @@ -47,4 +56,49 @@ ENV GOPATH /go ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 777 "$GOPATH" + + +ENV JUNIT_REPORT_LOCATION github.com/jstemmer/go-junit-report +RUN go get -u $JUNIT_REPORT_LOCATION && \ + cd "${GOPATH}/src/$JUNIT_REPORT_LOCATION" && \ + go build && \ + mv go-junit-report /usr/local/bin + +#Install Protocol Buffer Compiler +ENV PROTOC_VERSION 3.5.1 +RUN curl -OL https://github.com/google/protobuf/releases/download/v$PROTOC_VERSION/protoc-$PROTOC_VERSION-linux-x86_64.zip && \ + unzip protoc-$PROTOC_VERSION-linux-x86_64.zip -d protoc && \ + mv protoc/bin/* /usr/local/bin/ && \ + mv protoc/include/* /usr/local/include/ && \ + rm -rf ./protoc && \ + rm protoc-$PROTOC_VERSION-linux-x86_64.zip + +#Install protobuf->Golang generator +ENV GEN_GO_LOCATION github.com/golang/protobuf/protoc-gen-go +RUN go get -u $GEN_GO_LOCATION && \ + cd "${GOPATH}/src/$GEN_GO_LOCATION" && \ + go build && \ + mv protoc-gen-go /usr/local/bin + +#Install protobuf->Twirp generator +ENV GEN_TWIRP_LOCATION github.com/twitchtv/twirp/protoc-gen-twirp +RUN go get -u $GEN_TWIRP_LOCATION && \ + cd "${GOPATH}/src/$GEN_TWIRP_LOCATION" && \ + go build && \ + mv protoc-gen-twirp /usr/local/bin + +#Install protobuf->Swagger generator +ENV GEN_SWAGGER_LOCATION github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger +RUN go get -u $GEN_SWAGGER_LOCATION && \ + cd "${GOPATH}/src/$GEN_SWAGGER_LOCATION" && \ + go build && \ + mv protoc-gen-swagger /usr/local/bin + +#Install protobuf->Validator generator +ENV GEN_VALIDATORS_LOCATION github.com/mwitkow/go-proto-validators/protoc-gen-govalidators +RUN go get -u $GEN_VALIDATORS_LOCATION && \ + cd "${GOPATH}/src/$GEN_VALIDATORS_LOCATION" && \ + go build && \ + mv protoc-gen-govalidators /usr/local/bin + WORKDIR $GOPATH diff --git a/1.8/Dockerfile b/1.8/Dockerfile new file mode 100644 index 00000000..85a08e84 --- /dev/null +++ b/1.8/Dockerfile @@ -0,0 +1,27 @@ +FROM buildpack-deps:xenial-scm + +RUN apt-get update +RUN apt-get install -y --no-install-recommends \ + g++ \ + gcc \ + libc6-dev \ + zip \ + make \ + awscli +RUN rm -rf /var/lib/apt/lists/* + +ENV GOLANG_VERSION 1.8.3 +ENV GOLANG_DOWNLOAD_URL https://golang.org/dl/go$GOLANG_VERSION.linux-amd64.tar.gz + +RUN curl -fsSL "$GOLANG_DOWNLOAD_URL" -o golang.tar.gz \ + && echo "$GOLANG_DOWNLOAD_SHA256 golang.tar.gz" \ + && tar -C /usr/local -xzf golang.tar.gz \ + && rm golang.tar.gz + +ENV GOPATH /go +ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH + +RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 777 "$GOPATH" +WORKDIR $GOPATH + +COPY go-wrapper /usr/local/bin/ diff --git a/1.8/alpine/Dockerfile b/1.8/alpine/Dockerfile new file mode 100644 index 00000000..eb83bfad --- /dev/null +++ b/1.8/alpine/Dockerfile @@ -0,0 +1,46 @@ +FROM alpine:3.3 + +ENV GOLANG_VERSION 1.6.2 +ENV GOLANG_SRC_URL https://golang.org/dl/go$GOLANG_VERSION.src.tar.gz +ENV GOLANG_SRC_SHA256 787b0b750d037016a30c6ed05a8a70a91b2e9db4bd9b1a2453aa502a63f1bccc + +ENV GOLANG_BOOTSTRAP_VERSION 1.4.3 +ENV GOLANG_BOOTSTRAP_URL https://golang.org/dl/go$GOLANG_BOOTSTRAP_VERSION.src.tar.gz +ENV GOLANG_BOOTSTRAP_SHA1 486db10dc571a55c8d795365070f66d343458c48 + +# https://golang.org/issue/14851 +COPY no-pic.patch / + +RUN set -ex \ + && apk add --no-cache --virtual .build-deps \ + bash \ + ca-certificates \ + gcc \ + musl-dev \ + openssl \ + \ + && mkdir -p /usr/local/bootstrap \ + && wget -q "$GOLANG_BOOTSTRAP_URL" -O golang.tar.gz \ + && echo "$GOLANG_BOOTSTRAP_SHA1 golang.tar.gz" | sha1sum -c - \ + && tar -C /usr/local/bootstrap -xzf golang.tar.gz \ + && rm golang.tar.gz \ + && cd /usr/local/bootstrap/go/src \ + && ./make.bash \ + && export GOROOT_BOOTSTRAP=/usr/local/bootstrap/go \ + \ + && wget -q "$GOLANG_SRC_URL" -O golang.tar.gz \ + && echo "$GOLANG_SRC_SHA256 golang.tar.gz" | sha256sum -c - \ + && tar -C /usr/local -xzf golang.tar.gz \ + && rm golang.tar.gz \ + && cd /usr/local/go/src \ + && patch -p2 -i /no-pic.patch \ + && ./make.bash \ + \ + && rm -rf /usr/local/bootstrap /usr/local/go/pkg/bootstrap /*.patch \ + && apk del .build-deps + +ENV GOPATH /go +ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH + +RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 777 "$GOPATH" +WORKDIR $GOPATH diff --git a/1.8/alpine/no-pic.patch b/1.8/alpine/no-pic.patch new file mode 100644 index 00000000..db1f809d --- /dev/null +++ b/1.8/alpine/no-pic.patch @@ -0,0 +1,16 @@ +diff --git a/src/cmd/link/internal/ld/lib.go b/src/cmd/link/internal/ld/lib.go +index 8ccbec9dd634..4e96bfadc260 100644 +--- a/src/cmd/link/internal/ld/lib.go ++++ b/src/cmd/link/internal/ld/lib.go +@@ -1194,6 +1194,11 @@ func hostlink() { + argv = append(argv, peimporteddlls()...) + } + ++ // The Go linker does not currently support building PIE ++ // executables when using the external linker. See: ++ // https://github.com/golang/go/issues/6940 ++ argv = append(argv, "-fno-PIC") ++ + if Debug['v'] != 0 { + fmt.Fprintf(&Bso, "host link:") + for _, v := range argv { diff --git a/1.8/go-wrapper b/1.8/go-wrapper new file mode 100755 index 00000000..97367b71 --- /dev/null +++ b/1.8/go-wrapper @@ -0,0 +1,95 @@ +#!/bin/bash +set -e + +usage() { + base="$(basename "$0")" + cat <&2 + exit 1 +fi + +goDir="$(go list -e -f '{{.ImportComment}}' 2>/dev/null || true)" + +if [ -z "$goDir" -a -s .godir ]; then + goDir="$(cat .godir)" +fi + +dir="$(pwd -P)" +if [ "$goDir" ]; then + goPath="${GOPATH%%:*}" # this just grabs the first path listed in GOPATH, if there are multiple (which is the detection logic "go get" itself uses, too) + goDirPath="$goPath/src/$goDir" + mkdir -p "$(dirname "$goDirPath")" + if [ ! -e "$goDirPath" ]; then + ln -sfv "$dir" "$goDirPath" + elif [ ! -L "$goDirPath" ]; then + echo >&2 "error: $goDirPath already exists but is unexpectedly not a symlink!" + exit 1 + fi + goBin="$goPath/bin/$(basename "$goDir")" +else + goBin="$(basename "$dir")" # likely "app" +fi + +case "$cmd" in + download) + execCommand=( go get -v -d "$@" ) + if [ "$goDir" ]; then execCommand+=( "$goDir" ); fi + set -x; exec "${execCommand[@]}" + ;; + + install) + execCommand=( go install -v "$@" ) + if [ "$goDir" ]; then execCommand+=( "$goDir" ); fi + set -x; exec "${execCommand[@]}" + ;; + + run) + set -x; exec "$goBin" "$@" + ;; + + *) + echo >&2 'error: unknown command:' "$cmd" + usage >&2 + exit 1 + ;; +esac diff --git a/1.8/onbuild/Dockerfile b/1.8/onbuild/Dockerfile new file mode 100644 index 00000000..a854f4b8 --- /dev/null +++ b/1.8/onbuild/Dockerfile @@ -0,0 +1,11 @@ +FROM golang:1.6 + +RUN mkdir -p /go/src/app +WORKDIR /go/src/app + +# this will ideally be built by the ONBUILD below ;) +CMD ["go-wrapper", "run"] + +ONBUILD COPY . /go/src/app +ONBUILD RUN go-wrapper download +ONBUILD RUN go-wrapper install diff --git a/1.8/wheezy/Dockerfile b/1.8/wheezy/Dockerfile new file mode 100644 index 00000000..075b5655 --- /dev/null +++ b/1.8/wheezy/Dockerfile @@ -0,0 +1,26 @@ +FROM buildpack-deps:wheezy-scm + +# gcc for cgo +RUN apt-get update && apt-get install -y --no-install-recommends \ + g++ \ + gcc \ + libc6-dev \ + make \ + && rm -rf /var/lib/apt/lists/* + +ENV GOLANG_VERSION 1.6.2 +ENV GOLANG_DOWNLOAD_URL https://golang.org/dl/go$GOLANG_VERSION.linux-amd64.tar.gz +ENV GOLANG_DOWNLOAD_SHA256 e40c36ae71756198478624ed1bb4ce17597b3c19d243f3f0899bb5740d56212a + +RUN curl -fsSL "$GOLANG_DOWNLOAD_URL" -o golang.tar.gz \ + && echo "$GOLANG_DOWNLOAD_SHA256 golang.tar.gz" | sha256sum -c - \ + && tar -C /usr/local -xzf golang.tar.gz \ + && rm golang.tar.gz + +ENV GOPATH /go +ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH + +RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 777 "$GOPATH" +WORKDIR $GOPATH + +COPY go-wrapper /usr/local/bin/ diff --git a/1.8/wheezy/go-wrapper b/1.8/wheezy/go-wrapper new file mode 100755 index 00000000..97367b71 --- /dev/null +++ b/1.8/wheezy/go-wrapper @@ -0,0 +1,95 @@ +#!/bin/bash +set -e + +usage() { + base="$(basename "$0")" + cat <&2 + exit 1 +fi + +goDir="$(go list -e -f '{{.ImportComment}}' 2>/dev/null || true)" + +if [ -z "$goDir" -a -s .godir ]; then + goDir="$(cat .godir)" +fi + +dir="$(pwd -P)" +if [ "$goDir" ]; then + goPath="${GOPATH%%:*}" # this just grabs the first path listed in GOPATH, if there are multiple (which is the detection logic "go get" itself uses, too) + goDirPath="$goPath/src/$goDir" + mkdir -p "$(dirname "$goDirPath")" + if [ ! -e "$goDirPath" ]; then + ln -sfv "$dir" "$goDirPath" + elif [ ! -L "$goDirPath" ]; then + echo >&2 "error: $goDirPath already exists but is unexpectedly not a symlink!" + exit 1 + fi + goBin="$goPath/bin/$(basename "$goDir")" +else + goBin="$(basename "$dir")" # likely "app" +fi + +case "$cmd" in + download) + execCommand=( go get -v -d "$@" ) + if [ "$goDir" ]; then execCommand+=( "$goDir" ); fi + set -x; exec "${execCommand[@]}" + ;; + + install) + execCommand=( go install -v "$@" ) + if [ "$goDir" ]; then execCommand+=( "$goDir" ); fi + set -x; exec "${execCommand[@]}" + ;; + + run) + set -x; exec "$goBin" "$@" + ;; + + *) + echo >&2 'error: unknown command:' "$cmd" + usage >&2 + exit 1 + ;; +esac diff --git a/1.9/Dockerfile b/1.9/Dockerfile new file mode 100644 index 00000000..b234cad7 --- /dev/null +++ b/1.9/Dockerfile @@ -0,0 +1,83 @@ +FROM buildpack-deps:xenial-scm + +RUN curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | bash +RUN curl -Lo /usr/local/bin/jq https://github.com/stedolan/jq/releases/download/jq-1.5/jq-linux64 \ + && chmod +x /usr/local/bin/jq + +RUN apt-get update +RUN apt-get install -y --no-install-recommends \ + git-lfs \ + postgresql-client \ + g++ \ + gcc \ + libc6-dev \ + zip \ + make \ + awscli \ + unzip +RUN rm -rf /var/lib/apt/lists/* + +ENV DOCKERIZE_VERSION v0.5.0 +RUN wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz \ + && tar -C /usr/local/bin -xzvf dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz \ + && rm dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz + +ENV GOLANG_VERSION 1.9.2 +ENV GOLANG_DOWNLOAD_URL https://golang.org/dl/go$GOLANG_VERSION.linux-amd64.tar.gz + +RUN curl -fsSL "$GOLANG_DOWNLOAD_URL" -o golang.tar.gz \ + && echo "$GOLANG_DOWNLOAD_SHA256 golang.tar.gz" \ + && tar -C /usr/local -xzf golang.tar.gz \ + && rm golang.tar.gz + +ENV GOPATH /go +ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH + +RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 777 "$GOPATH" + +ENV JUNIT_REPORT_LOCATION github.com/jstemmer/go-junit-report +RUN go get -u $JUNIT_REPORT_LOCATION && \ + cd "${GOPATH}/src/$JUNIT_REPORT_LOCATION" && \ + go build && \ + mv go-junit-report /usr/local/bin + +#Install Protocol Buffer Compiler +ENV PROTOC_VERSION 3.5.1 +RUN curl -OL https://github.com/google/protobuf/releases/download/v$PROTOC_VERSION/protoc-$PROTOC_VERSION-linux-x86_64.zip && \ + unzip protoc-$PROTOC_VERSION-linux-x86_64.zip -d protoc && \ + mv protoc/bin/* /usr/local/bin/ && \ + mv protoc/include/* /usr/local/include/ && \ + rm -rf ./protoc && \ + rm protoc-$PROTOC_VERSION-linux-x86_64.zip + +#Install protobuf->Golang generator +ENV GEN_GO_LOCATION github.com/golang/protobuf/protoc-gen-go +RUN go get -u $GEN_GO_LOCATION && \ + cd "${GOPATH}/src/$GEN_GO_LOCATION" && \ + go build && \ + mv protoc-gen-go /usr/local/bin + +#Install protobuf->Twirp generator +ENV GEN_TWIRP_LOCATION github.com/twitchtv/twirp/protoc-gen-twirp +RUN go get -u $GEN_TWIRP_LOCATION && \ + cd "${GOPATH}/src/$GEN_TWIRP_LOCATION" && \ + go build && \ + mv protoc-gen-twirp /usr/local/bin + +#Install protobuf->Swagger generator +ENV GEN_SWAGGER_LOCATION github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger +RUN go get -u $GEN_SWAGGER_LOCATION && \ + cd "${GOPATH}/src/$GEN_SWAGGER_LOCATION" && \ + go build && \ + mv protoc-gen-swagger /usr/local/bin + +#Install protobuf->Validator generator +ENV GEN_VALIDATORS_LOCATION github.com/mwitkow/go-proto-validators/protoc-gen-govalidators +RUN go get -u $GEN_VALIDATORS_LOCATION && \ + cd "${GOPATH}/src/$GEN_VALIDATORS_LOCATION" && \ + go build && \ + mv protoc-gen-govalidators /usr/local/bin + +WORKDIR $GOPATH + +COPY go-wrapper /usr/local/bin/ diff --git a/1.9/alpine/Dockerfile b/1.9/alpine/Dockerfile new file mode 100644 index 00000000..eb83bfad --- /dev/null +++ b/1.9/alpine/Dockerfile @@ -0,0 +1,46 @@ +FROM alpine:3.3 + +ENV GOLANG_VERSION 1.6.2 +ENV GOLANG_SRC_URL https://golang.org/dl/go$GOLANG_VERSION.src.tar.gz +ENV GOLANG_SRC_SHA256 787b0b750d037016a30c6ed05a8a70a91b2e9db4bd9b1a2453aa502a63f1bccc + +ENV GOLANG_BOOTSTRAP_VERSION 1.4.3 +ENV GOLANG_BOOTSTRAP_URL https://golang.org/dl/go$GOLANG_BOOTSTRAP_VERSION.src.tar.gz +ENV GOLANG_BOOTSTRAP_SHA1 486db10dc571a55c8d795365070f66d343458c48 + +# https://golang.org/issue/14851 +COPY no-pic.patch / + +RUN set -ex \ + && apk add --no-cache --virtual .build-deps \ + bash \ + ca-certificates \ + gcc \ + musl-dev \ + openssl \ + \ + && mkdir -p /usr/local/bootstrap \ + && wget -q "$GOLANG_BOOTSTRAP_URL" -O golang.tar.gz \ + && echo "$GOLANG_BOOTSTRAP_SHA1 golang.tar.gz" | sha1sum -c - \ + && tar -C /usr/local/bootstrap -xzf golang.tar.gz \ + && rm golang.tar.gz \ + && cd /usr/local/bootstrap/go/src \ + && ./make.bash \ + && export GOROOT_BOOTSTRAP=/usr/local/bootstrap/go \ + \ + && wget -q "$GOLANG_SRC_URL" -O golang.tar.gz \ + && echo "$GOLANG_SRC_SHA256 golang.tar.gz" | sha256sum -c - \ + && tar -C /usr/local -xzf golang.tar.gz \ + && rm golang.tar.gz \ + && cd /usr/local/go/src \ + && patch -p2 -i /no-pic.patch \ + && ./make.bash \ + \ + && rm -rf /usr/local/bootstrap /usr/local/go/pkg/bootstrap /*.patch \ + && apk del .build-deps + +ENV GOPATH /go +ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH + +RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 777 "$GOPATH" +WORKDIR $GOPATH diff --git a/1.9/alpine/no-pic.patch b/1.9/alpine/no-pic.patch new file mode 100644 index 00000000..db1f809d --- /dev/null +++ b/1.9/alpine/no-pic.patch @@ -0,0 +1,16 @@ +diff --git a/src/cmd/link/internal/ld/lib.go b/src/cmd/link/internal/ld/lib.go +index 8ccbec9dd634..4e96bfadc260 100644 +--- a/src/cmd/link/internal/ld/lib.go ++++ b/src/cmd/link/internal/ld/lib.go +@@ -1194,6 +1194,11 @@ func hostlink() { + argv = append(argv, peimporteddlls()...) + } + ++ // The Go linker does not currently support building PIE ++ // executables when using the external linker. See: ++ // https://github.com/golang/go/issues/6940 ++ argv = append(argv, "-fno-PIC") ++ + if Debug['v'] != 0 { + fmt.Fprintf(&Bso, "host link:") + for _, v := range argv { diff --git a/1.9/go-wrapper b/1.9/go-wrapper new file mode 100755 index 00000000..97367b71 --- /dev/null +++ b/1.9/go-wrapper @@ -0,0 +1,95 @@ +#!/bin/bash +set -e + +usage() { + base="$(basename "$0")" + cat <&2 + exit 1 +fi + +goDir="$(go list -e -f '{{.ImportComment}}' 2>/dev/null || true)" + +if [ -z "$goDir" -a -s .godir ]; then + goDir="$(cat .godir)" +fi + +dir="$(pwd -P)" +if [ "$goDir" ]; then + goPath="${GOPATH%%:*}" # this just grabs the first path listed in GOPATH, if there are multiple (which is the detection logic "go get" itself uses, too) + goDirPath="$goPath/src/$goDir" + mkdir -p "$(dirname "$goDirPath")" + if [ ! -e "$goDirPath" ]; then + ln -sfv "$dir" "$goDirPath" + elif [ ! -L "$goDirPath" ]; then + echo >&2 "error: $goDirPath already exists but is unexpectedly not a symlink!" + exit 1 + fi + goBin="$goPath/bin/$(basename "$goDir")" +else + goBin="$(basename "$dir")" # likely "app" +fi + +case "$cmd" in + download) + execCommand=( go get -v -d "$@" ) + if [ "$goDir" ]; then execCommand+=( "$goDir" ); fi + set -x; exec "${execCommand[@]}" + ;; + + install) + execCommand=( go install -v "$@" ) + if [ "$goDir" ]; then execCommand+=( "$goDir" ); fi + set -x; exec "${execCommand[@]}" + ;; + + run) + set -x; exec "$goBin" "$@" + ;; + + *) + echo >&2 'error: unknown command:' "$cmd" + usage >&2 + exit 1 + ;; +esac diff --git a/1.9/onbuild/Dockerfile b/1.9/onbuild/Dockerfile new file mode 100644 index 00000000..a854f4b8 --- /dev/null +++ b/1.9/onbuild/Dockerfile @@ -0,0 +1,11 @@ +FROM golang:1.6 + +RUN mkdir -p /go/src/app +WORKDIR /go/src/app + +# this will ideally be built by the ONBUILD below ;) +CMD ["go-wrapper", "run"] + +ONBUILD COPY . /go/src/app +ONBUILD RUN go-wrapper download +ONBUILD RUN go-wrapper install diff --git a/1.9/wheezy/Dockerfile b/1.9/wheezy/Dockerfile new file mode 100644 index 00000000..075b5655 --- /dev/null +++ b/1.9/wheezy/Dockerfile @@ -0,0 +1,26 @@ +FROM buildpack-deps:wheezy-scm + +# gcc for cgo +RUN apt-get update && apt-get install -y --no-install-recommends \ + g++ \ + gcc \ + libc6-dev \ + make \ + && rm -rf /var/lib/apt/lists/* + +ENV GOLANG_VERSION 1.6.2 +ENV GOLANG_DOWNLOAD_URL https://golang.org/dl/go$GOLANG_VERSION.linux-amd64.tar.gz +ENV GOLANG_DOWNLOAD_SHA256 e40c36ae71756198478624ed1bb4ce17597b3c19d243f3f0899bb5740d56212a + +RUN curl -fsSL "$GOLANG_DOWNLOAD_URL" -o golang.tar.gz \ + && echo "$GOLANG_DOWNLOAD_SHA256 golang.tar.gz" | sha256sum -c - \ + && tar -C /usr/local -xzf golang.tar.gz \ + && rm golang.tar.gz + +ENV GOPATH /go +ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH + +RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 777 "$GOPATH" +WORKDIR $GOPATH + +COPY go-wrapper /usr/local/bin/ diff --git a/1.9/wheezy/go-wrapper b/1.9/wheezy/go-wrapper new file mode 100755 index 00000000..97367b71 --- /dev/null +++ b/1.9/wheezy/go-wrapper @@ -0,0 +1,95 @@ +#!/bin/bash +set -e + +usage() { + base="$(basename "$0")" + cat <&2 + exit 1 +fi + +goDir="$(go list -e -f '{{.ImportComment}}' 2>/dev/null || true)" + +if [ -z "$goDir" -a -s .godir ]; then + goDir="$(cat .godir)" +fi + +dir="$(pwd -P)" +if [ "$goDir" ]; then + goPath="${GOPATH%%:*}" # this just grabs the first path listed in GOPATH, if there are multiple (which is the detection logic "go get" itself uses, too) + goDirPath="$goPath/src/$goDir" + mkdir -p "$(dirname "$goDirPath")" + if [ ! -e "$goDirPath" ]; then + ln -sfv "$dir" "$goDirPath" + elif [ ! -L "$goDirPath" ]; then + echo >&2 "error: $goDirPath already exists but is unexpectedly not a symlink!" + exit 1 + fi + goBin="$goPath/bin/$(basename "$goDir")" +else + goBin="$(basename "$dir")" # likely "app" +fi + +case "$cmd" in + download) + execCommand=( go get -v -d "$@" ) + if [ "$goDir" ]; then execCommand+=( "$goDir" ); fi + set -x; exec "${execCommand[@]}" + ;; + + install) + execCommand=( go install -v "$@" ) + if [ "$goDir" ]; then execCommand+=( "$goDir" ); fi + set -x; exec "${execCommand[@]}" + ;; + + run) + set -x; exec "$goBin" "$@" + ;; + + *) + echo >&2 'error: unknown command:' "$cmd" + usage >&2 + exit 1 + ;; +esac