adding docker image build
Signed-off-by: Martin Buchleitner <mbuchleitner@infralovers.com>
This commit is contained in:
parent
f72b873ef9
commit
83f84922a0
|
|
@ -0,0 +1,2 @@
|
||||||
|
Dockerfile
|
||||||
|
.travis.yml
|
||||||
|
|
@ -0,0 +1,25 @@
|
||||||
|
FROM golang:stretch as builder
|
||||||
|
|
||||||
|
RUN mkdir -p $GOPATH/pkg/mod $GOPATH/bin
|
||||||
|
|
||||||
|
RUN apt-get update \
|
||||||
|
&& apt-get install -y ruby ruby-dev curl \
|
||||||
|
&& gem install --no-document fpm \
|
||||||
|
&& curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh \
|
||||||
|
&& mkdir -p $GOPATH/src/github.com/davidnewhall
|
||||||
|
|
||||||
|
COPY . $GOPATH/src/github.com/davidnewhall/unifi-poller
|
||||||
|
WORKDIR $GOPATH/src/github.com/davidnewhall/unifi-poller
|
||||||
|
|
||||||
|
RUN dep ensure \
|
||||||
|
&& make dockerbin
|
||||||
|
|
||||||
|
FROM scratch
|
||||||
|
|
||||||
|
COPY --from=builder /go/src/github.com/davidnewhall/unifi-poller/unifi-poller.dockerbin /unifi-poller
|
||||||
|
COPY --from=builder /go/src/github.com/davidnewhall/unifi-poller/examples/up.conf.example /etc/unifi-poller/up.conf
|
||||||
|
|
||||||
|
VOLUME [ "/etc/unifi-poller"]
|
||||||
|
|
||||||
|
ENTRYPOINT [ "/unifi-poller" ]
|
||||||
|
CMD [ "--config=/etc/unifi-poller/up.conf" ]
|
||||||
10
Makefile
10
Makefile
|
|
@ -9,6 +9,7 @@ OSX_PKG_PREFIX=com.github.davidnewhall
|
||||||
GOLANGCI_LINT_ARGS=--enable-all -D gochecknoglobals
|
GOLANGCI_LINT_ARGS=--enable-all -D gochecknoglobals
|
||||||
PACKAGE:=./cmd/$(BINARY)
|
PACKAGE:=./cmd/$(BINARY)
|
||||||
LIBRARY:=./pkg/$(BINARY)
|
LIBRARY:=./pkg/$(BINARY)
|
||||||
|
DOCKER_REPO=""
|
||||||
|
|
||||||
ITERATION:=$(shell git rev-list --count HEAD||echo 0)
|
ITERATION:=$(shell git rev-list --count HEAD||echo 0)
|
||||||
ifeq ($(VERSION),)
|
ifeq ($(VERSION),)
|
||||||
|
|
@ -69,6 +70,12 @@ $(BINARY).linux:
|
||||||
# Building linux binary.
|
# Building linux binary.
|
||||||
GOOS=linux go build -o $(BINARY).linux -ldflags "-w -s -X github.com/davidnewhall/unifi-poller/pkg/unifi-poller.Version=$(VERSION)" $(PACKAGE)
|
GOOS=linux go build -o $(BINARY).linux -ldflags "-w -s -X github.com/davidnewhall/unifi-poller/pkg/unifi-poller.Version=$(VERSION)" $(PACKAGE)
|
||||||
|
|
||||||
|
dockerbin: $(BINARY).dockerbin
|
||||||
|
$(BINARY).dockerbin:
|
||||||
|
# Building linux binary.
|
||||||
|
CGO_ENABLED=0 GOOS=linux go build -o $(BINARY).dockerbin -ldflags "-w -s -X github.com/davidnewhall/unifi-poller/pkg/unifi-poller.Version=$(VERSION)" $(PACKAGE)
|
||||||
|
|
||||||
|
|
||||||
macos: $(BINARY).macos
|
macos: $(BINARY).macos
|
||||||
$(BINARY).macos:
|
$(BINARY).macos:
|
||||||
# Building darwin binary.
|
# Building darwin binary.
|
||||||
|
|
@ -122,6 +129,9 @@ $(BINARY)-$(VERSION).pkg: check_fpm package_build_osx
|
||||||
--description "$(DESC)" \
|
--description "$(DESC)" \
|
||||||
--chdir package_build_osx
|
--chdir package_build_osx
|
||||||
|
|
||||||
|
docker:
|
||||||
|
docker build -t ${DOCKER_REPO}/${BINARY} .
|
||||||
|
|
||||||
# OSX packages use /usr/local because Apple doesn't allow writing many other places.
|
# OSX packages use /usr/local because Apple doesn't allow writing many other places.
|
||||||
package_build_osx: readme man macos
|
package_build_osx: readme man macos
|
||||||
# Building package environment for macOS.
|
# Building package environment for macOS.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue