From 36e84da7b5e8a242df1e46e5c7e5fdbf20384728 Mon Sep 17 00:00:00 2001 From: Mathias Kaufmann Date: Tue, 13 Mar 2018 23:52:03 +0100 Subject: [PATCH 1/3] Added Dockerfile Signed-off-by: Mathias Kaufmann --- .dockerignore | 7 +++++++ Dockerfile | 17 +++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..4549da4 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,7 @@ +**/* +!.git/ +!*.go +!GNUmakefile +!common.mk +!Dockerfile +!.dockerignore \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..1bb5e5b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,17 @@ +FROM golang:1.10 AS goircd-builder +ARG PACKAGE=github.com/bbusse/goircd +ENV PACKAGE=$PACKAGE + +WORKDIR /go/src/github.com/bbusse/goircd/ + +ADD . /go/src/github.com/bbusse/goircd/ + +RUN export CGO_ENABLED=0 \ + && go get $PACKAGE \ + && make -f GNUmakefile goircd \ + && mv goircd /go/bin/goircd + +FROM alpine AS goircd +COPY --from=goircd-builder /go/bin/goircd /bin/goircd +ENTRYPOINT ["sh","-c"] +CMD ["exec goircd"] \ No newline at end of file From eeb6782f0f441b3634ebe3dfc585baea2864ac7f Mon Sep 17 00:00:00 2001 From: Mathias Kaufmann Date: Wed, 14 Mar 2018 00:10:00 +0100 Subject: [PATCH 2/3] Added make targets to build and push docker images Usage: `make docker-image` to build the image `make docker-image-push` to build and push the image Signed-off-by: Mathias Kaufmann --- Dockerfile | 4 ++-- GNUmakefile | 3 ++- common.mk | 14 ++++++++++++++ 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 1bb5e5b..9708ce4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,9 +2,9 @@ FROM golang:1.10 AS goircd-builder ARG PACKAGE=github.com/bbusse/goircd ENV PACKAGE=$PACKAGE -WORKDIR /go/src/github.com/bbusse/goircd/ +WORKDIR /go/src/$PACKAGE/ -ADD . /go/src/github.com/bbusse/goircd/ +ADD . /go/src/$PACKAGE/ RUN export CGO_ENABLED=0 \ && go get $PACKAGE \ diff --git a/GNUmakefile b/GNUmakefile index 04d452d..c7aeb93 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -1,3 +1,4 @@ VERSION = $(shell git describe --tags) +PACKAGE ?= quay.io/goircd/goircd -include common.mk +include common.mk \ No newline at end of file diff --git a/common.mk b/common.mk index 888e048..ed5b175 100644 --- a/common.mk +++ b/common.mk @@ -2,3 +2,17 @@ LDFLAGS = -X main.version=$(VERSION) goircd: *.go go build -ldflags "$(LDFLAGS)" + +docker-image: *.go Dockerfile .dockerignore + docker build -t $(shell basename $(PACKAGE)):$(VERSION) . + +docker-image-push: docker-image-push-latest docker-image-push-version + @true + +docker-image-push-version: docker-image-push-latest docker-image-push-version + docker tag $(shell basename $(PACKAGE)):$(VERSION) $(PACKAGE):$(VERSION) + docker push $(PACKAGE):$(VERSION) + +docker-image-push-latest: docker-image + docker tag $(shell basename $(PACKAGE)):$(VERSION) $(PACKAGE):latest + docker push $(PACKAGE):latest From c8e83bb840f3f4972f9dd1aaea13b2a6d17f6191 Mon Sep 17 00:00:00 2001 From: Mathias Kaufmann Date: Wed, 14 Mar 2018 00:11:01 +0100 Subject: [PATCH 3/3] Added trailing newline Signed-off-by: Mathias Kaufmann --- GNUmakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GNUmakefile b/GNUmakefile index c7aeb93..91a9baa 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -1,4 +1,4 @@ VERSION = $(shell git describe --tags) PACKAGE ?= quay.io/goircd/goircd -include common.mk \ No newline at end of file +include common.mk