Merge pull request #38 from mabunixda/master

adding docker image build
This commit is contained in:
David Newhall II 2019-06-14 00:34:33 -07:00 committed by GitHub
commit cb41816d8b
3 changed files with 40 additions and 0 deletions

View File

@ -0,0 +1,2 @@
Dockerfile
.travis.yml

View File

@ -0,0 +1,34 @@
#
# building static go binary with golang container
#
FROM golang:stretch as builder
RUN mkdir -p $GOPATH/pkg/mod $GOPATH/bin
RUN apt-get update \
&& apt-get install -y curl \
&& 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 \
&& CGO_ENABLED=0 make linux
#
# creating container for run
# to use this container use the following command:
#
# docker run -d -v /your/config/up.conf:/etc/unifi-poller/up.conf golift/unifi-poller
#
# by using "-e UNIFI_PASSWORD=your-secret-pasword" you can avoid this configuration in the config file
#
FROM scratch
COPY --from=builder /go/src/github.com/davidnewhall/unifi-poller/unifi-poller.linux /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" ]

View File

@ -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=golift
ITERATION:=$(shell git rev-list --count HEAD||echo 0) ITERATION:=$(shell git rev-list --count HEAD||echo 0)
ifeq ($(VERSION),) ifeq ($(VERSION),)
@ -122,6 +123,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.