diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..eff49aa --- /dev/null +++ b/Dockerfile @@ -0,0 +1,16 @@ +FROM golang:1.9.3-stretch AS build-env + +RUN go-wrapper download github.com/golang/dep/cmd/dep && go-wrapper install github.com/golang/dep/cmd/dep + +WORKDIR /go/src/github.com/larsp/co2monitor + +# only copy Gopkg.toml and Gopkg.lock for now so dep ensure run keeps cached till those files are changed +COPY Gopkg.* ./ +RUN dep ensure -v --vendor-only + +COPY . ./ +RUN CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=6 go build -v -ldflags "-w -s" -a -installsuffix cgo -o /out/co2monitor + +FROM scratch +COPY --from=build-env /out/co2monitor / +ENTRYPOINT [ "./co2monitor" ] \ No newline at end of file diff --git a/Makefile b/Makefile index 38a71dc..a192f90 100644 --- a/Makefile +++ b/Makefile @@ -7,6 +7,9 @@ build: build_pi: GOOS=linux GOARCH=arm GOARM=6 go build -v +build_docker_pi: + docker build . + test: go test --race -v ./...