docker updates
This commit is contained in:
parent
e2621248e5
commit
369cf612c6
|
|
@ -10,7 +10,7 @@
|
||||||
/unifi-poller.*.macos
|
/unifi-poller.*.macos
|
||||||
/unifi-poller.*.linux
|
/unifi-poller.*.linux
|
||||||
/unifi-poller.rb
|
/unifi-poller.rb
|
||||||
*.sha256
|
checksums.sha256.txt
|
||||||
/vendor
|
/vendor
|
||||||
.DS_Store
|
.DS_Store
|
||||||
*~
|
*~
|
||||||
|
|
|
||||||
6
Makefile
6
Makefile
|
|
@ -36,10 +36,10 @@ VERSION_PATH:=github.com/$(GHUSER)/$(BINARY)/$(shell echo $(BINARY) | tr -d -- -
|
||||||
all: man build
|
all: man build
|
||||||
|
|
||||||
# Prepare a release. Called in Travis CI.
|
# Prepare a release. Called in Travis CI.
|
||||||
release: clean vendor test macos arm arm64 windows linux_packages
|
release: clean vendor test macos arm windows linux_packages
|
||||||
# Prepareing a release!
|
# Prepareing a release!
|
||||||
mkdir -p $@
|
mkdir -p $@
|
||||||
mv $(BINARY).*.linux $(BINARY).*.macos $@/
|
mv $(BINARY).*.{macos,linux} $@/
|
||||||
gzip -9r $@/
|
gzip -9r $@/
|
||||||
for i in $(BINARY)*.exe; do zip -9qm $@/$$i.zip $$i;done
|
for i in $(BINARY)*.exe; do zip -9qm $@/$$i.zip $$i;done
|
||||||
mv *.rpm *.deb $@/
|
mv *.rpm *.deb $@/
|
||||||
|
|
@ -49,7 +49,7 @@ release: clean vendor test macos arm arm64 windows linux_packages
|
||||||
# Delete all build assets.
|
# Delete all build assets.
|
||||||
clean:
|
clean:
|
||||||
# Cleaning up.
|
# Cleaning up.
|
||||||
rm -f $(BINARY) $(BINARY).*.{macos,linux,exe}{,.gz} $(BINARY).1{,.gz} $(BINARY).rb
|
rm -f $(BINARY) $(BINARY).*.{macos,linux,exe}{,.gz,.zip} $(BINARY).1{,.gz} $(BINARY).rb
|
||||||
rm -f $(BINARY){_,-}*.{deb,rpm} v*.tar.gz.sha256
|
rm -f $(BINARY){_,-}*.{deb,rpm} v*.tar.gz.sha256
|
||||||
rm -f cmd/$(BINARY)/README{,.html} README{,.html} ./$(BINARY)_manual.html
|
rm -f cmd/$(BINARY)/README{,.html} README{,.html} ./$(BINARY)_manual.html
|
||||||
rm -rf package_build_* release
|
rm -rf package_build_* release
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
#
|
#
|
||||||
# building static go binary with Debian golang container
|
# building static go binary with Debian golang container
|
||||||
#
|
#
|
||||||
ARG ARCH=amd64
|
|
||||||
|
|
||||||
FROM golang:stretch as builder
|
FROM golang:stretch as builder
|
||||||
ARG ARCH
|
ARG ARCH=amd64
|
||||||
|
ARG OS=linux
|
||||||
|
|
||||||
RUN mkdir -p $GOPATH/pkg/mod $GOPATH/bin $GOPATH/src/github.com/davidnewhall
|
RUN mkdir -p $GOPATH/pkg/mod $GOPATH/bin $GOPATH/src/github.com/davidnewhall
|
||||||
RUN apt-get update \
|
RUN apt-get update \
|
||||||
|
|
@ -15,7 +15,8 @@ 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}.linux
|
&& CGO_ENABLED=0 make unifi-poller.${ARCH}.${OS}
|
||||||
|
&& mv unifi-poller.${ARCH}.${OS} unifi-poller
|
||||||
|
|
||||||
#
|
#
|
||||||
# creating container for run
|
# creating container for run
|
||||||
|
|
@ -25,10 +26,8 @@ RUN dep ensure --vendor-only \
|
||||||
#
|
#
|
||||||
# by using "-e UNIFI_PASSWORD=your-secret-pasword" you can avoid this configuration in the config file
|
# by using "-e UNIFI_PASSWORD=your-secret-pasword" you can avoid this configuration in the config file
|
||||||
#
|
#
|
||||||
FROM scratch
|
|
||||||
ARG ARCH
|
|
||||||
|
|
||||||
COPY --from=builder /go/src/github.com/davidnewhall/unifi-poller/unifi-poller.${ARCH}.linux /unifi-poller
|
COPY --from=builder /go/src/github.com/davidnewhall/unifi-poller/unifi-poller /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" ]
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,20 @@
|
||||||
# Docker Build Hooks
|
# Docker Build Hooks
|
||||||
|
|
||||||
The files in this folder are used by Docker Cloud to automate image builds.
|
The files in this folder are used by Docker Cloud to automate image builds.
|
||||||
|
|
||||||
|
If you want to build, maintain and push multi-architecture Docker images, you may
|
||||||
|
follow the example provided here. All of the hooks are generic, and will work with
|
||||||
|
any build. Two environment variables must be passed in from Docker Cloud config.
|
||||||
|
`BUILDS` must be set to the builds you're trying to perform. This repo is currently
|
||||||
|
set to `linux:armhf:arm: linux:arm64:arm64:armv8 linux:amd64:amd64: linux:i386:386:`.
|
||||||
|
The format is `os:name:arch:variant`. `os` and `name` are passed into the Dockerfile.
|
||||||
|
`os`, `arch` and `variant` are passed into `docker manifest annotate`. This does not
|
||||||
|
yet work with an OS other than `linux`.
|
||||||
|
|
||||||
|
Keep the build simple; see screenshot. This only supports one build tag, but it creates many more.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
The fancy source tag is `/^v((\d+\.\d+)(?:\.\d+)?)$/` and it allows you to capture
|
||||||
|
the minor version without patch-level in `{\2}`. I no longer use `{\2}` in my build.
|
||||||
|
[See how it works here](https://regex101.com/r/fzt6ki/1).
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,20 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# This always run local to the Dockerfile folder.
|
# This always run local to the Dockerfile folder, so the path is ../..
|
||||||
|
|
||||||
set -e -o pipefail
|
set -e -o pipefail
|
||||||
|
|
||||||
|
# The Docker Cloud config must pass in the BUILDS env variable.
|
||||||
|
# See README.md (in this dir) and the screenshot for more info.
|
||||||
|
|
||||||
|
# Build each configured image from Docker Cloud.
|
||||||
for build in $BUILDS; do
|
for build in $BUILDS; do
|
||||||
|
# os:name:arch:variant
|
||||||
os=$(echo $build | cut -d: -f1)
|
os=$(echo $build | cut -d: -f1)
|
||||||
name=$(echo $build | cut -d: -f2)
|
name=$(echo $build | cut -d: -f2)
|
||||||
echo "Building Image ${IMAGE_NAME}_${os}_${name}"
|
echo "Building Image ${IMAGE_NAME}_${os}_${name}"
|
||||||
docker build --build-arg "ARCH=${name}" --tag "${IMAGE_NAME}_${os}_${name}" --file Dockerfile ../..
|
docker build \
|
||||||
|
--build-arg "ARCH=${name}" \
|
||||||
|
--tag "${IMAGE_NAME}_${os}_${name}" \
|
||||||
|
--file Dockerfile ../..
|
||||||
done
|
done
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,11 @@
|
||||||
|
|
||||||
# https://www.smockle.com/blog/2019/04/22/migrating-from-travis-ci-to-docker-hub-automated-builds/
|
# https://www.smockle.com/blog/2019/04/22/migrating-from-travis-ci-to-docker-hub-automated-builds/
|
||||||
|
|
||||||
|
# This upgrades the docker client on the Docker Cloud server to a version
|
||||||
|
# that contains the `docker manifest` command. To use `docker manifest`
|
||||||
|
# set `DOCKER_CLI_EXPERIMENTAL=enabled` in your build environment.
|
||||||
|
# See README.md (in this dir) and the screenshot for more info.
|
||||||
|
|
||||||
apt-get -y update
|
apt-get -y update
|
||||||
apt-get -y --only-upgrade install docker-ee
|
apt-get -y --only-upgrade install docker-ee
|
||||||
docker run --rm --privileged multiarch/qemu-user-static:register --reset
|
docker run --rm --privileged multiarch/qemu-user-static:register --reset
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,8 @@
|
||||||
# It's all a bit complicated for some reason.
|
# It's all a bit complicated for some reason.
|
||||||
set -e -o pipefail
|
set -e -o pipefail
|
||||||
|
|
||||||
VERSION=$(git tag -l --merged | tail -n1 | tr -d v)
|
VERSION=$(git tag -l --merged | tail -n1 | tr -d v) # 1.2.3
|
||||||
SHORTVER=$(echo $VERSION | cut -d. -f1,2)
|
SHORTVER=$(echo $VERSION | cut -d. -f1,2) # 1.2
|
||||||
if [ "$BUILDS" != "" ] && [ "$VERSION" != "" ]; then
|
if [ "$BUILDS" != "" ] && [ "$VERSION" != "" ]; then
|
||||||
TAGS=latest
|
TAGS=latest
|
||||||
fi
|
fi
|
||||||
|
|
@ -20,16 +20,20 @@ for build in $BUILDS; do
|
||||||
done
|
done
|
||||||
echo "Annotating Images: ${IMAGES}"
|
echo "Annotating Images: ${IMAGES}"
|
||||||
|
|
||||||
[ "$VERSION" != "$SOURCE_BRANCH" ] || TAGS="latest $VERSION $SHORTVER stable"
|
# Build all the Docker tags if the github branch is a release and not master.
|
||||||
|
[ "$SOURCE_BRANCH" == "master" ] || TAGS="latest $VERSION $SHORTVER stable"
|
||||||
echo "Version: $VERSION, Source: $SOURCE_BRANCH, Building tags: ${TAGS}"
|
echo "Version: $VERSION, Source: $SOURCE_BRANCH, Building tags: ${TAGS}"
|
||||||
|
|
||||||
|
# Create multi-architecture manifests for each tag with all the built images.
|
||||||
for tag in $TAGS; do
|
for tag in $TAGS; do
|
||||||
docker manifest create --amend ${DOCKER_REPO}:${tag} $IMAGES
|
docker manifest create --amend ${DOCKER_REPO}:${tag} $IMAGES
|
||||||
for build in $BUILDS; do
|
for build in $BUILDS; do
|
||||||
|
# os:name:arch:variant, ie linux:amd64:amd64: (no variant is ok)
|
||||||
os=$(echo $build | cut -d: -f1)
|
os=$(echo $build | cut -d: -f1)
|
||||||
name=$(echo $build | cut -d: -f2)
|
name=$(echo $build | cut -d: -f2)
|
||||||
arch=$(echo $build | cut -d: -f3)
|
arch=$(echo $build | cut -d: -f3)
|
||||||
vari=$(echo $build | cut -d: -f4)
|
vari=$(echo $build | cut -d: -f4)
|
||||||
|
# Annotating updates the manifest to describe each images' capabilities.
|
||||||
docker manifest annotate ${DOCKER_REPO}:${tag} ${IMAGE_NAME}_${os}_${name} --os ${os} --arch ${arch} --variant "${vari}"
|
docker manifest annotate ${DOCKER_REPO}:${tag} ${IMAGE_NAME}_${os}_${name} --os ${os} --arch ${arch} --variant "${vari}"
|
||||||
done
|
done
|
||||||
echo "Pushing Manifest ${DOCKER_REPO}:${tag}"
|
echo "Pushing Manifest ${DOCKER_REPO}:${tag}"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue