add docker and makefile

This commit is contained in:
DataHearth 2021-03-15 19:11:52 +01:00
parent 05c98a9adb
commit 5a2f0544ae
4 changed files with 50 additions and 1 deletions

3
.dockerignore Normal file
View File

@ -0,0 +1,3 @@
ddnsclient.yaml.sample
README.md
bin

3
.gitignore vendored
View File

@ -1 +1,2 @@
ddns-client.yaml
ddnsclient.yaml
bin

14
Dockerfile Normal file
View File

@ -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"]

31
Makefile Normal file
View File

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