Add Docker labels.
This commit is contained in:
parent
e0a3ef38fe
commit
e18f17f9f9
|
|
@ -32,7 +32,8 @@ ifeq ($(VERSION),)
|
||||||
endif
|
endif
|
||||||
# rpm is wierd and changes - to _ in versions.
|
# rpm is wierd and changes - to _ in versions.
|
||||||
RPMVERSION:=$(shell echo $(VERSION) | tr -- - _)
|
RPMVERSION:=$(shell echo $(VERSION) | tr -- - _)
|
||||||
DATE:=$(shell date)
|
DATE:=$(shell date -u +%Y-%m-%dT%H:%M:%SZ)
|
||||||
|
COMMIT:=$(shell git rev-parse --short HEAD || echo 0)
|
||||||
|
|
||||||
# Makefile targets follow.
|
# Makefile targets follow.
|
||||||
|
|
||||||
|
|
@ -264,7 +265,11 @@ $(BINARY)_$(VERSION)-$(ITERATION)_armhf.deb: package_build_linux_armhf check_fpm
|
||||||
--chdir $<
|
--chdir $<
|
||||||
|
|
||||||
docker:
|
docker:
|
||||||
docker build -f init/docker/Dockerfile -t $(DHUSER)/$(BINARY):local .
|
docker build -f init/docker/Dockerfile \
|
||||||
|
--build-arg "BUILD_DATE=${DATE}" \
|
||||||
|
--build-arg "COMMIT=${COMMIT}" \
|
||||||
|
--build-arg "VERSION=${VERSION}" \
|
||||||
|
--tag $(DHUSER)/$(BINARY):local .
|
||||||
|
|
||||||
# Build an environment that can be packaged for linux.
|
# Build an environment that can be packaged for linux.
|
||||||
package_build_linux: readme man linux
|
package_build_linux: readme man linux
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,15 @@
|
||||||
# building static go binary with Debian golang container
|
# building static go binary with Debian golang container
|
||||||
#
|
#
|
||||||
|
|
||||||
FROM golang:stretch as builder
|
|
||||||
ARG ARCH=amd64
|
ARG ARCH=amd64
|
||||||
ARG OS=linux
|
ARG OS=linux
|
||||||
|
ARG BUILD_DATE=0
|
||||||
|
ARG COMMIT=0
|
||||||
|
ARG VERSION=development
|
||||||
|
|
||||||
|
FROM golang:stretch as builder
|
||||||
|
ARG ARCH
|
||||||
|
ARG OS
|
||||||
|
|
||||||
RUN mkdir -p $GOPATH/pkg/mod $GOPATH/bin $GOPATH/src/github.com/davidnewhall/unifi-poller
|
RUN mkdir -p $GOPATH/pkg/mod $GOPATH/bin $GOPATH/src/github.com/davidnewhall/unifi-poller
|
||||||
RUN apt-get update \
|
RUN apt-get update \
|
||||||
|
|
@ -15,8 +21,7 @@ COPY . $GOPATH/src/github.com/davidnewhall/unifi-poller
|
||||||
WORKDIR $GOPATH/src/github.com/davidnewhall/unifi-poller
|
WORKDIR $GOPATH/src/github.com/davidnewhall/unifi-poller
|
||||||
|
|
||||||
RUN dep ensure --vendor-only \
|
RUN dep ensure --vendor-only \
|
||||||
&& CGO_ENABLED=0 make unifi-poller.${ARCH}.${OS} \
|
&& CGO_ENABLED=0 make unifi-poller.${ARCH}.${OS}
|
||||||
&& mv unifi-poller.${ARCH}.${OS} unifi-poller
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# creating container for run
|
# creating container for run
|
||||||
|
|
@ -28,8 +33,27 @@ RUN dep ensure --vendor-only \
|
||||||
#
|
#
|
||||||
|
|
||||||
FROM scratch
|
FROM scratch
|
||||||
|
ARG ARCH
|
||||||
|
ARG OS
|
||||||
|
ARG BUILD_DATE
|
||||||
|
ARG COMMIT
|
||||||
|
ARG VERSION
|
||||||
|
|
||||||
COPY --from=builder /go/src/github.com/davidnewhall/unifi-poller/unifi-poller /unifi-poller
|
# Build-time metadata as defined at https://github.com/opencontainers/image-spec/blob/master/annotations.md
|
||||||
|
LABEL org.opencontainers.image.created="${BUILD_DATE}" \
|
||||||
|
org.opencontainers.image.title="UniFi Poller" \
|
||||||
|
org.opencontainers.image.documentation="https://github.com/davidnewhall/unifi-poller/wiki" \
|
||||||
|
org.opencontainers.image.description="Polls a UniFi controller and stores metrics in InfluxDB" \
|
||||||
|
org.opencontainers.image.url="https://github.com/davidnewhall/unifi-poller" \
|
||||||
|
org.opencontainers.image.revision="${COMMIT}" \
|
||||||
|
org.opencontainers.image.source="https://github.com/davidnewhall/unifi-poller" \
|
||||||
|
org.opencontainers.image.vendor="Go Lift" \
|
||||||
|
org.opencontainers.image.authors="David Newhall II <david at sleepers dot pro>" \
|
||||||
|
org.opencontainers.image.architecture="${OS} ${ARCH}" \
|
||||||
|
org.opencontainers.image.licenses="MIT" \
|
||||||
|
org.opencontainers.image.version="${VERSION}"
|
||||||
|
|
||||||
|
COPY --from=builder /go/src/github.com/davidnewhall/unifi-poller/unifi-poller.${ARCH}.${OS} /unifi-poller
|
||||||
COPY --from=builder /go/src/github.com/davidnewhall/unifi-poller/examples/up.conf.example /etc/unifi-poller/up.conf
|
COPY --from=builder /go/src/github.com/davidnewhall/unifi-poller/examples/up.conf.example /etc/unifi-poller/up.conf
|
||||||
|
|
||||||
VOLUME [ "/etc/unifi-poller" ]
|
VOLUME [ "/etc/unifi-poller" ]
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,10 @@ set -e -o pipefail
|
||||||
# The Docker Cloud config must pass in the BUILDS env variable.
|
# The Docker Cloud config must pass in the BUILDS env variable.
|
||||||
# See README.md (in this dir) and the screenshot for more info.
|
# See README.md (in this dir) and the screenshot for more info.
|
||||||
|
|
||||||
|
VERSION=$(git tag -l --merged | tail -n1 | tr -d v) # 1.2.3
|
||||||
|
DATE=$(date -u +%Y-%m-%dT%H:%M:%SZ)
|
||||||
|
COMMIT=$(git rev-parse --short HEAD)
|
||||||
|
|
||||||
# Build each configured image from Docker Cloud.
|
# Build each configured image from Docker Cloud.
|
||||||
for build in $BUILDS; do
|
for build in $BUILDS; do
|
||||||
# os:name:arch:variant
|
# os:name:arch:variant
|
||||||
|
|
@ -15,6 +19,9 @@ for build in $BUILDS; do
|
||||||
echo "Building Image ${IMAGE_NAME}_${os}_${name}"
|
echo "Building Image ${IMAGE_NAME}_${os}_${name}"
|
||||||
docker build \
|
docker build \
|
||||||
--build-arg "ARCH=${name}" \
|
--build-arg "ARCH=${name}" \
|
||||||
|
--build-arg "BUILD_DATE=${DATE}" \
|
||||||
|
--build-arg "COMMIT=${COMMIT}" \
|
||||||
|
--build-arg "VERSION=${VERSION}" \
|
||||||
--tag "${IMAGE_NAME}_${os}_${name}" \
|
--tag "${IMAGE_NAME}_${os}_${name}" \
|
||||||
--file Dockerfile ../..
|
--file Dockerfile ../..
|
||||||
done
|
done
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue