Last Updated: February 25, 2016
·
2.126K
· stephanep

Dockerfile golang example

FROM ubuntu:14.04

# env vars
ENV HOME /root
ENV GOPATH /root/go
ENV PATH /root/go/bin:/usr/local/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
ENV MONGO_URL <MONGO_URL>
RUN mkdir -p /root/.ssh
ADD id_rsa /root/.ssh/id_rsa
RUN chmod 700 /root/.ssh/id_rsa
RUN echo "Host github.com\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config

# GOPATH
RUN mkdir -p /root/go

RUN apt-get update
RUN apt-get install -y build-essential mercurial git subversion wget curl bzr

# go 1.3 tarball
RUN wget -qO- http://golang.org/dl/go1.3.linux-amd64.tar.gz | tar -C /usr/local -xzf -

RUN go get github.com/go-martini/martini
RUN go get github.com/martini-contrib/binding
RUN go get github.com/martini-contrib/cors
RUN go get github.com/martini-contrib/render
RUN go get github.com/martini-contrib/sessions
RUN go get github.com/martini-contrib/strict
RUN go get github.com/huandu/facebook
RUN go get gopkg.in/mgo.v2
RUN go get github.com/zhengying/apns
RUN go get github.com/satori/go.uuid
RUN go get launchpad.net/goamz/aws
RUN go get launchpad.net/goamz/s3
RUN go get github.com/nfnt/resize

RUN mkdir -p $GOPATH/src/github.com/kwirkco
RUN cd $GOPATH/src/github.com/kwirkco/; git clone git@github.com:Kwirkco/mobile_api.git
WORKDIR /root/go
EXPOSE 8080
CMD go run src/github.com/kwirkco/mobile_api/server.go