Skip to content

Add 1.4beta1 #26

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 17, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions 1.4/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
FROM debian:jessie

# SCMs for "go get", gcc for cgo
RUN apt-get update && apt-get install -y \
ca-certificates curl gcc libc6-dev make \
bzr git mercurial \
--no-install-recommends \
&& rm -rf /var/lib/apt/lists/*

ENV GOLANG_VERSION 1.4rc1

RUN curl -sSL https://golang.org/dl/go$GOLANG_VERSION.src.tar.gz \
| tar -v -C /usr/src -xz

RUN cd /usr/src/go/src && ./make.bash --no-clean 2>&1

ENV PATH /usr/src/go/bin:$PATH

RUN mkdir -p /go/src
ENV GOPATH /go
ENV PATH /go/bin:$PATH
WORKDIR /go

COPY go-wrapper /usr/local/bin/
31 changes: 31 additions & 0 deletions 1.4/cross/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
FROM golang:1.4rc1

# see https://golang.org/doc/install/source#environment
# see also http://build.golang.org/
# and canonically, see defs_OS_ARCH.h files in src/runtime
# https://code.google.com/p/go/source/browse?name=go1.4beta1#hg%2Fsrc%2Fruntime
ENV GOLANG_CROSSPLATFORMS \
android/arm \
darwin/386 darwin/amd64 \
dragonfly/386 dragonfly/amd64 \
freebsd/386 freebsd/amd64 freebsd/arm \
linux/386 linux/amd64 linux/arm \
nacl/386 nacl/amd64p32 nacl/arm \
netbsd/386 netbsd/amd64 netbsd/arm \
openbsd/386 openbsd/amd64 \
plan9/386 plan9/amd64 \
solaris/amd64 \
windows/386 windows/amd64

# ls src/runtime/defs_*_*.h | sed -r 's!^.*/defs_([^_]+)_([^_]+)[.]h$!\1/\2!'

# (set an explicit GOARM of 5 for maximum ARM compatibility)
ENV GOARM 5

RUN cd /usr/src/go/src \
&& set -ex \
&& for platform in $GOLANG_CROSSPLATFORMS; do \
GOOS=${platform%/*} \
GOARCH=${platform##*/} \
./make.bash --no-clean 2>&1; \
done
89 changes: 89 additions & 0 deletions 1.4/go-wrapper
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
#!/bin/bash
set -e

usage() {
base="$(basename "$0")"
cat <<EOUSAGE

usage: $base command [args]

This script assumes that is is run from the root of your Go package (for
example, "/go/src/app" if your GOPATH is set to "/go").

The main feature of this wrapper over the native "go" tool is that it supports
the addition of a ".godir" file in your package directory which is a plain text
file that is the import path your application expects (ie, it would be something
like "github.com/jsmith/my-cool-app"). If this file is found, the current
package is then symlinked to /go/src/<.gopath> and the commands then use that
full import path to act on it. This allows for applications to be universally
cloned into a path like "/go/src/app" and then automatically built properly so
that inter-package imports use the existing source instead of downloading it a
second time. This also makes the final binary have the correct name (ie,
instead of being "/go/bin/app", it can be "/go/bin/my-cool-app"), which is why
the "run" command exists here.

Available Commands:

$base download
$base download -u
(equivalent to "go get -d [args] [godir]")

$base install
$base install -race
(equivalent to "go install [args] [godir]")

$base run
$base run -app -specific -arguments
(assumes "GOPATH/bin" is in "PATH")

EOUSAGE
}

# "shift" so that "$@" becomes the remaining arguments and can be passed along to other "go" subcommands easily
cmd="$1"
if ! shift; then
usage >&2
exit 1
fi

dir="$(pwd -P)"
goBin="$(basename "$dir")" # likely "app"

goDir=
if [ -f .godir ]; then
goDir="$(cat .godir)"
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")"
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
11 changes: 11 additions & 0 deletions 1.4/onbuild/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM golang:1.4rc1

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
24 changes: 24 additions & 0 deletions 1.4/wheezy/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
FROM debian:wheezy

