Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Dockerfile for Recorder #20

Merged
merged 1 commit into from Jan 9, 2019
Merged

New Dockerfile for Recorder #20

merged 1 commit into from Jan 9, 2019

Conversation

deisi
Copy link
Contributor

@deisi deisi commented Jan 8, 2019

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

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
@jpmens
Copy link
Member

jpmens commented Jan 8, 2019

Thank you, @deisi, for this work. What you write sounds sensible to me. FYI, the reason it was originally a multi-system container (recorder + mosquitto) was simply my ignorance. I have since learned (also from you) that it was a bad idea. As such, I greatly appreciate these changes.

I also approve of the simplification in removing certificate creation; this should, indeed, be left to "third party", i.e. Let's Encrypt & co.

@juzam Could you please, as our resident docker contributor :-), look at this and comment?

@deisi
Copy link
Contributor Author

deisi commented Jan 8, 2019

:-)

@juzam
Copy link
Collaborator

juzam commented Jan 9, 2019

I'll give a proper look as soon as possible :)

@jpmens
Copy link
Member

jpmens commented Jan 9, 2019

@deisi I'm trying this now, and get a linker error for -lssl:

...
cc -g -Wall -Werror -DGHASHPREC=7 -DWITH_MQTT=1 -I/usr/include -DWITH_PING=1 -DWITH_LUA=1 `pkg-config --cflags lua5.2` -DWITH_ENCRYPT=1 `pkg-config --cflags libsodium` -DWITH_HTTP=1 -DJSON_INDENT=NULL -DSTORAGEDEFAULT=\"/store\" -DDOCROOT=\"/htdocs\" -DCONFIGFILE=\"/config/recorder.conf\" -DGIT_VERSION=\"tarball\" -o ot-recorder recorder.o json.o gcache.o geo.o geohash.o mkpath.o base64.o misc.o util.o storage.o fences.o listsort.o hooks.o  mongoose.o http.o -lssl -lm -lcurl -lconfig -llmdb -lpthread -L/usr/lib -lmosquitto -lm `pkg-config --libs lua5.2` `pkg-config --libs libsodium`
/usr/lib/gcc/x86_64-alpine-linux-musl/6.3.0/../../../../x86_64-alpine-linux-musl/bin/ld: cannot find -lssl
collect2: error: ld returned 1 exit status
make: *** [Makefile:77: ot-recorder] Error 1
ERROR: Service 'recorder' failed to build: The command '/bin/sh -c apk add --no-cache --virtual .build-deps         curl-dev libconfig-dev make         gcc musl-dev mosquitto-dev wget     && apk add --no-cache         libcurl libconfig-dev mosquitto-dev lmdb-dev libsodium-dev lua5.2-dev     && mkdir -p /usr/local/source     && cd /usr/local/source     && wget https://github.com/owntracks/recorder/archive/$VERSION.tar.gz     && tar xzf $VERSION.tar.gz     && cd recorder-$VERSION     && mv /config.mk ./     && make     && make install     && cd /     && chmod 755 /entrypoint.sh     && rm -rf /usr/local/source     && apk del .build-deps' returned a non-zero code: 2

I fixed with

index 687325c..2996a59 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -13,7 +13,7 @@ RUN apk add --no-cache --virtual .build-deps \
         curl-dev libconfig-dev make \
         gcc musl-dev mosquitto-dev wget \
     && apk add --no-cache \
-        libcurl libconfig-dev mosquitto-dev lmdb-dev libsodium-dev lua5.2-dev \
+        libcurl libconfig-dev mosquitto-dev lmdb-dev libsodium-dev lua5.2-dev openssl-dev \
     && mkdir -p /usr/local/source \
     && cd /usr/local/source \
     && wget https://github.com/owntracks/recorder/archive/$VERSION.tar.gz \

@jpmens
Copy link
Member

jpmens commented Jan 9, 2019

For the rest, it works like a charm, @deisi!

jmbp-4945

@jpmens jpmens merged commit 8b63ac0 into owntracks:master Jan 9, 2019
@jpmens
Copy link
Member

jpmens commented Jan 9, 2019

Merged. Thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants