Malte Deiseroth 8b63ac0296 New Dockerfile for Recorder
The problem with the current solution is that it provide a monolytic
multiprogramm docker container. However the idiom of docker is to
have one service per docker container. If multiple services are
needed multiple docker container should be used. Docker-compose
makes this easily possible.

Another isse is that the container automatically creates certificates
and sets up encryption using a script. Also this violates docker
idioms, because certificate handling can be done using specific
containers like letsencrypt. It further makes it hard to include this
image into an existing and possible complex infastructure.

A further goal of mine would be to generate a Hassio addon for the
homeassistant project from this. The current dockerfile makes this
kind of hard.

What I did:
- Slimmed down the container to about 10MB by using alpine as a base
- Added a `docker-compose.yml` file that shows how to build and run
  the container
- Added a `docker-compose-mqtt.yml` file to show how a mqtt broker
  can be added. This shows how a plug and play solution using
  docker could look like.
- Changed the docker image label to owntracks/recorder
- Added documentation on how to use and configure the image
- Simple travis file for possible automatic building in the near
  future
- Removed automatic certificate handling
  Instead provide `config` volume to allow configuration.
- Removed arm32v7 build
  should be readded later but I dont have a setup for testing right
  now

What might be added at some point:
- Example with nginx reverse proxy
- Example with letsencrypt certificate
  This could also be an example for a complete plug and play
  solution. Proxy, SSl, MQTT and Recorder.
- Default resolv.conf file with all default options and documentation
- Upload to docker hub
- Change name to owntracks/recorder
- Some more examples for eclipse mosquitto
2019-01-08 16:55:16 +01:00
2019-01-08 16:55:16 +01:00
2019-01-08 16:55:16 +01:00
2019-01-08 16:55:16 +01:00
2019-01-08 16:55:16 +01:00
2019-01-08 16:55:16 +01:00
2019-01-08 16:55:16 +01:00
2019-01-08 16:55:16 +01:00
2019-01-08 16:55:16 +01:00
2019-01-08 16:55:16 +01:00

Dockerfile for OwnTracks Recorder

Build Status

Dockerfile for the Recorder of the Owntracks project.

Quickstart

$ docker volume create recorder_store
$ docker run -d -p 8083:8083 -v recorder_store:/store -e OTR_HOST=mqtt_broker owntracks/recorder

Recorder is now accessible at http://localhost:8083

-p 8083:8083 makes the container reachable at port 8083. -d detaches the container into the background. The volume recorder_store is mounted at /store into the container. This is needed to have persistent data storage. -e allows to pass additional configuration to the container as environment variables. Multiple -e parameters can be used for multiple environment variables.

Configuration

The Recorder can be configured using two methods, environment variables and via the a recorder.conf file in the /config volume of the container.

Environment variables

Can be passed to the container with the -e parameter. Example:

$ docker run -d -p 8083:8083 -e OTR_HOST=mqtt_broker -e OTR_PORT=1883 -e OTR_USER=user -e OTR_PASS=pass owntracks/recorder

The complete list of parameters can be found in the recorder documentations

Configuration file

One can also use a configuration file. The container reads a recorder.conf file from the /config folder. To use this, create a folder e.g. ./config and mount it into you docker container at /config.

$ mkdir config
$ docker run -d -p 8083:8083 -v recorder_store:/store -v ./config:/config owntracks/recorder

Up on starting the recorder, a default recorder.conf file will be created if none exists. Possible options are documented [here](https://github.com/owntracks/recorder/blob/master/README.md#configuration-file**

Notes:

  • OTR_HOST is as seen from the container. Thus localhost refers to the container not the host.
  • Environment variables, overwrite the recorder.conf file options.
  • The shell like style of therecorder.conf file needs "" encapsulated variable values.

Storing data

The /store volume of the container is used for persistent storage of location data. The volume needs to be created explicitly.

$ docker volume create recorder_storage
$ docker run -d -p 8083:8083 -v recorder_store:/store owntracks/recorder

It is also possible to use a local folder instead of an static docker volume.

$ mkdir store
$ docker run -d -p 8083:8083 -v ./store:/store owntracks/recorder

If nothing is mounted at /store, docker will create a unique volume automatically. However up on recreation of the docker container, this process will be repeated and another unique volume will be created. As a result, the container will have forgotten about previous tracks.

TLS between MQTT broker and Recorder

The OTR_CAPATH of the container defaults to the /config volume. Thus certificates and key files belong into the /config volume. OTR_CAFILE must be configured for TLS.

OTR_CERTFILE defaults to cert.pem and OTR_KEYFILE to key.pem. These files are optional and the options are ignored if the files don't exist.

TLS encryption via reverse proxy

The Recorder has no encryption module by it self. Instead use a reverse proxy setup. See https://github.com/jwilder/nginx-proxy for how to do this in a semi automatic way with docker containers and https://github.com/owntracks/recorder#reverse-proxy for Recorder specific details.

Docker compose files

Save a file with the name docker-compose.yml and following content. Run with docker-compose up from the same folder.

version: '3'

services:

  otrecorder:
    image: owntracks/recorder
    ports:
      - 8083:8083
    volumes:
      - config:/config
      - store:/store
    restart: unless-stopped

volumes:
  store:
  config:

This docker-compose.yml file creates store and config volumes. It is possible to edit the recorder.conf file in the config volume to get the system up and running. It is also possible to pass environment variables to the docker container via the environment: keyword. For details see here and for available variables see here.

An example might look like:

version: '3'

services:

  otrecorder:
    image: owntracks/recorder
    ports:
      - 8083:8083
    volumes:
      - store:/store
    restart: unless-stopped
    environment:
      - OTR_HOST: "mqtt_broker"
      - OTR_USER: "user"
      - OTR_PASS: "pass"

volumes:
  store:

With MQTT broker

If an mqtt broker is needed mosquitto can be used. There are ready to use containers available on docker hub. To use eclipse-mosquitto add the following to you docker-compose.yml file.

version: '3'

services:

  otrecorder:
    image: owntracks/recorder
    ports:
      - 8083:8083
    volumes:
      - config:/config
      - store:/store
    restart: unless-stopped

  mosquitto:
    image: eclipse-mosquitto
    ports:
      - 1883:1883
      - 8883:8883
    volumes:
      - mosquitto-data:/mosquitto/data
      - mosquitto-logs:/mosquitto/logs
      - mosquitto-conf:/mosquitto/config
    restart: unless-stopped

volumes:
  store:
  config:
  mosquitto-data:
  mosquitto-logs:
  mosquitto-conf:

See here for info on the eclipse-mosquitto image and how to configure.

Notes

  • certificates volume for Recorder and some documentation
  • Check if lua5.2-libs is needed
  • Check if eclipse-mosquitto is working
  • Maybe put the most common mosquitto options
  • Maybe add letsencrypt
  • Add some defaults so mosquitto and owntracks work right away
  • Find out how it works with automatic build tags on travis and automatic docker hub uploading
Description
Languages
Lua 87%
Makefile 6.5%
Dockerfile 4.3%
Shell 2.2%