Skip to content

Instantly share code, notes, and snippets.

@buddhike
Last active May 11, 2017 20:48
Show Gist options
  • Save buddhike/93a378133b25bf389310311f9a12f536 to your computer and use it in GitHub Desktop.
Save buddhike/93a378133b25bf389310311f9a12f536 to your computer and use it in GitHub Desktop.
Go app template with dumb-init
FROM centos
ENV DOWNLOADS /home/downloads
ENV TOOLS /home/tools
ENV GOROOT $TOOLS/go
ENV GOPATH /home/go
ENV PATH $GOROOT/bin:$PATH
ENV APP [APP-NAME]
ADD . /home/go/src/$APP
RUN GO_VERSION="go1.8.linux-amd64.tar.gz" && \
mkdir $TOOLS && \
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 && \
cd /home/go/src/$APP && \
go get && \
go test ./... && \
go build -o /usr/bin/$APP && \
cd / && \
curl -o /usr/local/bin/dumb-init https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64
chmod +x /usr/local/bin/dumb-init
yum autoremove -y git && \
yum clean all && \
rm -rf $TOOLS && \
rm -rf $GOPATH && \
rm -rf $DOWNLOADS
WORKDIR /
ENTRYPOINT ["/usr/bin/$APP"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment