Created
March 9, 2014 01:38
-
-
Save mrryanjohnston/9441704 to your computer and use it in GitHub Desktop.
Golang development environment using Docker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM ubuntu:13.10 | |
RUN apt-get update | |
RUN DEBIAN_FRONTEND=noninteractive apt-get -y install golang | |
RUN mkdir /go | |
RUN export GOPATH=/go | |
ENV GOPATH /go | |
RUN export PATH=$PATH:$GOPATH/bin | |
ENV PATH $PATH:$GOPATH/bin | |
WORKDIR /go | |
CMD go install hello && hello |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Taken directly from http://golang.org/ | |
// /home/yourusername/go/src/hello/hello.go | |
package main | |
import "fmt" | |
func main() { | |
fmt.Println("Hello, 世界") | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# cd to the directory with the Dockerfile in it, | |
# then run | |
sudo docker build -t ubuntu-go . | |
# To run the container the first time, do | |
sudo docker run -v /home/yourusername/go:/go -name go ubuntu-go | |
# If you make changes to the hello package, just run | |
sudo docker start -a go |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sources I used to figure this stuff out (thanks!):
http://golang.org/doc/install
http://docs.docker.io/en/latest/reference/commandline/
https://www.digitalocean.com/community/articles/docker-explained-using-dockerfiles-to-automate-building-of-images