From 3a91baab21f999553e2d29b867ec07279a90304a Mon Sep 17 00:00:00 2001 From: Martin Polden Date: Fri, 29 Mar 2019 20:38:43 +0100 Subject: [PATCH] Build without cgo --- Dockerfile | 3 ++- Makefile | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index eee3c56..711588b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,8 @@ FROM golang:1.12-stretch AS build WORKDIR /go/src/github.com/mpolden/echoip COPY . . -ENV GO111MODULE=on +# Must build without cgo because libc is unavailable in runtime image +ENV GO111MODULE=on CGO_ENABLED=0 RUN make # Run diff --git a/Makefile b/Makefile index 6c234b5..7d28655 100644 --- a/Makefile +++ b/Makefile @@ -39,5 +39,10 @@ docker-build: docker-login: @echo "$(DOCKER_PASSWORD)" | docker login -u "$(DOCKER_USERNAME)" --password-stdin -docker-push: docker-login +docker-test: + $(eval CONTAINER=$(shell docker run --rm --detach --publish-all $(DOCKER_IMAGE))) + $(eval DOCKER_PORT=$(shell docker port $(CONTAINER) | cut -d ":" -f 2)) + curl -qfsS -m 5 localhost:$(DOCKER_PORT) > /dev/null; docker stop $(CONTAINER) + +docker-push: docker-test docker-login docker push $(DOCKER_IMAGE)