version: '3.8'

services:
  reverse-proxy:
    container_name:  "reverse-proxy"
    image:           "traefik:v3.6.5"
    restart:         "unless-stopped"
    labels:
         #           global redirect to https
         -           "traefik.http.routers.http-catchall.rule=hostregexp(`{host:.+}`)"
         -           "traefik.http.routers.http-catchall.entrypoints=web"
         -           "traefik.http.routers.http-catchall.middlewares=redirect-to-https"
         #           middleware redirect
         -           "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https"
    command:
         -           "--api.insecure=true"
         -           "--certificatesresolvers.njordresolver.acme.caserver=https://acme-v02.api.letsencrypt.org/directory"
         -           "--certificatesresolvers.njordresolver.acme.email=progisart@gmx.de"
         -           "--certificatesresolvers.njordresolver.acme.httpchallenge.entrypoint=web"
         -           "--certificatesresolvers.njordresolver.acme.storage=/letsencrypt/acme.json"
         -           "--certificatesresolvers.njordresolver.acme.dnschallenge.resolvers=1.1.1.1:53,8.8.8.8:53"
         -           "--entrypoints.web.address=0.0.0.0:80"
         -           "--entrypoints.websecure.address=0.0.0.0:443"
         -           "--log.level=info"
         -           "--providers.docker=true"
    ports:
         -             "80:80"
         -            "443:443"
         -           "8080:8080"
    volumes:
         -                  "./letsencrypt:/letsencrypt"
         -           "/var/run/docker.sock:/var/run/docker.sock"
    depends_on:
         -           gogs
         -           nxtcld
         -           httpd

  gogs:
    image:           "gogs/gogs:0.13"
    container_name:  "gogs"
    privileged:      true
    restart:         "unless-stopped"
    labels:
         -           "traefik.enable=true"
         -           "traefik.http.routers.gogs.entrypoints=websecure"
         -           "traefik.http.routers.gogs.rule=Host(`gogs.njord.dynv6.net`)"
         -           "traefik.http.routers.gogs.tls.certresolver=njordresolver"
         -           "traefik.http.routers.gogs.tls=true"
         -           "traefik.http.services.gogs.loadbalancer.server.port=3000"
    ports:
         -           "881:3000"
    volumes:
         -           "./gogs/data:/data"
    environment:
         -           "DB_TYPE=sqlite3"


  nxtcld_db:
    image:           "mariadb:latest"
    container_name:  "nxtcld_db"
    command:         [ "--transaction-isolation=READ-COMMITTED", "--binlog-format=ROW" ]   
    restart:         "unless-stopped"
    volumes:
      -              "./nxtcld/db:/var/lib/mysql"
    environment:
      -              MYSQL_ROOT_PASSWORD=nextcloud_admin
      -              MYSQL_PASSWORD=nextcloud
      -              MYSQL_DATABASE=nextcloud
      -              MYSQL_USER=nextcloud

  nxtcld:
    image:           "nextcloud:stable"
    container_name:  "nxtcld"
    privileged:      true
    restart:         "unless-stopped"
    labels:
         -           "traefik.enable=true"
         -           "traefik.http.routers.nxtcld.entrypoints=websecure"
         -           "traefik.http.routers.nxtcld.rule=Host(`nxtcld.njord.dynv6.net`)"
         -           "traefik.http.routers.nxtcld.tls.certresolver=njordresolver"
         -           "traefik.http.routers.nxtcld.tls=true"
         -           "traefik.http.services.nxtcld.loadbalancer.server.port=80"
    ports:
         -           "882:80"
    links:
         -           "nxtcld_db"
    volumes:
         -           "./nxtcld/data:/var/www/html"
    environment:
         -           MYSQL_PASSWORD=nextcloud
         -           MYSQL_DATABASE=nextcloud
         -           MYSQL_USER=nextcloud
         -           MYSQL_HOST=nxtcld_db
    depends_on:
         -           nxtcld_db

  httpd:
    image:           "httpd:2.4.57"
    container_name:  "httpd"
    restart:         "unless-stopped"
    labels:
         -           "traefik.enable=true"
         -           "traefik.http.routers.httpd.entrypoints=websecure"
         -           "traefik.http.routers.httpd.rule=Host(`progisart.njord.dynv6.net`)"
         -           "traefik.http.routers.httpd.tls.certresolver=njordresolver"
         -           "traefik.http.routers.httpd.tls=true"
         -           "traefik.http.services.httpd.loadbalancer.server.port=80"
    ports:
         -           "883:80"
    volumes:
         -           "./httpd/data:/usr/local/apache2/htdocs"

networks:
  default:
    driver: bridge
    driver_opts:
      com.docker.network.enable_ipv6: "false"