├── influxdb.conf ├── .travis.yml ├── Makefile ├── Dockerfile ├── LICENSE ├── run.sh └── README.md /influxdb.conf: -------------------------------------------------------------------------------- 1 | [meta] 2 | dir = "/data/meta" 3 | 4 | [data] 5 | dir = "/data/data" 6 | engine = "tsm1" 7 | wal-dir = "/data/wal" 8 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: required 2 | services: 3 | - docker 4 | language: bash 5 | script: 6 | # prepare qemu 7 | - docker run --rm --privileged multiarch/qemu-user-static:register --reset 8 | # build image 9 | - make build 10 | # test image 11 | - make test 12 | - make version 13 | # push image 14 | - > 15 | if [ "$TRAVIS_BRANCH" == "master" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then 16 | docker login -u="$DOCKER_USER" -p="$DOCKER_PASS" 17 | make push 18 | fi 19 | 20 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | DOCKER_IMAGE_VERSION=1.2.2 2 | DOCKER_IMAGE_NAME=hypriot/rpi-influxdb 3 | DOCKER_IMAGE_TAGNAME=$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_VERSION) 4 | 5 | default: build 6 | 7 | build: 8 | docker build -t $(DOCKER_IMAGE_TAGNAME) . 9 | docker tag $(DOCKER_IMAGE_TAGNAME) $(DOCKER_IMAGE_NAME):latest 10 | 11 | push: 12 | docker push $(DOCKER_IMAGE_TAGNAME) 13 | docker push $(DOCKER_IMAGE_NAME) 14 | 15 | test: 16 | docker run --rm $(DOCKER_IMAGE_TAGNAME) /bin/echo "Success." 17 | 18 | version: 19 | docker run --rm $(DOCKER_IMAGE_TAGNAME) influx -version 20 | 21 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # Pull base image 2 | FROM resin/rpi-raspbian:jessie 3 | MAINTAINER Henrik Östman 4 | 5 | # Setup external package-sources 6 | RUN apt-get update && apt-get install -y \ 7 | apt-transport-https \ 8 | curl \ 9 | --no-install-recommends && \ 10 | curl -sL https://repos.influxdata.com/influxdb.key | sudo apt-key add - source /etc/os-release && \ 11 | echo "deb https://repos.influxdata.com/debian jessie stable" | sudo tee /etc/apt/sources.list.d/influxdb.list && \ 12 | apt-get update && apt-get install -y \ 13 | influxdb=1.2.2-1 \ 14 | --no-install-recommends && \ 15 | apt-get remove --auto-remove -y \ 16 | apt-transport-https && \ 17 | rm -rf /var/lib/apt/lists/* 18 | 19 | COPY influxdb.conf /etc/influxdb/influxdb.conf 20 | 21 | ADD run.sh /run.sh 22 | RUN chmod +x /*.sh 23 | 24 | ENV PRE_CREATE_DB **None** 25 | 26 | # HTTP API 27 | EXPOSE 8086 28 | 29 | VOLUME ["/data"] 30 | 31 | CMD ["/run.sh"] 32 | 33 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2017 Hypriot 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -m 4 | CONFIG_FILE="/etc/influxdb/influxdb.conf" 5 | INFLUX_HOST="localhost" 6 | INFLUX_API_PORT="8086" 7 | API_URL="http://${INFLUX_HOST}:${INFLUX_API_PORT}" 8 | 9 | if [ "${PRE_CREATE_DB}" == "**None**" ]; then 10 | unset PRE_CREATE_DB 11 | fi 12 | 13 | echo "=> Starting InfluxDB ..." 14 | exec influxd -config=${CONFIG_FILE} & 15 | 16 | # Pre create database on the initiation of the container 17 | if [ -n "${PRE_CREATE_DB}" ]; then 18 | echo "=> About to create the following database: ${PRE_CREATE_DB}" 19 | if [ -f "/data/.pre_db_created" ]; then 20 | echo "=> Database had been created before, skipping ..." 21 | else 22 | arr=$(echo ${PRE_CREATE_DB} | tr ";" "\n") 23 | 24 | #wait for the startup of influxdb 25 | RET=1 26 | while [[ RET -ne 0 ]]; do 27 | echo "=> Waiting for confirmation of InfluxDB service startup ..." 28 | sleep 3 29 | curl -k ${API_URL}/ping 2> /dev/null 30 | RET=$? 31 | done 32 | echo "" 33 | 34 | PASS=${INFLUXDB_INIT_PWD:-root} 35 | if [ -n "${ADMIN_USER}" ]; then 36 | echo "=> Creating admin user" 37 | influx -host=${INFLUX_HOST} -port=${INFLUX_API_PORT} -execute="CREATE USER ${ADMIN_USER} WITH PASSWORD '${PASS}' WITH ALL PRIVILEGES" 38 | for x in $arr 39 | do 40 | echo "=> Creating database: ${x}" 41 | influx -host=${INFLUX_HOST} -port=${INFLUX_API_PORT} -username=${ADMIN_USER} -password="${PASS}" -execute="create database ${x}" 42 | influx -host=${INFLUX_HOST} -port=${INFLUX_API_PORT} -username=${ADMIN_USER} -password="${PASS}" -execute="grant all PRIVILEGES on ${x} to ${ADMIN_USER}" 43 | done 44 | echo "" 45 | else 46 | for x in $arr 47 | do 48 | echo "=> Creating database: ${x}" 49 | influx -host=${INFLUX_HOST} -port=${INFLUX_API_PORT} -execute="create database \"${x}\"" 50 | done 51 | fi 52 | 53 | touch "/data/.pre_db_created" 54 | fi 55 | else 56 | echo "=> No database need to be pre-created" 57 | fi 58 | 59 | fg 60 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # rpi-influxdb [![Build Status](https://travis-ci.org/hypriot/rpi-influxdb.svg?branch=master)](https://travis-ci.org/hypriot/rpi-influxdb) [![This image on DockerHub](https://img.shields.io/docker/pulls/hypriot/rpi-influxdb.svg)](https://hub.docker.com/r/hypriot/rpi-influxdb/) 2 | 3 | Raspberry Pi compatible Docker base image with InfluxDB, an open source database written in Go specifically to handle time series data with high availability and high performance requirements. 4 | 5 | ### Build Details 6 | - [Source Project Page](https://github.com/hypriot) 7 | - [Source Repository](https://github.com/hypriot/rpi-influxdb) 8 | - [Dockerfile](https://github.com/hypriot/rpi-influxdb/blob/master/Dockerfile) 9 | - [DockerHub](https://registry.hub.docker.com/u/hypriot/rpi-influxdb/) 10 | 11 | #### Build the Docker Image 12 | ```bash 13 | make build 14 | ``` 15 | 16 | #### Run the Docker Image and get the version of installed InfluxDB client 17 | ```bash 18 | make version 19 | ``` 20 | 21 | #### Push the Docker Image to the Docker Hub 22 | * First use a `docker login` with username, password and email address 23 | * Second push the Docker Image to the official Docker Hub 24 | 25 | ```bash 26 | make push 27 | ``` 28 | 29 | Running your InfluxDB image 30 | --------------------------- 31 | 32 | Start your image binding the external port `8086` of your containers: 33 | 34 | docker run -d -p 8086:8086 hypriot/rpi-influxdb 35 | 36 | Docker containers are easy to delete. If you are serious about keeping InfluxDB data persistently, then consider adding a volume mapping to the containers `/data` folder: 37 | 38 | docker run -d --volume=/var/influxdb:/data -p 8086:8086 hypriot/rpi-influxdb 39 | 40 | Configuring your InfluxDB 41 | ------------------------- 42 | 43 | You can use the RESTful API to talk to InfluxDB on port `8086`. Use the new `influx` cli tool to configure the database. While the container is running, you launch the tool with the following command: 44 | 45 | ``` 46 | docker exec -it /usr/bin/influx 47 | Visit https://enterprise.influxdata.com to register for updates, InfluxDB server management, and monitoring. 48 | Connected to http://localhost:8086 version 1.2.2 49 | InfluxDB shell 1.2.2 50 | > 51 | ``` 52 | 53 | Initially create Database 54 | ------------------------- 55 | Use `-e PRE_CREATE_DB="db1;db2;db3"` to create database named "db1", "db2", and "db3" on the first time the container starts automatically. Each database name is separated by `;`. For example: 56 | 57 | ```docker run -d -p 8086:8086 -e ADMIN_USER="root" -e INFLUXDB_INIT_PWD="somepassword" -e PRE_CREATE_DB="db1;db2;db3" hypriot/rpi-influxdb:latest``` 58 | 59 | Alternatively, create a database and user with the InfluxDB 1.2 shell: 60 | 61 | ``` 62 | > CREATE DATABASE db1 63 | > SHOW DATABASES 64 | name: databases 65 | --------------- 66 | name 67 | db1 68 | > USE db1 69 | > CREATE USER root WITH PASSWORD 'somepassword' WITH ALL PRIVILEGES 70 | > GRANT ALL PRIVILEGES ON db1 TO root 71 | > SHOW USERS 72 | user admin 73 | root true 74 | ``` 75 | 76 | Credits 77 | ------- 78 | [This docker image was based upon the tutum-image](https://github.com/tutumcloud/influxdb) 79 | 80 | 81 | ## License 82 | 83 | The MIT License (MIT) 84 | 85 | Copyright (c) 2017 Hypriot 86 | 87 | Permission is hereby granted, free of charge, to any person obtaining a copy 88 | of this software and associated documentation files (the "Software"), to deal 89 | in the Software without restriction, including without limitation the rights 90 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 91 | copies of the Software, and to permit persons to whom the Software is 92 | furnished to do so, subject to the following conditions: 93 | 94 | The above copyright notice and this permission notice shall be included in all 95 | copies or substantial portions of the Software. 96 | 97 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 98 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 99 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 100 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 101 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 102 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 103 | SOFTWARE. 104 | --------------------------------------------------------------------------------