From 7174f91ffc0db8a9e58f55d54c5387e381038c8a Mon Sep 17 00:00:00 2001 From: Stephan Porada Date: Wed, 28 Apr 2021 12:13:46 +0200 Subject: [PATCH 1/8] remote_branch initial push --- .gitignore | 14 +++ gitea/docker-compose.yml | 72 +++++++++++ nextcloud/collabora/loolwsd.xml.tpl | 183 ++++++++++++++++++++++++++++ nextcloud/docker-compose.yml | 151 +++++++++++++++++++++++ nextcloud/mariadb-conf/docker.cnf | 6 + nginx-rtmp/docker-compose.yml | 8 ++ traefik/docker-compose.yml | 159 ++++++++++++++++++++++++ traefik/live.env.tpl | 4 + ts3/docker-compose.yml | 43 +++++++ ts3/live.env.tpl | 15 +++ wordpress/docker-compose.yml | 46 +++++++ 11 files changed, 701 insertions(+) create mode 100644 .gitignore create mode 100644 gitea/docker-compose.yml create mode 100644 nextcloud/collabora/loolwsd.xml.tpl create mode 100644 nextcloud/docker-compose.yml create mode 100644 nextcloud/mariadb-conf/docker.cnf create mode 100644 nginx-rtmp/docker-compose.yml create mode 100644 traefik/docker-compose.yml create mode 100644 traefik/live.env.tpl create mode 100644 ts3/docker-compose.yml create mode 100644 ts3/live.env.tpl create mode 100644 wordpress/docker-compose.yml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..dad0abf --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +# Environment files +*.env + +# Nextcloud collabora file +loolwsd.xml + +# Service folders +**/bundesdata_web_app/ +**/data/ +**/db/ +**/mariadb/ +**/redis/ +**/html/ +**/volumes/ diff --git a/gitea/docker-compose.yml b/gitea/docker-compose.yml new file mode 100644 index 0000000..cfda5c1 --- /dev/null +++ b/gitea/docker-compose.yml @@ -0,0 +1,72 @@ +version: '3.5' + +networks: + default: + external: + name: traefik_default + +services: + gitea-db: + image: mariadb:10 + container_name: gitea-db + restart: unless-stopped + env_file: live.env + labels: + # Watchtower + - "com.centurylinklabs.watchtower.enable=true" + networks: + - default + volumes: + - /etc/localtime:/etc/localtime:ro + - /etc/timezone:/etc/timezone:ro + - ${GITEA_ROOT}/db:/var/lib/mysql + environment: + - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD} + - MYSQL_USER=${MYSQL_USER} + - MYSQL_PASSWORD=${MYSQL_PASSWORD} + - MYSQL_DATABASE=gitea + + gitea-app: + image: gitea/gitea:latest + container_name: gitea-app + restart: unless-stopped + volumes: + - /etc/localtime:/etc/localtime:ro + - /etc/timezone:/etc/timezone:ro + - ${GITEA_ROOT}/data:/data + #- /home/git/.ssh/:/data/git/.ssh + + env_file: live.env + environment: + - USER_UID=1000 + - USER_GID=1000 + - DB_TYPE=mysql + - DB_HOST=gitea-db:3306 + - DB_NAME=gitea + - DB_USER=${MYSQL_USER} + - DB_PASSWD=${MYSQL_PASSWORD} + - DOMAIN=gitea.${DOMAIN} + #- SSH_PORT=2222 + - DISABLE_SSH=true + - DISABLE_REGISTRATION=true + - ROOT_URL=https://gitea.${DOMAIN}/ + - "APP_NAME=Gitea: Git Gud!" + labels: + # Watchtower + - "com.centurylinklabs.watchtower.enable=true" + # Routes + - "traefik.enable=true" + - "traefik.http.routers.gitea.entrypoints=websecure" + - "traefik.http.routers.gitea.rule=Host(`gitea.${DOMAIN}`)" + - "traefik.http.routers.gitea.tls=true" + - "traefik.http.routers.gitea.tls.certresolver=myresolver" + - "traefik.http.services.gitea.loadbalancer.server.port=3000" + # SSH + #- "traefik.tcp.routers.gitea-ssh.rule=HostSNI(`*`)" + #- "traefik.tcp.routers.gitea-ssh.entrypoints=ssh" + #- "traefik.tcp.routers.gitea-ssh.service=gitea-ssh-svc" + #- "traefik.tcp.services.gitea-ssh-svc.loadbalancer.server.port=2222" + depends_on: + - gitea-db + networks: + - default diff --git a/nextcloud/collabora/loolwsd.xml.tpl b/nextcloud/collabora/loolwsd.xml.tpl new file mode 100644 index 0000000..f8551e4 --- /dev/null +++ b/nextcloud/collabora/loolwsd.xml.tpl @@ -0,0 +1,183 @@ + + + + + + de_DE en_GB en_US es_ES fr_FR it nl pt_BR pt_PT ru + + + + + + collabora.domain.com + + + + 1 + + 4 + 5 + + false + 3600 + + + 30 + 300 + false + 0 + 8000 + 0 + 0 + 100 + 100 + + 10000 + 60 + 300 + 3072 + 85 + + + + + 120 + 900 + + + loleaflet.html + + + true + warning + false + + -INFO-WARN + + + /var/log/loolwsd.log + never + timestamp + true + 10 days + 10 + true + false + + + false + 82589933 + + + + false + + + + + + + + false + + + + + + all + any + + + + 192\.168\.[0-9]{1,3}\.[0-9]{1,3} + ::ffff:192\.168\.[0-9]{1,3}\.[0-9]{1,3} + 127\.0\.0\.1 + ::ffff:127\.0\.0\.1 + ::1 + 172\.17\.[0-9]{1,3}\.[0-9]{1,3} + ::ffff:172\.17\.[0-9]{1,3}\.[0-9]{1,3} + + + + + + + true + false + /etc/loolwsd/cert.pem + /etc/loolwsd/key.pem + /etc/loolwsd/ca-chain.cert.pem + + + 1000 + + + + + + + + + true + true + + + + + + + + + true + false + + + + + classic + + + + + + nextcloud\\.domain\\.com + 10\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3} + 172\.1[6789]\.[0-9]{1,3}\.[0-9]{1,3} + 172\.2[0-9]\.[0-9]{1,3}\.[0-9]{1,3} + 172\.3[01]\.[0-9]{1,3}\.[0-9]{1,3} + 192\.168\.[0-9]{1,3}\.[0-9]{1,3} + 192\.168\.1\.1 + 0 + false + + 900 + + + + nextcloud.domain.com + + + true + + + + + + + + + true + + + true + false + username + test + + + + + + diff --git a/nextcloud/docker-compose.yml b/nextcloud/docker-compose.yml new file mode 100644 index 0000000..0949c70 --- /dev/null +++ b/nextcloud/docker-compose.yml @@ -0,0 +1,151 @@ +version: '3.5' + +networks: + default: + external: + name: traefik_default + +services: + nextcloud-db: + env_file: live.env + image: mariadb:10 + container_name: nextcloud-db + command: --transaction-isolation=READ-COMMITTED --log-bin=ROW + labels: + - "com.centurylinklabs.watchtower.enable=true" + networks: + - default + ports: + - 3306:3306 + restart: unless-stopped + volumes: + - /etc/localtime:/etc/localtime:ro + - /etc/timezone:/etc/timezone:ro + - ${NEXTCLOUD_ROOT}/mariadb:/var/lib/mysql + - ${NEXTCLOUD_ROOT}/mariadb-conf/docker.cnf:/etc/mysql/conf.d/docker.cnf:ro + + nextcloud-redis: + image: redis:6-alpine + container_name: nextcloud-redis + command: redis-server --requirepass ${REDIS_HOST_PASSWORD} + labels: + - "com.centurylinklabs.watchtower.enable=true" + networks: + - default + restart: unless-stopped + volumes: + - ${NEXTCLOUD_ROOT}/redis:/data + - /etc/localtime:/etc/localtime:ro + - /etc/timezone:/etc/timezone:ro + + + nextcloud-app: + depends_on: + - nextcloud-db + - nextcloud-redis + container_name: nextcloud-app + env_file: live.env + environment: + - NEXTCLOUD_TRUSTED_DOMAINS='${NEXTCLOUD_FQDN}' + extra_hosts: + - "${NEXTCLOUD_FQDN}:${TRAEFIK_CONTAINER_IP}" + - "${COLLABORA_FQDN}:${TRAEFIK_CONTAINER_IP}" + image: nextcloud:21 + labels: + # Watchtower + - "com.centurylinklabs.watchtower.enable=true" + # Routes + - "traefik.enable=true" + - "traefik.http.routers.nextcloud.entrypoints=websecure" + - "traefik.http.routers.nextcloud.rule=Host(`nextcloud.${DOMAIN}`)" + - "traefik.http.routers.nextcloud.tls=true" + - "traefik.http.routers.nextcloud.tls.certresolver=myresolver" + - "traefik.http.services.nextcloud.loadbalancer.server.port=80" + # HSTS and Cal Dav + - "traefik.http.middlewares.nc-rep.redirectregex.regex=https://(.*)/.well-known/(card|cal)dav" + - "traefik.http.middlewares.nc-rep.redirectregex.replacement=https://$$1/remote.php/dav/" + - "traefik.http.middlewares.nc-rep.redirectregex.permanent=true" + - "traefik.http.middlewares.nc-header.headers.referrerPolicy=no-referrer" + - "traefik.http.middlewares.nc-header.headers.stsSeconds=31536000" + - "traefik.http.middlewares.nc-header.headers.forceSTSHeader=true" + - "traefik.http.middlewares.nc-header.headers.stsPreload=true" + - "traefik.http.middlewares.nc-header.headers.stsIncludeSubdomains=true" + - "traefik.http.middlewares.nc-header.headers.browserXssFilter=true" + - "traefik.http.middlewares.nc-header.headers.customRequestHeaders.X-Forwarded-Proto=https" + - "traefik.http.routers.nextcloud.middlewares=nc-rep,nc-header" + networks: + - default + restart: unless-stopped + volumes: + - ${NEXTCLOUD_ROOT}/html:/var/www/html + - ${NEXTCLOUD_ROOT}/data:/srv/nextcloud/data + + nextcloud-cron: + image: nextcloud:21 + container_name: nextcloud-cron + labels: + - "com.centurylinklabs.watchtower.enable=true" + restart: unless-stopped + volumes: + - ${NEXTCLOUD_ROOT}/html:/var/www/html + - ${NEXTCLOUD_ROOT}/data:/srv/nextcloud/data + entrypoint: /cron.sh + depends_on: + - nextcloud-db + - nextcloud-redis + - nextcloud-collabora + + nextcloud-coturn: + image: instrumentisto/coturn + container_name: nextcloud-coturn + restart: unless-stopped + ports: + - "3478:3478/tcp" + - "3478:3478/udp" + networks: + - default + command: + - -n + - --log-file=stdout + - --min-port=49160 + - --max-port=49200 + - --realm=${NEXTCLOUD_FQDN} + - --use-auth-secret + - --static-auth-secret=${COTURN_SECRET} + + nextcloud-collabora: + image: collabora/code:6.4.2.2 + container_name: nextcloud-collabora + env_file: live.env + extra_hosts: + - "${NEXTCLOUD_FQDN}:${TRAEFIK_CONTAINER_IP}" + - "${COLLABORA_FQDN}:${TRAEFIK_CONTAINER_IP}" + hostname: collabora.sporada.eu + labels: + # Watchtower + - "com.centurylinklabs.watchtower.enable=true" + # Routes + - "traefik.enable=true" + - "traefik.http.routers.collabora.entrypoints=websecure" + - "traefik.http.routers.collabora.rule=Host(`collabora.${DOMAIN}`)" + - "traefik.http.routers.collabora.tls.certresolver=myresolver" + - "traefik.http.services.collabora.loadbalancer.server.port=9980" + restart: unless-stopped + networks: + - default + ports: + - "9980:9980" + environment: + - domain=${COLLABORA_DOMAIN} + - server_name=${COLLABORA_FQDN} + - username=${COLLABORA_USERNAME} + - password=${COLLABORA_PASSWORD} + - extra_params=--o:ssl.enable=false --o:ssl.termination=true + cap_add: + - MKNOD + volumes: + - /etc/localtime:/etc/localtime:ro + - /etc/timezone:/etc/timezone:ro + - ./collabora/loolwsd.xml:/etc/loolwsd/loolwsd.xml + + diff --git a/nextcloud/mariadb-conf/docker.cnf b/nextcloud/mariadb-conf/docker.cnf new file mode 100644 index 0000000..aae35ff --- /dev/null +++ b/nextcloud/mariadb-conf/docker.cnf @@ -0,0 +1,6 @@ +[mysqld] +innodb_buffer_pool_size=2G +innodb_io_capacity=4000 +innodb_io_capacity_max=4000 +skip-host-cache +skip-name-resolve diff --git a/nginx-rtmp/docker-compose.yml b/nginx-rtmp/docker-compose.yml new file mode 100644 index 0000000..20a9630 --- /dev/null +++ b/nginx-rtmp/docker-compose.yml @@ -0,0 +1,8 @@ +version: "3.7" +services: + streaming: + image: tiangolo/nginx-rtmp + container_name: nginx-rtmp + ports: + - "1935:1935" + restart: unless-stopped diff --git a/traefik/docker-compose.yml b/traefik/docker-compose.yml new file mode 100644 index 0000000..d1ad106 --- /dev/null +++ b/traefik/docker-compose.yml @@ -0,0 +1,159 @@ +version: '3.5' + +networks: + default: + driver: bridge + socket_proxy: + external: + name: socket_proxy + + +services: + # Only accept needed incoming docker API calls + socket-proxy: + container_name: socket-proxy + environment: + - LOG_LEVEL=info # debug,info,notice,warning,err,crit,alert,emerg + ## Variables match the URL prefix (i.e. AUTH blocks access to /auth/* parts of the API, etc.). + # 0 to revoke access. + # 1 to grant access. + ## Granted by Default + - EVENTS=1 + - PING=1 + - VERSION=1 + ## Revoked by Default + # Security critical + - AUTH=0 + - SECRETS=0 + - POST=1 # Watchtower + - DELETE=1 # Watchtower + # GET Optons + - BUILD=0 + - COMMIT=0 + - CONFIGS=0 + - CONTAINERS=1 # Traefik, portainer, etc. + - DISTRIBUTION=0 + - EXEC=0 + - IMAGES=1 # Portainer, Watchtower + - INFO=1 # Portainer + - NETWORKS=1 # Portainer, Watchtower + - NODES=0 + - PLUGINS=0 + - SERVICES=1 # Portainer + - SESSION=0 + - SWARM=0 + - SYSTEM=0 + - TASKS=1 # Portaienr + - VOLUMES=1 # Portainer + # POST Options + - CONTAINERS_CREATE=1 # WatchTower + - CONTAINERS_START=1 # WatchTower + - CONTAINERS_UPDATE=1 # WatchTower + # DELETE Options + - CONTAINERS_DELETE=1 # WatchTower + - IMAGES_DELETE=1 # WatchTower + image: fluencelabs/docker-socket-proxy + labels: + - "com.centurylinklabs.watchtower.enable=true" + networks: + - socket_proxy + ports: + - "127.0.0.1:2375:2375" + # Always restart if server restart etc. + restart: unless-stopped + volumes: + - "/var/run/docker.sock:/var/run/docker.sock" + + # watchtower keeps docker iamges automatically up to date + watchtower: + container_name: watchtower + depends_on: + - socket-proxy + environment: + WATCHTOWER_CLEANUP: "true" + WATCHTOWER_REMOVE_VOLUMES: "true" + WATCHTOWER_INCLUDE_STOPPED: "true" + WATCHTOWER_NO_STARTUP_MESSAGE: "false" + WATCHTOWER_SCHEDULE: "0 30 12 * * *" # Everyday at 12:30 + DOCKER_HOST: tcp://socket-proxy:2375 + image: containrrr/watchtower + labels: + - "com.centurylinklabs.watchtower.enable=true" + networks: + - default + - socket_proxy + restart: unless-stopped + + traefik: + depends_on: + - watchtower + # Always restart also at boot unless manually stopped + restart: unless-stopped + # The official v2 Traefik docker image + image: traefik:v2.3 + networks: + - socket_proxy + - default + env_file: live.env + container_name: "traefik" + # Enables the web UI and tells Traefik to listen to docker + command: + # logging + - "--log.filePath=/logs/traefik.log" + - "--log.level=DEBUG" + # API and Dashboard + #- "--api.insecure=true" + - "--api=true" + - "--api.dashboard=true" + # Docker as provider + - "--providers.docker=true" + - "--providers.docker.exposedbydefault=false" + # Entrypoints (not HTTPS) + - "--entrypoints.web.address=:80" + # HTTPS (websecure entrypoint) + - "--entrypoints.websecure.address=:443" + # TS3 entrypoints + - "--entrypoints.ts-udp.address=:9987/udp" + - "--entrypoints.ts-tcp.address=:30033" + # Use this CA server for testing + # - "--certificatesresolvers.myresolver.acme.caserver=https://acme-staging-v02.api.letsencrypt.org/directory" + - "--certificatesresolvers.myresolver.acme.email=${EMAIL}" + - "--certificatesresolvers.myresolver.acme.httpchallenge=true" + - "--certificatesresolvers.myresolver.acme.httpchallenge.entrypoint=web" + - "--certificatesresolvers.myresolver.acme.storage=/letsencrypt/acme.json" + # Docker socket proxy cli commands + - "--providers.docker.endpoint=tcp://socket-proxy:2375" + labels: + # enable watchtower for traefik + - "com.centurylinklabs.watchtower.enable=true" + # Dashboard stuff + - "traefik.enable=true" + - "traefik.http.routers.traefik-https.rule=Host(`traefik.${DOMAIN}`)" + - "traefik.http.routers.traefik-https.entrypoints=websecure" + - "traefik.http.routers.traefik-https.middlewares=auth" + - "traefik.http.routers.traefik-https.service=api@internal" + - "traefik.http.routers.traefik-https.tls=true" + - "traefik.http.routers.traefik-https.tls.certresolver=myresolver" + - "traefik.http.middlewares.auth.basicauth.users=${TRAEFIK_USER}:${TRAEFIK_PASSWORD_HASH}" + # http to https redirect + - "traefik.http.middlewares.https-redirect.redirectscheme.scheme=https" + - "traefik.http.middlewares.https-redirect.redirectscheme.permanent=true" + - "traefik.http.routers.http_catchall.rule=HostRegexp(`{any:.+}`)" + - "traefik.http.routers.http_catchall.entrypoints=web" + - "traefik.http.routers.http_catchall.middlewares=https-redirect" + ports: + # The HTTP port + - "80:80" + # The HTTPS port + - "443:443" + # The Web UI (enabled by --api.insecure=true) + #- "8080:8080" + # TS3 ports + - "9987:9987/udp" + - "10011:10011" + - "30033:30033" + volumes: + # For certificate + - "./volumes/letsencrypt/acme.json:/letsencrypt/acme.json" + # For logging + - "./volumes/logs/traefik.log:/logs/traefik.log" diff --git a/traefik/live.env.tpl b/traefik/live.env.tpl new file mode 100644 index 0000000..ad303db --- /dev/null +++ b/traefik/live.env.tpl @@ -0,0 +1,4 @@ +TRAEFIK_USER=sporada +TRAEFIK_PASSWORD_HASH=hash +DOMAIN=sporada.eu +EMAIL=porada@posteo.de diff --git a/ts3/docker-compose.yml b/ts3/docker-compose.yml new file mode 100644 index 0000000..867e2ec --- /dev/null +++ b/ts3/docker-compose.yml @@ -0,0 +1,43 @@ +version: '3.5' + +networks: + default: + external: + name: traefik_default + +services: + teamspeak-app: + networks: + - default + image: teamspeak:latest + env_file: live.env + container_name: ts3-service + restart: unless-stopped + volumes: + - ./data:/var/ts3server + depends_on: + - teamspeak-db + labels: + # Watchtower + - "com.centurylinklabs.watchtower.enable=true" + # Traefik + - "traefik.enable=true" + # tcp + - "traefik.tcp.routers.teamspeak-tcp.entrypoints=ts-tcp" + - "traefik.tcp.routers.teamspeak-tcp.service=teamspeak-tcp" + - "traefik.tcp.routers.teamspeak-tcp.rule=HostSNI(`ts3.${DOMAIN}`)" + - "traefik.tcp.services.teamspeak-tcp.loadbalancer.server.port=30033" + # udp + - "traefik.udp.routers.teamspeak-udp.entrypoints=ts-udp" + - "traefik.udp.routers.teamspeak-udp.service=teamspeak-udp" + - "traefik.udp.services.teamspeak-udp.loadbalancer.server.port=9987" + + teamspeak-db: + networks: + - default + image: mariadb:10 + env_file: live.env + container_name: ts3-db + restart: unless-stopped + volumes: + - ./db:/var/lib/mysql diff --git a/ts3/live.env.tpl b/ts3/live.env.tpl new file mode 100644 index 0000000..e31acd9 --- /dev/null +++ b/ts3/live.env.tpl @@ -0,0 +1,15 @@ +DOMAIN=sporada.eu + +### TS3 Server ### +TS3SERVER_DB_PLUGIN=ts3db_mariadb +TS3SERVER_DB_SQLCREATEPATH=create_mariadb +TS3SERVER_DB_HOST=db +TS3SERVER_DB_USER=root +TS3SERVER_DB_PASSWORD=password +TS3SERVER_DB_NAME=teamspeak +TS3SERVER_DB_WAITUNTILREADY=30 +TS3SERVER_LICENSE=accept + +### Mariadb ### +MYSQL_ROOT_PASSWORD=password +MYSQL_DATABASE=teamspeak diff --git a/wordpress/docker-compose.yml b/wordpress/docker-compose.yml new file mode 100644 index 0000000..968bd9d --- /dev/null +++ b/wordpress/docker-compose.yml @@ -0,0 +1,46 @@ +version: '3.5' + +networks: + default: + external: + name: traefik_default + +services: + wordpress: + env_file: live.env + image: wordpress + container_name: wordpress-app + restart: unless-stopped + labels: + # Watchtower + - "com.centurylinklabs.watchtower.enable=true" + - "traefik.enable=true" + ### ### + - "traefik.http.routers.wordpress.entrypoints=websecure" + #- "traefik.http.routers.wordpress.middlewares=hsts-header@file" + - "traefik.http.routers.wordpress.rule=Host(`${DOMAIN}`)" + - "traefik.http.routers.wordpress.tls=true" + - "traefik.http.routers.wordpress.tls.certresolver=myresolver" + #- "traefik.http.routers.wordpress.tls.options=intermediate@file" + ### ### + networks: + - default + volumes: + - ${WORDPRESS_ROOT}/data/wordpress/usr/local/etc/php/conf.d/uploads.ini:/usr/local/etc/php/conf.d/uploads.ini + - ${WORDPRESS_ROOT}/data/wordpress/var/www/html:/var/www/html + - /etc/localtime:/etc/localtime:ro + - /etc/timezone:/etc/timezone:ro + + db: + env_file: live.env + image: mysql:5.7 + restart: unless-stopped + container_name: wordpress-db + labels: + # Watchtower + - "com.centurylinklabs.watchtower.enable=true" + networks: + - default + volumes: + - ${WORDPRESS_ROOT}/db/var/lib/mysql:/var/lib/mysql + From ff82a1c2e3264768ab214678169bb3fc4e14de4e Mon Sep 17 00:00:00 2001 From: Stephan Porada Date: Thu, 29 Apr 2021 10:28:08 +0200 Subject: [PATCH 2/8] add files from master --- README.md | 17 +++++++++++++++++ gitea/live.env.tpl | 11 +++++++++++ nextcloud/live.env.tpl | 31 +++++++++++++++++++++++++++++++ nginx-rtmp/README.md | 1 + traefik/README.md | 1 + ts3/README.md | 2 ++ wordpress/live.env.tpl | 15 +++++++++++++++ 7 files changed, 78 insertions(+) create mode 100644 README.md create mode 100644 gitea/live.env.tpl create mode 100644 nextcloud/live.env.tpl create mode 100644 nginx-rtmp/README.md create mode 100644 traefik/README.md create mode 100644 ts3/README.md create mode 100644 wordpress/live.env.tpl diff --git a/README.md b/README.md new file mode 100644 index 0000000..626dbe3 --- /dev/null +++ b/README.md @@ -0,0 +1,17 @@ +# selfhosted-traefik + +This is a setup/guide/repo for self hosting services like nextcloud, gitea etc. to avoid using SaaSS I have no control over. +I use Traefik and docker-compose to self hoste services. +Inspired by: https://github.com/awesome-selfhosted/awesome-selfhosted + +# Installation/Setup guide (WIP) + +1. Create a user named _compute_ on your server. _compute_ needs a home directory. +2. Create a _services_ directory in the home directory of compute with `mkdir service`. +3. navigat into _services_ with `cd services`. +4. Clone this git into services with `git clone https://gitea.sporada.eu/sporada/selfhosted-traefik.git`. +5. For every service copy the live.env.tpl to live.env file and edit it accordingly. 'cp live.env.tpl live.env' +6. Navigate into the traefik with cd traefik` folder and start traefik with `docker-compose --env-file live.env up` +7. Could be that you have to create some networks manually before starting everything. +7. Navigate into the other service folders and start every service with `docker-compose --env-file live.env up` after additional setup steps have been completed. (See netxt step!) +8. Every serveice hase an additional README.md where the specific setup steps for the service is explained. Like creating the .env file etc. Follow those steps and then start the service as said above. \ No newline at end of file diff --git a/gitea/live.env.tpl b/gitea/live.env.tpl new file mode 100644 index 0000000..de5c1b4 --- /dev/null +++ b/gitea/live.env.tpl @@ -0,0 +1,11 @@ +# MariaDB settings +MYSQL_ROOT_PASSWORD=password_db_root +MYSQL_DATABASE=gitea +MYSQL_USER=gitea +MYSQL_PASSWORD=pasword_db + +# Gitea +GITEA_ROOT=/home/compute/services/gitea + +# Domain +DOMAIN=domain.com diff --git a/nextcloud/live.env.tpl b/nextcloud/live.env.tpl new file mode 100644 index 0000000..80bd0cf --- /dev/null +++ b/nextcloud/live.env.tpl @@ -0,0 +1,31 @@ +# MariaDB settings +MYSQL_ROOT_PASSWORD=password_db_root +MYSQL_DATABASE=nextcloud +MYSQL_USER=nextcloud +MYSQL_PASSWORD=password_db +MYSQL_INITDB_SKIP_TZINFO=1 +MYSQL_HOST=nextcloud-db + +# Redis +REDIS_HOST=nextcloud-redis +REDIS_HOST_PASSWORD=password_redis + +# Nextcloud +NEXTCLOUD_ROOT=/home/compute/services/nextcloud +NEXTCLOUD_DATA_DIR=/srv/nextcloud/data +NEXTCLOUD_FQDN=your_nextcloud_sub_domain.domain.com +# This is the IP of the Trafik container. This changes if the traefik container restarts. If it is not the current traefik container IP collabora does not work. Check the current traefik container IP with: docker inspect traefik and get the IP from the Networks -> traefik_default -> IPAddress section +TRAEFIK_CONTAINER_IP=172.27.0.16 +PHP_MEMORY_LIMIT=2048M +PHP_UPLOAD_LIMIT=8G + +# Collabora +COLLABORA_FQDN=collabora.domain.com +COLLABORA_DOMAIN=nextcloud_sub_domain\\.domain\\.com # This is the domain which the collabora server is requests accepting from. +COLLABORA_USERNAME=username +COLLABORA_PASSWORD=password_collabora + +# COTURN +COTURN_SECRET=password_coturn +# Traefik +DOMAIN=domain.com diff --git a/nginx-rtmp/README.md b/nginx-rtmp/README.md new file mode 100644 index 0000000..683a1e5 --- /dev/null +++ b/nginx-rtmp/README.md @@ -0,0 +1 @@ +Not Traefik ready! diff --git a/traefik/README.md b/traefik/README.md new file mode 100644 index 0000000..00d7bdd --- /dev/null +++ b/traefik/README.md @@ -0,0 +1 @@ +WIP diff --git a/ts3/README.md b/ts3/README.md new file mode 100644 index 0000000..a5b0ccb --- /dev/null +++ b/ts3/README.md @@ -0,0 +1,2 @@ +This is now routed via traefik. +Still checking performance if working it is. diff --git a/wordpress/live.env.tpl b/wordpress/live.env.tpl new file mode 100644 index 0000000..48f0a23 --- /dev/null +++ b/wordpress/live.env.tpl @@ -0,0 +1,15 @@ +# Domain +DOMAIN=domain.com + +# Wordpress +WORDPRESS_ROOT=/home/compute/services/wordpress +WORDPRESS_DB_HOST=db +WORDPRESS_DB_USER=username +WORDPRESS_DB_PASSWORD=password_db +WORDPRESS_DB_NAME=wordpress + +# DB +MYSQL_DATABASE=wordpress +MYSQL_USER=username +MYSQL_PASSWORD=password_db +MYSQL_RANDOM_ROOT_PASSWORD=password_db_root From 50c67f9d7ab32bd5fb06dc9ff88aeb798d89fe62 Mon Sep 17 00:00:00 2001 From: sporada Date: Thu, 29 Apr 2021 10:30:50 +0200 Subject: [PATCH 3/8] Update 'ts3/live.env.tpl' --- ts3/live.env.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ts3/live.env.tpl b/ts3/live.env.tpl index e31acd9..cf6772c 100644 --- a/ts3/live.env.tpl +++ b/ts3/live.env.tpl @@ -3,7 +3,7 @@ DOMAIN=sporada.eu ### TS3 Server ### TS3SERVER_DB_PLUGIN=ts3db_mariadb TS3SERVER_DB_SQLCREATEPATH=create_mariadb -TS3SERVER_DB_HOST=db +TS3SERVER_DB_HOST=teamspeak-db TS3SERVER_DB_USER=root TS3SERVER_DB_PASSWORD=password TS3SERVER_DB_NAME=teamspeak From 81d484de341dd18d8ae423ab601300e7f515c05f Mon Sep 17 00:00:00 2001 From: Stephan Porada Date: Thu, 29 Apr 2021 10:33:56 +0200 Subject: [PATCH 4/8] add nextcloud readme --- nextcloud/README.md | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 nextcloud/README.md diff --git a/nextcloud/README.md b/nextcloud/README.md new file mode 100644 index 0000000..99db0f4 --- /dev/null +++ b/nextcloud/README.md @@ -0,0 +1,37 @@ +# Nextcloud setup +https://help.nextcloud.com/t/howto-ubuntu-docker-nextcloud-talk-collabora/76430 +Follow the guide above as close as possible and deviate where traefik is being used etc. + +There is also somewhere a step to set up an alias for `occ` that can be used outside the container to directly execute occ cli commands inside the container. (Should be in the guide above) + +#Nextcloud self check fixes +Set default_phone_region like this: +occ config:syste:set default_phone_region --value="DE" + +# Collabora loolwsd setup +Check if you have to alter this line in the _collabora/loolwsd.xml_ file: + +`nextcloud\\.sporada\\.eu` + +# Server Security and tuning +Look at the documentation for server security and server tuning: https://docs.nextcloud.com/server/21/admin_manual/installation/index.html# +Do as much as is possible with the docker setup. The PHP stuff for example is not needed. +- Do defnitly the database cache things. +- Lower logging level +- Change size of the php cache etc. (This should be part of the config file mounted into the container) + + +# Photo Preview Generation: +- Photo viewer tweaks: https://rayagainstthemachine.net/linux%20administration/nextcloud-photos/ +- Use these values to svae space on prieview files and speed nextcloud up. https://ownyourbits.com/2019/06/29/understanding-and-improving-nextcloud-previews/ +```sh +occ config:app:set previewgenerator squareSizes --value="32 256" +occ config:app:set previewgenerator widthSizes --value="256 384" +occ config:app:set previewgenerator heightSizes --value="256" +occ config:system:set preview_max_x --value 2048 +occ config:system:set preview_max_y --value 2048 +occ config:system:set jpeg_quality --value 60 +occ config:app:set preview jpeg_quality --value="60" +``` +- I created a cron Job outside the container using the `occ` client command to trigger photo pre generation every day. +- Maybe this can be added to the cron nextcloud container? \ No newline at end of file From b24d9074ac11845f9020453fdf81b71bf9510588 Mon Sep 17 00:00:00 2001 From: Stephan Porada Date: Thu, 29 Apr 2021 10:39:16 +0200 Subject: [PATCH 5/8] update live.env.tpl --- traefik/live.env.tpl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/traefik/live.env.tpl b/traefik/live.env.tpl index ad303db..9eec331 100644 --- a/traefik/live.env.tpl +++ b/traefik/live.env.tpl @@ -1,4 +1,4 @@ TRAEFIK_USER=sporada TRAEFIK_PASSWORD_HASH=hash -DOMAIN=sporada.eu -EMAIL=porada@posteo.de +DOMAIN=domain.com +EMAIL=name@host.de From 685bfcda294dd646a70bf55af5edc655da5d6801 Mon Sep 17 00:00:00 2001 From: Stephan Porada Date: Thu, 29 Apr 2021 10:42:54 +0200 Subject: [PATCH 6/8] change traefik live.env.tpl --- traefik/live.env.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/traefik/live.env.tpl b/traefik/live.env.tpl index 9eec331..eab3589 100644 --- a/traefik/live.env.tpl +++ b/traefik/live.env.tpl @@ -1,4 +1,4 @@ -TRAEFIK_USER=sporada +TRAEFIK_USER=username TRAEFIK_PASSWORD_HASH=hash DOMAIN=domain.com EMAIL=name@host.de From df34f1f0004f9a9c42de766a98e1b8fe55765a30 Mon Sep 17 00:00:00 2001 From: Stephan Porada Date: Thu, 29 Apr 2021 10:45:25 +0200 Subject: [PATCH 7/8] update traefik live.env.tpl --- traefik/live.env.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/traefik/live.env.tpl b/traefik/live.env.tpl index eab3589..e4356f4 100644 --- a/traefik/live.env.tpl +++ b/traefik/live.env.tpl @@ -1,4 +1,4 @@ TRAEFIK_USER=username TRAEFIK_PASSWORD_HASH=hash DOMAIN=domain.com -EMAIL=name@host.de +EMAIL=user@domain.de From 5de4093a2960c08d427742f1fd7053da76d5d9d3 Mon Sep 17 00:00:00 2001 From: Stephan Porada Date: Thu, 29 Apr 2021 10:47:18 +0200 Subject: [PATCH 8/8] update ts3 live.env.tpl --- ts3/live.env.tpl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ts3/live.env.tpl b/ts3/live.env.tpl index cf6772c..d7a5cab 100644 --- a/ts3/live.env.tpl +++ b/ts3/live.env.tpl @@ -5,11 +5,11 @@ TS3SERVER_DB_PLUGIN=ts3db_mariadb TS3SERVER_DB_SQLCREATEPATH=create_mariadb TS3SERVER_DB_HOST=teamspeak-db TS3SERVER_DB_USER=root -TS3SERVER_DB_PASSWORD=password +TS3SERVER_DB_PASSWORD=password_db TS3SERVER_DB_NAME=teamspeak TS3SERVER_DB_WAITUNTILREADY=30 TS3SERVER_LICENSE=accept ### Mariadb ### -MYSQL_ROOT_PASSWORD=password +MYSQL_ROOT_PASSWORD=password_db MYSQL_DATABASE=teamspeak