From d6a9b30ea1e157a9d0ca7db76f66cb9c9e144440 Mon Sep 17 00:00:00 2001 From: Oliver Sterzel Date: Sun, 26 Jun 2016 23:29:22 +0100 Subject: [PATCH] Make the clam-rest container tiny --- Dockerfile | 11 +++-------- Makefile | 1 + scripts/build-static-binary | 3 +++ 3 files changed, 7 insertions(+), 8 deletions(-) create mode 100755 scripts/build-static-binary diff --git a/Dockerfile b/Dockerfile index 322bf76..bc97478 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,12 +1,7 @@ -FROM golang:1.3 +FROM scratch -ADD . /go/src/github.com/osterzel/clamrest +ADD target/clamrest / -WORKDIR /go/src/github.com/osterzel/clamrest -RUN go get -RUN go install github.com/osterzel/clamrest -RUN rm -rf /go/src/github.com/osterzel/clamrest - -ENTRYPOINT /go/bin/clamrest +CMD ["/clamrest"] EXPOSE 8080 diff --git a/Makefile b/Makefile index 175d68b..88c83e7 100644 --- a/Makefile +++ b/Makefile @@ -6,6 +6,7 @@ run-container: .clamav build-container @docker run -d -p 9000:9000 -e PORT=9000 --name $(SERVICE) --link clamd:clamd $(SERVICE):$(VERSION) build-container: + docker run --rm -t -i -v $(shell pwd):/go/src/github.com/osterzel/clamrest -v $(shell pwd)/target:/go/bin golang:1.3 /bin/bash -c "/go/src/github.com/osterzel/clamrest/scripts/build-static-binary" docker build -t $(SERVICE):$(VERSION) . run-slug: .clamav build-slug diff --git a/scripts/build-static-binary b/scripts/build-static-binary new file mode 100755 index 0000000..89aaa39 --- /dev/null +++ b/scripts/build-static-binary @@ -0,0 +1,3 @@ +cd /go/src/github.com/osterzel/clamrest +go get +CGO_ENABLED=0 GOOS=linux go install -a -installsuffix cgo