diff --git a/.travis.yml b/.travis.yml index f4ed0fed..0c1436ae 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,15 +1,17 @@ +sudo: true +dist: xenial +language: minimal services: - docker - -jobs: - include: - - stage: "Build and Push" - script: - - docker build -t boerderij/varken:$TRAVIS_BRANCH . - - docker images - - echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin - - docker push boerderij/varken:$TRAVIS_BRANCH - -env: - global: - - secure: c91+zQXN28Anr2q94vhJAzN36teKovgniNmUI0MaejYfwcShN8TVeojkxbP+AxZuvGh1AfvB26LQeuPqAAntoNxvtPg3PLxv93rRSkAf0jk9apm9biYDAJNAM3OSiqCGfzfNhtUHmPmybRy2UmRXpHc6ZU1GmOdX2yyXCC2S6wjJOGabRpCA2Lw1vNnQuSJMDZ78amybZNmqAkK+rxe9hH2TGwcSImW8dlW2Ryt8H4a2s9VW9rbebQF+PzY4pw+OlIarpVUXZzUyEq8PS2EmJTuhrNA+RtZWJ4yRZ33jK4UqZRJzfC4FniZzSqtV/P3YGgSFNzhM87y5VhNiauX6QmtIDfLUV6c86cWCy24O41SrAJQOi4CLszJVkYfyggVFoRFegNS2+njN+f2Bbbx3rHtmNds0cDSfFuK3XhtTe0EhNgHLXOCX4IyAGzYWO+afmbqm/8S+m/QjCT28+0GgxYSqD2qO3FuPRA7woWucrKl2xa/tYikkurkDif0yBHxPac8mB8KLPLrjGzHlBG6SYYpTlpjWJrddbYhm0EZVmMkkFHRHLcOK8AOHKQipQBHmP+wvTGouwaZ8Uv5+uDNZ76st4BZR1tfXCtZ6A0RLRspo0wJ5EKlrNr8OIQGdj1G4TJ0H029mycqkAQ5yFPlvF/wAZ0shVFb/uMejpQw+2ks= \ No newline at end of file +addons: + apt: + packages: + - docker-ce +branches: + only: + - master +deploy: + - provider: script + script: bash deploy.sh + on: + branch: master diff --git a/CHANGELOG.md b/CHANGELOG.md index d337c2a7..ae091244 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,20 @@ # Change Log +## [v1.6.3](https://github.com/Boerderij/Varken/tree/v1.6.3) (2019-01-16) +[Full Changelog](https://github.com/Boerderij/Varken/compare/v1.6.2...v1.6.3) + +**Implemented enhancements:** + +- \[Feature Request\] ARM, ARMHF and ARM64 Docker Images [\#71](https://github.com/Boerderij/Varken/issues/71) + +**Fixed bugs:** + +- \[BUG\] Newer influxdb has timeouts and connection errors [\#93](https://github.com/Boerderij/Varken/issues/93) + +**Merged pull requests:** + +- v1.6.3 Merge [\#94](https://github.com/Boerderij/Varken/pull/92) ([DirtyCajunRice](https://github.com/DirtyCajunRice)) + ## [v1.6.2](https://github.com/Boerderij/Varken/tree/v1.6.2) (2019-01-12) [Full Changelog](https://github.com/Boerderij/Varken/compare/v1.6.1...v1.6.2) @@ -9,7 +24,7 @@ **Merged pull requests:** -- v1.6.2 Merge [\#90](https://github.com/Boerderij/Varken/pull/92) ([DirtyCajunRice](https://github.com/DirtyCajunRice)) +- v1.6.2 Merge [\#92](https://github.com/Boerderij/Varken/pull/92) ([DirtyCajunRice](https://github.com/DirtyCajunRice)) ## [v1.6.1](https://github.com/Boerderij/Varken/tree/v1.6.1) (2019-01-12) [Full Changelog](https://github.com/Boerderij/Varken/compare/v1.6...v1.6.1) diff --git a/Dockerfile b/Dockerfile index e6007e9c..3681dd45 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM lsiobase/alpine.python3 +FROM amd64/python:3.7.2-alpine LABEL maintainers="dirtycajunrice,samwiseg0" @@ -6,6 +6,8 @@ ENV DEBUG="False" COPY / /app +COPY /tmp/qemu-arm-static /usr/bin/qemu-arm-static + RUN \ python3 -m pip install -r /app/requirements.txt && \ chown -R abc:abc \ diff --git a/Dockerfile.arm b/Dockerfile.arm new file mode 100644 index 00000000..fed9013a --- /dev/null +++ b/Dockerfile.arm @@ -0,0 +1,21 @@ +FROM arm32v6/python:3.7.2-alpine + +LABEL maintainers="dirtycajunrice,samwiseg0" + +ENV DEBUG="False" + +COPY / /app + +COPY /tmp/qemu-arm-static /usr/bin/qemu-arm-static + +RUN \ + python3 -m pip install -r /app/requirements.txt && \ + chown -R abc:abc \ + /config \ + /app + +WORKDIR /app + +CMD cp /app/data/varken.example.ini /config/varken.example.ini && python3 /app/Varken.py --data-folder /config + +VOLUME /config \ No newline at end of file diff --git a/Dockerfile.arm64 b/Dockerfile.arm64 new file mode 100644 index 00000000..92fd7ab6 --- /dev/null +++ b/Dockerfile.arm64 @@ -0,0 +1,21 @@ +FROM arm64v8/python:3.7.2-alpine + +LABEL maintainers="dirtycajunrice,samwiseg0" + +ENV DEBUG="False" + +COPY / /app + +COPY /tmp/qemu-arm-static /usr/bin/qemu-arm-static + +RUN \ + python3 -m pip install -r /app/requirements.txt && \ + chown -R abc:abc \ + /config \ + /app + +WORKDIR /app + +CMD cp /app/data/varken.example.ini /config/varken.example.ini && python3 /app/Varken.py --data-folder /config + +VOLUME /config \ No newline at end of file diff --git a/Dockerfile.armhf b/Dockerfile.armhf new file mode 100644 index 00000000..977979ef --- /dev/null +++ b/Dockerfile.armhf @@ -0,0 +1,21 @@ +FROM arm32v7/python:3.7.2-slim + +LABEL maintainers="dirtycajunrice,samwiseg0" + +ENV DEBUG="False" + +COPY / /app + +COPY /tmp/qemu-arm-static /usr/bin/qemu-arm-static + +RUN \ + python3 -m pip install -r /app/requirements.txt && \ + chown -R abc:abc \ + /config \ + /app + +WORKDIR /app + +CMD cp /app/data/varken.example.ini /config/varken.example.ini && python3 /app/Varken.py --data-folder /config + +VOLUME /config \ No newline at end of file diff --git a/deploy.sh b/deploy.sh new file mode 100644 index 00000000..5bce71fa --- /dev/null +++ b/deploy.sh @@ -0,0 +1,54 @@ +#!/usr/bin/env bash +VERSION="$(grep -i version varken.__init__.py | cut -d' ' -f3 | tr -d \")" + +# Docker +GITHUB_USER='dirtycajunrice' +DOCKER_USER='dirtycajunrice' +PROJECT='varken' +NAMESPACE="boerderij/${PROJECT}" + +# Docker experimental config +echo '{"experimental":true}' | sudo tee /etc/docker/daemon.json +[[ -d ~/.docker ]] || mkdir ~/.docker +[[ -f ~/.docker/config.json ]] || touch ~/.docker/config.json +echo '{"experimental":"enabled"}' | sudo tee ~/.docker/config.json +sudo service docker restart + +# Auth +echo "$DOCKER_PASSWORD" | docker login -u="$DOCKER_USER" --password-stdin + +# Latest x64 +docker build -t "${NAMESPACE}:latest" . && \ +docker push "${NAMESPACE}:latest" && \ +# Versioned x64 +docker tag "${NAMESPACE}:latest" "${NAMESPACE}:${VERSION}" && \ +docker push "${NAMESPACE}:${VERSION}" && \ +# x64 Arch +docker tag "${NAMESPACE}:latest" "${NAMESPACE}:latest-amd64" && \ +docker push "${NAMESPACE}:latest-amd64" + +# Prepare qemu for ARM builds +docker run --rm --privileged multiarch/qemu-user-static:register --reset +wget -P tmp/ "https://github.com/multiarch/qemu-user-static/releases/download/v3.1.0-2/qemu-aarch64-static" +wget -P tmp/ "https://github.com/multiarch/qemu-user-static/releases/download/v3.1.0-2/qemu-arm-static" +chmod +x tmp/qemu-aarch64-static tmp/qemu-arm-static + +# ARM images +for i in $(ls *arm*); do + arch="$(echo ${i} | cut -d. -f2)" + # Latest + docker build -f "./Dockerfile.${arch}" -t "${NAMESPACE}:latest-${arch}" . && \ + docker push "${NAMESPACE}:latest-${arch}" && \ + # Versioned + docker tag "${NAMESPACE}:latest-${arch}" "${NAMESPACE}:${VERSION}-${arch}" && \ + docker push "${NAMESPACE}:${VERSION}-${arch}" +done + +wget -O manifest-tool https://github.com/estesp/manifest-tool/releases/download/v0.9.0/manifest-tool-linux-amd64 && \ +chmod +x manifest-tool && \ +python3 manifest_generator.py && \ +./manifest-tool --username "$DOCKER_USER" --password "$DOCKER_PASSWORD" push from-spec ".manifest.yaml" +# Git tags +git remote set-url origin "https://${GITHUB_USER}:${GITHUB_API_KEY}@github.com/${NAMESPACE}.git" && \ +git tag "${VERSION}" && \ +git push --tags \ No newline at end of file diff --git a/varken/__init__.py b/varken/__init__.py index 2192d2de..196ac44d 100644 --- a/varken/__init__.py +++ b/varken/__init__.py @@ -1,2 +1,2 @@ -VERSION = "1.6.2" +VERSION = "1.6.3" BRANCH = 'master' diff --git a/varken/dbmanager.py b/varken/dbmanager.py index 486d8aa4..e3c53221 100644 --- a/varken/dbmanager.py +++ b/varken/dbmanager.py @@ -1,5 +1,7 @@ from logging import getLogger from influxdb import InfluxDBClient +from requests.exceptions import ConnectionError +from influxdb.exceptions import InfluxDBServerError class DBManager(object): @@ -21,4 +23,8 @@ def __init__(self, server): def write_points(self, data): d = data self.logger.debug('Writing Data to InfluxDB %s', d) - self.influx.write_points(d) + try: + self.influx.write_points(d) + except (InfluxDBServerError, ConnectionError) as e: + self.logger.error('Error writing data to influxdb. Dropping this set of data. ' + 'Check your database! Error: %s', e)