# SCMs for "go get", gcc for cgo
RUN apt-get update && apt-get install -y \
ca-certificates curl gcc libc6-dev make \
bzr git mercurial \
--no-install-recommends \
&& rm -rf /var/lib/apt/lists/*

ENV GOLANG_VERSION 1.4rc1

RUN curl -sSL https://golang.org/dl/go$GOLANG_VERSION.src.tar.gz \
| tar -v -C /usr/src -xz

RUN cd /usr/src/go/src && ./make.bash --no-clean 2>&1

ENV PATH /usr/src/go/bin:$PATH

RUN mkdir -p /go/src
ENV GOPATH /go
ENV PATH /go/bin:$PATH
WORKDIR /go

COPY go-wrapper /usr/local/bin/
89 changes: 89 additions & 0 deletions 1.4/wheezy/go-wrapper
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
#!/bin/bash
set -e

usage() {
base="$(basename "$0")"
cat <<EOUSAGE

usage: $base command [args]

This script assumes that is is run from the root of your Go package (for
example, "/go/src/app" if your GOPATH is set to "/go").

The main feature of this wrapper over the native "go" tool is that it supports
the addition of a ".godir" file in your package directory which is a plain text
file that is the import path your application expects (ie, it would be something
like "github.com/jsmith/my-cool-app"). If this file is found, the current
package is then symlinked to /go/src/<.gopath> and the commands then use that
full import path to act on it. This allows for applications to be universally
cloned into a path like "/go/src/app" and then automatically built properly so
that inter-package imports use the existing source instead of downloading it a
second time. This also makes the final binary have the correct name (ie,
instead of being "/go/bin/app", it can be "/go/bin/my-cool-app"), which is why
the "run" command exists here.

Available Commands:

$base download
$base download -u
(equivalent to "go get -d [args] [godir]")

$base install
$base install -race
(equivalent to "go install [args] [godir]")

$base run
$base run -app -specific -arguments
(assumes "GOPATH/bin" is in "PATH")

EOUSAGE
}

# "shift" so that "$@" becomes the remaining arguments and can be passed along to other "go" subcommands easily
cmd="$1"
if ! shift; then
usage >&2
exit 1
fi

dir="$(pwd -P)"
goBin="$(basename "$dir")" # likely "app"

goDir=
if [ -f .godir ]; then
goDir="$(cat .godir)"
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")"
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
2 changes: 1 addition & 1 deletion generate-stackbrew-library.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ echo '# maintainer: Johan Euphrosine <[email protected]> (@proppy)'
for version in "${versions[@]}"; do
commit="$(git log -1 --format='format:%H' -- "$version")"
fullVersion="$(grep -m1 'ENV GOLANG_VERSION ' "$version/Dockerfile" | cut -d' ' -f3)"
[[ "$fullVersion" == *.*.* ]] || fullVersion+='.0'
[[ "$fullVersion" == *.*[^0-9]* ]] || fullVersion+='.0'
versionAliases=( $fullVersion $version ${aliases[$version]} )

echo
Expand Down
2 changes: 1 addition & 1 deletion update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ versions=( "${versions[@]%/}" )
for version in "${versions[@]}"; do
fullVersion="$(curl -sSL 'https://golang.org/dl' | grep '">go'"$version"'.*\.src.tar.gz<' | sed -r 's!.*go([^"/<]+)\.src\.tar\.gz.*!\1!' | sort -V | tail -1)"
versionTag="$fullVersion"
[[ "$versionTag" == *.*.* ]] || versionTag+='.0'
[[ "$versionTag" == *.*[^0-9]* ]] || versionTag+='.0'
(
set -x
sed -ri 's/^(ENV GOLANG_VERSION) .*/\1 '"$fullVersion"'/' "$version/Dockerfile"
Expand Down