Add nginx for healthcheck route

This commit is contained in:
Girish Ramakrishnan 2018-02-26 16:28:45 -08:00
parent ee5dc6e5b8
commit 310b9443b0
6 changed files with 78 additions and 9 deletions

View File

@ -6,8 +6,8 @@
"changelog": "file://CHANGELOG",
"tagline": "Decentralized file synchronization",
"version": "0.5.0",
"healthCheckPath": "/check",
"httpPort": 3000,
"healthCheckPath": "/healthcheck",
"httpPort": 8000,
"addons": {
"localstorage": {}
},

View File

@ -9,6 +9,11 @@ RUN mkdir -p /app/code \
WORKDIR /app/code
# add supervisor configs
ADD supervisor/* /etc/supervisor/conf.d/
RUN ln -sf /run/syncthing/supervisord.log /var/log/supervisor/supervisord.log
ADD nginx.conf /app/code/nginx.conf
ADD start.sh /app/code/start.sh
CMD [ "/app/code/start.sh" ]

41
nginx.conf Normal file
View File

@ -0,0 +1,41 @@
user cloudron;
worker_processes 1;
pid /run/nginx.pid;
daemon off;
# Send logs to stderr
error_log /dev/stderr warn;
events {
worker_connections 768;
}
http {
error_log /dev/stderr warn;
log_format simple '$remote_addr [$time_local] "$request" $status $body_bytes_sent "$http_referer"';
access_log /dev/stdout simple;
include /etc/nginx/mime.types;
client_body_temp_path /tmp/client_body 1 2;
proxy_temp_path /tmp/proxy_temp 1 2;
fastcgi_temp_path /tmp/fastcgi_temp 1 2;
uwsgi_temp_path /tmp/uwsgi_temp 1 2;
scgi_temp_path /tmp/scgi_temp 1 2;
proxy_buffering off;
proxy_cache_path /tmp/proxy_cache levels=1:2 keys_zone=my_cache:10m max_size=100m inactive=60m use_temp_path=off;
proxy_cache my_cache;
server {
error_log /dev/stderr warn;
listen 8000 default_server;
server_name _;
proxy_read_timeout 120s;
location /healthcheck {
return 200;
}
location / {
proxy_pass http://localhost:3000;
}
}
}

View File

@ -2,7 +2,7 @@
set -eu
mkdir -p /app/data/config /app/data/folders
mkdir -p /app/data/config /app/data/folders /run/syncthing
# if this if the first run, generate a useful config
if [ ! -f /app/data/config/config.xml ]; then
@ -21,10 +21,7 @@ fi
sed -e "s,<listenAddress>.*</listenAddress>,<listenAddress>tcp://:${SYNC_PORT}</listenAddress>," -i /app/data/config/config.xml
sed -e 's,<gui .*>,<gui enabled="true" tls="false" debugging="false">,' -i /app/data/config/config.xml
chown -R cloudron:cloudron /app/data/config /app/data
# -no-browser opens up the browser (for desktop app preumably)
# auditfile "-" means log to stdout
echo "=> Starting syncthing"
STNOUPGRADE=1 exec /usr/local/bin/gosu cloudron:cloudron /app/code/syncthing -gui-address=0.0.0.0:3000 -home=/app/data/config -no-browser -auditfile=-
chown -R cloudron:cloudron /app/data /run/syncthing
echo "Starting supervisor"
exec /usr/bin/supervisord --configuration /etc/supervisor/supervisord.conf --nodaemon -i GitLab

12
supervisor/nginx.conf Normal file
View File

@ -0,0 +1,12 @@
[program:nginx]
priority=100
directory=/tmp
command=/usr/sbin/nginx -c /app/code/nginx.conf
user=root
autostart=true
autorestart=true
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0

14
supervisor/syncthing.conf Normal file
View File

@ -0,0 +1,14 @@
[program:syncthing]
priority=20
environment=HOME=/app/data/folders,STNOUPGRADE=1
; -no-browser opens up the browser (for desktop app preumably)
; auditfile "-" means log to stdout
command=/app/code/syncthing -gui-address=127.0.0.1:3000 -home=/app/data/config -no-browser -auditfile=-
user=cloudron
autostart=true
autorestart=true
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0