diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..50889c6 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,11 @@ +FROM nginx:alpine +EXPOSE 80 +ENV LISTEN_PORT=80 \ + SERVER_HOST=otrecorder \ + SERVER_PORT=80 + +COPY nginx.tmpl /etc/nginx/nginx.tmpl +COPY index.html /usr/share/nginx/html +COPY static/ /usr/share/nginx/html/static/ + +CMD /bin/sh -c "envsubst '\${SERVER_HOST} \${SERVER_PORT} \${LISTEN_PORT}' < /etc/nginx/nginx.tmpl > /etc/nginx/nginx.conf && nginx -g 'daemon off;' || ( env; cat /etc/nginx/nginx.conf )" diff --git a/README.md b/README.md index d0c8654..19c7e18 100644 --- a/README.md +++ b/README.md @@ -12,8 +12,33 @@ This is a web interface for [OwnTracks](https://github.com/owntracks/recorder), ## Installation +### Manual install + Clone the repository and copy `index.html` and the `static/` directory to your server's webroot. The API is expected to be reachable under the same domain as the web interface. +### Docker + +You can launch directly via Docker run like this: +```console +$ docker run -d -p 80:80 -e SERVER_HOST=otrecorder-host -e SERVER_PORT=otrecorder-port cosme/owntracks-ui +``` + +Or you can use `docker-compose` (if you also run the OwnTracks Recorder with the default compose config, and the service is named `otrecorder`): + +```yaml +version: '3' + +services: + owntracks-ui: + image: cosme/owntracks-ui + ports: + - 80:80 + environment: + - SERVER_HOST=otrecorder + - SERVER_PORT=8083 + restart: unless-stopped +``` + ## Features - Enable or disable multiple layers: diff --git a/nginx.tmpl b/nginx.tmpl new file mode 100644 index 0000000..dcdbd4c --- /dev/null +++ b/nginx.tmpl @@ -0,0 +1,27 @@ +worker_processes 1; +events { + worker_connections 1024; +} +http { + upstream otrecorder { + server ${SERVER_HOST}:${SERVER_PORT}; + } + server { + listen ${LISTEN_PORT}; + root /usr/share/nginx/html; + location /api { + proxy_pass http://otrecorder/api/; + } + location /ws { + proxy_pass http://otrecorder/ws/; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection upgrade; + } + location / { + include /etc/nginx/mime.types; + try_files $uri $uri/index.html; + } + } +} +