Skip to content

Latest commit

 

History

History
51 lines (38 loc) · 1.05 KB

README.md

File metadata and controls

51 lines (38 loc) · 1.05 KB

golang-tool

A tool to compile a Golang application and package it in a minimal Docker container.

Heavily inspired by CenturyLinkLabs/golang-builder.

usage

Create a project folder

$ mkdir /tmp/hello && cd /tmp/hello

Create an Hello world application

$ cat <<EOF > hello-world.go
package main // import "github.com/pierredavidbelanger/hello"
import "fmt"
func main() {
    fmt.Println("hello world")
}
EOF

Compile and package it

$ docker run --rm \
    -v $PWD:/src \
    -v /var/run/docker.sock:/var/run/docker.sock \
    pierredavidbelanger/golang-tool \
    build

Appreciate its size

$ docker images
REPOSITORY                           TAG                 IMAGE ID            CREATED              SIZE
hello                                latest              45cc1f1f326f        About a minute ago   1.3 MB
pierredavidbelanger/golang-tool      latest              98dbd68d4fe4        15 minutes ago       830 MB

Run it

$ docker run --rm hello
hello world