From 31332d5561e377e101f5147c22ec1871e80e1b7d Mon Sep 17 00:00:00 2001 From: Simon Bruder Date: Wed, 3 Jun 2020 21:17:17 +0200 Subject: [PATCH] Init --- .drone.yml | 25 ++++++++++++++++++ Dockerfile | 28 ++++++++++++++++++++ entrypoint.sh | 5 ++++ http-socket/Dockerfile | 9 +++++++ nginx.conf | 50 ++++++++++++++++++++++++++++++++++++ services/deluge-web/run | 2 ++ services/deluge_exporter/run | 2 ++ services/deluged/run | 2 ++ services/nginx/run | 2 ++ 9 files changed, 125 insertions(+) create mode 100644 .drone.yml create mode 100644 Dockerfile create mode 100755 entrypoint.sh create mode 100644 http-socket/Dockerfile create mode 100644 nginx.conf create mode 100755 services/deluge-web/run create mode 100755 services/deluge_exporter/run create mode 100755 services/deluged/run create mode 100755 services/nginx/run diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..70c4ae2 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,25 @@ +kind: pipeline +name: default + +steps: + - name: deluge + image: plugins/docker + settings: + registry: r.sbruder.de + username: + from_secret: docker_username + password: + from_secret: docker_password + repo: r.sbruder.de/deluge + + - name: http-socket + image: plugins/docker + settings: + registry: r.sbruder.de + username: + from_secret: docker_username + password: + from_secret: docker_password + context: http-socket + dockerfile: http-socket/Dockerfile + repo: r.sbruder.de/http-socket diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..539f7ce --- /dev/null +++ b/Dockerfile @@ -0,0 +1,28 @@ +FROM debian:testing-slim + +RUN apt-get update \ + && apt-get -y install --no-install-recommends runit \ + && apt-get -y install \ + deluge-console \ + deluge-web \ + deluged \ + git \ + gosu \ + nginx-light \ + python3-pip \ + tini + +RUN pip3 install --no-cache-dir \ + deluge-client \ + prometheus_client + +RUN git clone --depth=1 https://github.com/sbruder/deluge_exporter /opt/deluge_exporter + +COPY services /etc/service +COPY nginx.conf /etc/nginx/ +COPY entrypoint.sh /usr/local/bin/ + +ENV PER_TORRENT_METRICS 1 +ENV PUID 1000 + +ENTRYPOINT ["entrypoint.sh"] diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 0000000..4e0ee4b --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,5 @@ +#!/bin/sh +set -u +adduser -q --gecos '' --disabled-password --uid $PUID deluge +chown deluge:deluge /download/ /config/ +exec tini -- runsvdir /etc/service/ diff --git a/http-socket/Dockerfile b/http-socket/Dockerfile new file mode 100644 index 0000000..a457a33 --- /dev/null +++ b/http-socket/Dockerfile @@ -0,0 +1,9 @@ +FROM alpine + +RUN apk add --no-cache \ + socat \ + tini + +EXPOSE 80 + +ENTRYPOINT ["tini", "--", "socat", "TCP-LISTEN:80,reuseaddr,fork,su=nobody", "UNIX-CLIENT:/var/run/nginx.sock"] diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..2ef341e --- /dev/null +++ b/nginx.conf @@ -0,0 +1,50 @@ +# vim: set et sts=4 sw=4 ts=4: +user www-data; +worker_processes auto; +pid /run/nginx.pid; + +error_log /dev/stderr warn; + +events { + worker_connections 768; +} + +http { + sendfile on; + tcp_nopush on; + keepalive_timeout 65; + types_hash_max_size 2048; + server_tokens off; + + include /etc/nginx/mime.types; + default_type application/octet-stream; + + server { + listen unix:/var/run/nginx.sock; + server_name localhost; + + location / { + proxy_pass http://127.0.0.1:8112/; + add_header X-Frame-Options SAMEORIGIN; + + # this is NOT authentication (it is in a public git repository + # after all), it is only meant to avoid automatic scans + if ($cookie_preauth != "correct horse battery staple") { + return 404; + } + } + + location /download/ { + alias /download/; + autoindex on; + auth_basic "go away"; + auth_basic_user_file /config/htpasswd; + } + + location /metrics { + proxy_pass http://localhost:9354/metrics; + auth_basic "go away"; + auth_basic_user_file /config/htpasswd; + } + } +} diff --git a/services/deluge-web/run b/services/deluge-web/run new file mode 100755 index 0000000..8ca9db2 --- /dev/null +++ b/services/deluge-web/run @@ -0,0 +1,2 @@ +#!/bin/sh +gosu deluge deluge-web -d -c /config diff --git a/services/deluge_exporter/run b/services/deluge_exporter/run new file mode 100755 index 0000000..e65d5bd --- /dev/null +++ b/services/deluge_exporter/run @@ -0,0 +1,2 @@ +#!/bin/sh +DELUGE_CONFIG_DIR=/config/ gosu deluge /opt/deluge_exporter/deluge_exporter.py diff --git a/services/deluged/run b/services/deluged/run new file mode 100755 index 0000000..9f800fc --- /dev/null +++ b/services/deluged/run @@ -0,0 +1,2 @@ +#!/bin/sh +gosu deluge deluged -d -c /config diff --git a/services/nginx/run b/services/nginx/run new file mode 100755 index 0000000..dc23d67 --- /dev/null +++ b/services/nginx/run @@ -0,0 +1,2 @@ +#!/bin/sh +nginx -g 'daemon off;'