From cbcb25a25c149f09b0f0596c318e1d19931127d3 Mon Sep 17 00:00:00 2001 From: SharkoZ Date: Tue, 3 Sep 2019 08:57:13 +0200 Subject: [PATCH 1/9] Dockerise app --- Dockerfile | 12 ++++++++++++ nginx.tmpl | 26 ++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 Dockerfile create mode 100644 nginx.tmpl diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..f03a4d7 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,12 @@ +FROM nginx:alpine +EXPOSE 80 +ENV LISTEN_PORT=80 \ + SERVER_URL=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/ +RUN ls /usr/share/nginx/html/* +CMD /bin/sh -c "envsubst '\${SERVER_URL} \${SERVER_PORT} \${LISTEN_PORT}' < /etc/nginx/nginx.tmpl > /etc/nginx/nginx.conf && nginx -g 'daemon off;' || cat /etc/nginx/nginx.conf" + diff --git a/nginx.tmpl b/nginx.tmpl new file mode 100644 index 0000000..51f65ea --- /dev/null +++ b/nginx.tmpl @@ -0,0 +1,26 @@ +worker_processes 1; +events { + worker_connections 1024; +} +http { + upstream otrecorder { + server ${SERVER_URL}:${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 / { + try_files $uri $uri/index.html; + } + } +} + From 6c58bb2bc8839229c582e203c4b2c14f28f1289b Mon Sep 17 00:00:00 2001 From: SharkoZ Date: Tue, 3 Sep 2019 09:00:26 +0200 Subject: [PATCH 2/9] fix nginx mime types --- nginx.tmpl | 1 + 1 file changed, 1 insertion(+) diff --git a/nginx.tmpl b/nginx.tmpl index 51f65ea..db5751c 100644 --- a/nginx.tmpl +++ b/nginx.tmpl @@ -19,6 +19,7 @@ http { proxy_set_header Connection upgrade; } location / { + include /etc/nginx/mime.types; try_files $uri $uri/index.html; } } From 2ec596e09a3d5215ef0abec2e0f6fb12de1c3f18 Mon Sep 17 00:00:00 2001 From: SharkoZ Date: Tue, 3 Sep 2019 10:53:32 +0200 Subject: [PATCH 3/9] update readme for docker install --- README.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/README.md b/README.md index e222673..dea54e0 100644 --- a/README.md +++ b/README.md @@ -14,8 +14,35 @@ 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 : +```bash +docker run -d -p 80:80 -e SERVER_URL=otrecorder-url -e SERVER_PORT=otrecorder-port cosme/owntracks-ui +``` + +Or you can use docker-compose (if you also run otrecorder 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_URL=otrecorder + - SERVER_PORT=8083 + restart: unless-stopped + +``` + ## Features - Enable or disable multiple layers: From 00bb4e7fa7410450fbfd7e3b31402d9c2e1b43cd Mon Sep 17 00:00:00 2001 From: sharkoz Date: Tue, 3 Sep 2019 14:33:38 +0200 Subject: [PATCH 4/9] Apply suggestions from code review Co-Authored-By: Linus Groh --- Dockerfile | 4 ++-- README.md | 10 ++++------ nginx.tmpl | 2 +- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index f03a4d7..7e1f247 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,12 +1,12 @@ FROM nginx:alpine EXPOSE 80 ENV LISTEN_PORT=80 \ - SERVER_URL=otrecorder \ + 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/ RUN ls /usr/share/nginx/html/* -CMD /bin/sh -c "envsubst '\${SERVER_URL} \${SERVER_PORT} \${LISTEN_PORT}' < /etc/nginx/nginx.tmpl > /etc/nginx/nginx.conf && nginx -g 'daemon off;' || cat /etc/nginx/nginx.conf" +CMD /bin/sh -c "envsubst '\${SERVER_HOST} \${SERVER_PORT} \${LISTEN_PORT}' < /etc/nginx/nginx.tmpl > /etc/nginx/nginx.conf && nginx -g 'daemon off;' || cat /etc/nginx/nginx.conf" diff --git a/README.md b/README.md index dea54e0..d0f61ab 100644 --- a/README.md +++ b/README.md @@ -20,27 +20,25 @@ Clone the repository and copy `index.html` and the `static/` directory to your s ### Docker -You can launch directly via docker run like this : +You can launch directly via Docker run like this: ```bash docker run -d -p 80:80 -e SERVER_URL=otrecorder-url -e SERVER_PORT=otrecorder-port cosme/owntracks-ui ``` -Or you can use docker-compose (if you also run otrecorder with the default compose config, and the service is named `otrecorder`): +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 +```yaml version: '3' services: - owntracks-ui: image: cosme/owntracks-ui ports: - 80:80 environment: - - SERVER_URL=otrecorder + - SERVER_HOST=otrecorder - SERVER_PORT=8083 restart: unless-stopped - ``` ## Features diff --git a/nginx.tmpl b/nginx.tmpl index db5751c..917e71d 100644 --- a/nginx.tmpl +++ b/nginx.tmpl @@ -12,7 +12,7 @@ http { location /api { proxy_pass http://otrecorder/api/; } - location /ws { + location /ws { proxy_pass http://otrecorder/ws/; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; From 8b19d2bc6322335f1c4f6eae0ade44033ad58053 Mon Sep 17 00:00:00 2001 From: sharkoz Date: Tue, 3 Sep 2019 16:15:32 +0200 Subject: [PATCH 5/9] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d0f61ab..0118b40 100644 --- a/README.md +++ b/README.md @@ -21,8 +21,8 @@ Clone the repository and copy `index.html` and the `static/` directory to your s ### Docker You can launch directly via Docker run like this: -```bash -docker run -d -p 80:80 -e SERVER_URL=otrecorder-url -e SERVER_PORT=otrecorder-port cosme/owntracks-ui +```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`): From 95d820033886a0e61a43219cb13da5fbdde1a70c Mon Sep 17 00:00:00 2001 From: sharkoz Date: Tue, 3 Sep 2019 20:55:26 +0200 Subject: [PATCH 6/9] remove useless command --- Dockerfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7e1f247..6ea22c7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,6 +7,5 @@ ENV LISTEN_PORT=80 \ COPY nginx.tmpl /etc/nginx/nginx.tmpl COPY index.html /usr/share/nginx/html COPY static/ /usr/share/nginx/html/static/ -RUN ls /usr/share/nginx/html/* -CMD /bin/sh -c "envsubst '\${SERVER_HOST} \${SERVER_PORT} \${LISTEN_PORT}' < /etc/nginx/nginx.tmpl > /etc/nginx/nginx.conf && nginx -g 'daemon off;' || cat /etc/nginx/nginx.conf" +CMD /bin/sh -c "envsubst '\${SERVER_HOST} \${SERVER_PORT} \${LISTEN_PORT}' < /etc/nginx/nginx.tmpl > /etc/nginx/nginx.conf && nginx -g 'daemon off;' || cat /etc/nginx/nginx.conf" From 1008d99144146b39d31826fb50577c0125d4c221 Mon Sep 17 00:00:00 2001 From: sharkoz Date: Tue, 3 Sep 2019 21:37:37 +0200 Subject: [PATCH 7/9] Update nginx.tmpl Co-Authored-By: Linus Groh --- nginx.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nginx.tmpl b/nginx.tmpl index 917e71d..288f56c 100644 --- a/nginx.tmpl +++ b/nginx.tmpl @@ -19,7 +19,7 @@ http { proxy_set_header Connection upgrade; } location / { - include /etc/nginx/mime.types; + include /etc/nginx/mime.types; try_files $uri $uri/index.html; } } From f6eb70c40852ff8cc865c219b91bbca2239af8cc Mon Sep 17 00:00:00 2001 From: sharkoz Date: Tue, 3 Sep 2019 21:37:47 +0200 Subject: [PATCH 8/9] Update nginx.tmpl Co-Authored-By: Linus Groh --- nginx.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nginx.tmpl b/nginx.tmpl index 288f56c..dcdbd4c 100644 --- a/nginx.tmpl +++ b/nginx.tmpl @@ -4,7 +4,7 @@ events { } http { upstream otrecorder { - server ${SERVER_URL}:${SERVER_PORT}; + server ${SERVER_HOST}:${SERVER_PORT}; } server { listen ${LISTEN_PORT}; From 4fca3d4cd7b85b5acbe616318769474af9e6b4fa Mon Sep 17 00:00:00 2001 From: sharkoz Date: Mon, 16 Sep 2019 16:52:17 +0200 Subject: [PATCH 9/9] Update Dockerfile --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 6ea22c7..50889c6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,4 +8,4 @@ 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;' || cat /etc/nginx/nginx.conf" +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 )"