Skip to content

Commit

Permalink
Add armv7 Docker image builds
Browse files Browse the repository at this point in the history
  • Loading branch information
janw committed Jul 31, 2019
1 parent c0a528c commit ff7274d
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 20 deletions.
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.git
.venv
htmlcov
tests
.readme-assets
30 changes: 29 additions & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ services:
variables:
DOCKER_HOST: tcp://docker:2375
DOCKER_DRIVER: overlay2
DOCKER_TLS_CERTDIR: ""

stages:
- build
Expand All @@ -19,7 +20,6 @@ build:
script:
- docker pull $CI_REGISTRY_IMAGE:latest || true
- docker build
--cache-from $CI_REGISTRY_IMAGE:latest
--tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA .
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA

Expand All @@ -29,6 +29,34 @@ tag latest:
- docker pull $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA
- docker tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA $CI_REGISTRY_IMAGE:latest
- docker push $CI_REGISTRY_IMAGE:latest
only:
- master

## Aditional build jobs for special-flavor Dockerfiles
## ----

.build special:
stage: build
variables:
BUILD_DOCKERFILE: Dockerfile
script:
- docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
- docker pull $CI_REGISTRY_IMAGE:$IMAGE_FLAVOR || true
- docker build
--build-arg BUILD_FROM=${BUILD_FROM}
--tag $CI_REGISTRY_IMAGE:${IMAGE_FLAVOR}-$CI_COMMIT_SHORT_SHA
--file ${BUILD_DOCKERFILE} .
- docker run --rm $CI_REGISTRY_IMAGE:${IMAGE_FLAVOR}-$CI_COMMIT_SHORT_SHA uname -m
- docker push $CI_REGISTRY_IMAGE:${IMAGE_FLAVOR}-$CI_COMMIT_SHORT_SHA

.tag special:
stage: tag
script:
- docker pull $CI_REGISTRY_IMAGE:${IMAGE_FLAVOR}-$CI_COMMIT_SHORT_SHA
- docker tag $CI_REGISTRY_IMAGE:${IMAGE_FLAVOR}-$CI_COMMIT_SHORT_SHA $CI_REGISTRY_IMAGE:${IMAGE_FLAVOR}
- docker push $CI_REGISTRY_IMAGE:${IMAGE_FLAVOR}
only:
- master

build armv7: {extends: .build special, variables: {IMAGE_FLAVOR: armv7, BUILD_FROM: "arm32v7/python:3.6-alpine"}}
tag armv7: {extends: .tag special, variables: {IMAGE_FLAVOR: armv7}}
9 changes: 6 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
FROM python:3.6-alpine

ARG BUILD_FROM=python:3.6-alpine
FROM $BUILD_FROM
LABEL maintainer="Jan Willhaus <[email protected]>"

ENV PYTHONUNBUFFERED=1
WORKDIR /app

COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
RUN apk add --no-cache tini && \
pip install --no-cache-dir -r requirements.txt

COPY user.toml.example ./user.toml
COPY default.toml ./
COPY piholeinflux.py ./

ENTRYPOINT [ "tini", "--" ]
CMD [ "python", "./piholeinflux.py" ]
43 changes: 27 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,36 @@ A simple daemonized script to report Pi-Hole stats to an InfluxDB, ready to be d

## Setup (Using Docker)

To use docker for running the daemon, use the following command:

```bash
docker run \
-e PIHOLE_INFLUXDB_HOST="myhostname" \
-e PIHOLE_INFLUXDB_PORT="8086" \
-e PIHOLE_INFLUXDB_USERNAME="myusername" \
-e PIHOLE_INFLUXDB_PASSWORD="mysupersecretpassword" \
-e PIHOLE_INFLUXDB_DATABASE="pihole" \
-e PIHOLE_INSTANCES="localhost=http://127.0.0.1/admin/api.php" \
registry.gitlab.com/janw/pi-hole-influx
```
* To use docker for running the daemon, use the following command:

```bash
docker run \
-e PIHOLE_INFLUXDB_HOST="myhostname" \
-e PIHOLE_INFLUXDB_PORT="8086" \
-e PIHOLE_INFLUXDB_USERNAME="myusername" \
-e PIHOLE_INFLUXDB_PASSWORD="mysupersecretpassword" \
-e PIHOLE_INFLUXDB_DATABASE="pihole" \
-e PIHOLE_INSTANCES="localhost=http://127.0.0.1/admin/api.php" \
registry.gitlab.com/janw/pi-hole-influx
```

* For running it on a Raspberry Pi (arm v7 arch), use the dedicated `armv7` image tag:

```bash
docker run \
-e PIHOLE_INFLUXDB_HOST="myhostname" \
-e PIHOLE_INFLUXDB_USERNAME="myusername" \
-e PIHOLE_INFLUXDB_PASSWORD="mysupersecretpassword" \
--network host \
registry.gitlab.com/janw/pi-hole-influx
```

The following values are the defaults and will be used if not set:

* PIHOLE_INFLUXDB_PORT="8086"
* PIHOLE_INFLUXDB_HOST="127.0.0.1"
* PIHOLE_INFLUXDB_DATABASE="pihole"
* PIHOLE_INSTANCES="localhost=http://127.0.0.1/admin/api.php"
* `PIHOLE_INFLUXDB_PORT="8086"`
* `PIHOLE_INFLUXDB_HOST="127.0.0.1"`
* `PIHOLE_INFLUXDB_DATABASE="pihole"`
* `PIHOLE_INSTANCES="localhost=http://127.0.0.1/admin/api.php"`

`PIHOLE_INSTANCES` contains the Pi-hole instances that are to be reported. Multiple instances can given in a dict-like boxed syntax, known as [Inline Tables in TOML](https://github.com/toml-lang/toml#inline-table):

Expand Down

0 comments on commit ff7274d

Please sign in to comment.