From 5a2f0544ae4188f251c9dca7da3499c54cf2d7b0 Mon Sep 17 00:00:00 2001 From: DataHearth Date: Mon, 15 Mar 2021 19:11:52 +0100 Subject: [PATCH] add docker and makefile --- .dockerignore | 3 +++ .gitignore | 3 ++- Dockerfile | 14 ++++++++++++++ Makefile | 31 +++++++++++++++++++++++++++++++ 4 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 Makefile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..e5f7391 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,3 @@ +ddnsclient.yaml.sample +README.md +bin \ No newline at end of file diff --git a/.gitignore b/.gitignore index 8a079d3..cdae886 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -ddns-client.yaml \ No newline at end of file +ddnsclient.yaml +bin \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..96f28c7 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,14 @@ +FROM golang:1.15 as base + +WORKDIR /go/src/ddnsclient +ADD . /go/src/ddnsclient + +RUN go get -d -v ./... + +RUN go build -o /go/bin/ddnsclient cmd/main.go + +FROM gcr.io/distroless/base + +COPY --from=base /go/bin/ddnsclient / + +CMD ["/ddnsclient"] \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..7f86d26 --- /dev/null +++ b/Makefile @@ -0,0 +1,31 @@ +GO := $(shell command -v go 2> /dev/null) +DOCKER := $(shell command -v docker 2> /dev/null) +RELEASE_VERSION ?= $(shell bash -c 'read -s -p "Release version: " pwd') + +.PHONY: build +build: +ifndef GO + @echo "go is required!" +endif + @echo "building ddnsclient..." + @go build -o bin/ddnsclient cmd/main.go + @echo "module built!" + +.PHONY: deploy-image-latest +deploy-image: +ifndef DOCKER + @echo "docker is required!" +endif + @echo "Pushing image ddnsclient:latest to docker hub..." + @docker push ddnsclient:latest + @echo "Image pushed!" + +.PHONY: deploy-Release +deploy-Release: +ifndef DOCKER + @echo "docker is required!" +endif + @echo "Pushing image ddnsclient:$(RELEASE_VERSION) to docker hub..." + @docker push ddnsclient:$(RELEASE_VERSION) + @echo "Image pushed!" +