version: '2'

networks:
  default:
    driver: bridge
  gitea:
    external: false
  nextcloud:
    driver: bridge
  portainer:
    external: false

volumes:
  gitea-db-data:
    driver: local
  gitea-data:
    driver: local
  nextcloud-db:
    driver: local
  nextcloud:
    driver: local
  portainer:
    driver: local

services:

  nginx-proxy:
    image: nginx
    restart: always
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - "./nginx/vhost.d:/etc/nginx/vhost.d"
      - "./nginx/html:/etc/nginx/html"
      - "./nginx/conf/nginx.conf:/etc/nginx/nginx.conf"
      - "/etc/letsencrypt/live/henryfjordan.com/fullchain.pem:/etc/nginx/certs/default.crt"
      - "/etc/letsencrypt/live/henryfjordan.com/privkey.pem:/etc/nginx/certs/default.key"
      - "./nginx/certs/dhparam.pem:/etc/nginx/certs/dhparam.pem"
    networks:
      - default
      - gitea
      - nextcloud
      - portainer

  gitea-postgres:
    image: postgres:9.5
    restart: always
    environment:
      - "POSTGRES_USER=gitea"
      - "POSTGRES_PASSWORD=gitea"
      - "POSTGRES_DB=gitea"
    volumes:
      - "gitea-db-data:/var/lib/postgresql/data"
    networks:
      - gitea

  gitea:
    image: gitea/gitea:latest
    restart: always
    networks:
      - gitea
    volumes:
      - gitea-data:/data
    expose:
      - 3000
    networks:
      - gitea
    environment:
      - DISABLE_REGISTRATION=true
    depends_on:
      - gitea-postgres
      - nginx-proxy

  nextcloud-db:
    image: postgres
    restart: always
    volumes:
      - nextcloud-db:/var/lib/postgresql/data
    environment:
      - "POSTGRES_USER=nextcloud"
      - "POSTGRES_PASSWORD=nextcloud"
      - "POSTGRES_DB=nextcloud"
    networks:
      - nextcloud

  nextcloud:
    image: nextcloud
    expose:
      - 8080
    ports:
      - "8080:8080"
    volumes:
      - nextcloud:/var/www/html
      - ./apache/apache2.conf:/etc/apache2/apache2.conf
    restart: always
    networks:
      - nextcloud
    depends_on:
      - nextcloud-db
      - nginx-proxy

  portainer:
    image: portainer/portainer
    command: -H unix:///var/run/docker.sock
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - portainer:/data
    networks:
      - portainer

