minimal container for go apps
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Dockerfile
Makefile
README.md
main.go

README.md

Minimal Golang App

This repo aims to explore how to build minimal runtime for golang applications

The final docker image size is:

docker images | grep goapp
adolphlwq/goapp latest  b2b7723296db    25 seconds ago       2.01MB

Requisites

  • Docker 17.05 or higher
  • CMake

Dockerfile

FROM golang:1.10-alpine as builder
ADD main.go /go/src/goapp/
RUN cd /go/src/goapp/ && \
    CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o main .

FROM scratch
COPY --from=builder /go/src/goapp/main /
CMD ["/main"]

Reference