Skip to content

Instantly share code, notes, and snippets.

@dj95
Created October 1, 2018 17:44
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dj95/66a4066a7d207ad77f969383f60f5509 to your computer and use it in GitHub Desktop.
Save dj95/66a4066a7d207ad77f969383f60f5509 to your computer and use it in GitHub Desktop.
homekit-api dockerfile
# STEP 1 - Build the binary
# use the golang image as build image
FROM golang
# copy the local package files to the container's workspace.
ADD . /go/src/github.com/dj95/homekit-api
# set the working directory to build the application
WORKDIR /go/src/github.com/dj95/homekit-api
# install the go dependencies
RUN go get -u github.com/golang/dep/cmd/dep
RUN dep ensure
# compile the program
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -a -installsuffix cgo -o /go/bin/homekit-api
# STEP 2 - Build a minimal container
# start from scratch
FROM scratch
# copy the static executable
COPY --from=0 /go/bin/homekit-api /go/bin/homekit-api
# define the entrypoint
ENTRYPOINT ["/go/bin/homekit-api"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment