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!" +