Skip to content

Instantly share code, notes, and snippets.

@buddhike
Last active May 12, 2017 22:00
Show Gist options
  • Save buddhike/5d36a51f3dd920b1cc27b30536d963bb to your computer and use it in GitHub Desktop.
Save buddhike/5d36a51f3dd920b1cc27b30536d963bb to your computer and use it in GitHub Desktop.
Container with go toolchain.
# Container with go toolchain.
# Create a directory in host and map it to /go volume to persist data between
# multiple commands.
# Usage:
# docker build -t go
# docker run --rm -v [dir-in-host]:/go -v $GOPATH/src/app:/go/src/app go get app
# docker run --rm -v [dir-in-host]:/go -v $GOPATH/src/app:/go/src/app go test app
# docker run --rm -v [dir-in-host]:/go -v $GOPATH/src/app:/go/src/app go build -o app/build/out app
#
FROM centos
ENV DOWNLOADS /downloads
ENV TOOLS /tools
ENV GOROOT $TOOLS/go
ENV GOPATH /go
ENV PATH $GOROOT/bin:$PATH
RUN GO_VERSION="go1.8.linux-amd64.tar.gz" && \
mkdir -p $GOPATH/src && \
mkdir -p $GOROOT && \
mkdir -p $DOWNLOADS && \
curl -o "$DOWNLOADS/$GO_VERSION" "https://storage.googleapis.com/golang/$GO_VERSION" && \
tar xz -C "$TOOLS" -f "$DOWNLOADS/$GO_VERSION" && \
yum install -y git
ENTRYPOINT ["go"]
WORKDIR $GOPATH/src
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment