version: "3.8"

networks:
  deltachunk-ext: 
    driver_opts:
      com.docker.network.bridge.host_binding_ipv4: "127.0.0.1"
  deltachunk-int: 
    driver_opts:
      com.docker.network.bridge.host_binding_ipv4: "127.0.0.1"

services:
  nginx:
    image: nginx:${NGINX_VERSION}
    container_name: nginx
    restart: unless-stopped
    networks:
      - deltachunk-ext
      - deltachunk-int
    ports:
      - "${NGINX_HOST_HTTPS_PORT}:${NGINX_CONTAINER_HTTPS_PORT}"
      - "${NGINX_HOST_HTTP_PORT}:${NGINX_CONTAINER_HTTP_PORT}"
    volumes:
      - "${NGINX_HOST_ETC}:${NGINX_CONTAINER_ETC}:ro" 
      - "${NGINX_HOST_WEB_ROOT}:${NGINX_CONTAINER_WEB_ROOT}:ro"
      - "${NGINX_HOST_CERTS_DIR}:${NGINX_CONTAINER_CERTS_DIR}:ro"
      - "${NGINX_HOST_LOG_DIR}:${NGINX_CONTAINER_LOG_DIR}:"
      - "${NGINX_HOST_CACHE}:${NGINX_CONTAINER_CACHE}"
      - "${NGINX_HOST_RUN}:${NGINX_CONTAINER_RUN}"
    depends_on:
      - gitea
      - aprilandtrey
      - commento_aprilandtrey
      - eldon
      - commento_eldon
    links:
      - gitea
      - aprilandtrey
      - commento_aprilandtrey
      - eldon
      - commento_eldon
  gitea: 
    image: gitea/gitea:${GITEA_VERSION}
    container_name: gitea
    environment:
      - USER=${GITEA_USER}
      - USER_UID=${GITEA_USER_UID}
      - USER_GID=${GITEA_USER_GID}
      - GITEA__database__DB_TYPE=${GITEA_DATABASE_TYPE}
      - GITEA__database__HOST=${GITEA_DATABASE_HOST}
      - GITEA__database__USER=${GITEA_DATABASE_USER}
      - GITEA__database__PASSWD=${GITEA_DATABASE_PASS}
      - GITEA__database__NAME=${GITEA_DATABASE}
    depends_on:
      - mariadb
    restart: unless-stopped
    networks:
      - deltachunk-int
    ports:
      - "${GITEA_CONTAINER_PORT}"
      - "${GITEA_HOST_SSH_PORT}:${GITEA_CONTAINER_SSH_PORT}"
    volumes:
      - "${GITEA_CONTAINER_DATA}/.snapshots/"
      - "${GITEA_HOST_DATA}:${GITEA_CONTAINER_DATA}"
      - "${GITEA_HOST_SSH_DIR}:${GITEA_CONTAINER_SSH_DIR}"
      - "/etc/localtime:/etc/localtime:ro"
    links:
      - mariadb
  aprilandtrey:
    image: ghost:${GHOST_VERSION}
    container_name: aprilandtrey
    environment:
      database__client: ${APRILANDTREY_GHOST_DATABASE_CLIENT}
      database__connection__host: ${APRILANDTREY_GHOST_DATABASE_HOST}
      database__connection__user: ${APRILANDTREY_GHOST_DATABASE_USER}
      database__connection__password: ${APRILANDTREY_GHOST_DATABASE_PASS}
      database__connection__database: ${APRILANDTREY_GHOST_DATABASE}
      url: ${APRILANDTREY_GHOST_URL}
    restart: unless-stopped
    depends_on:
      - mariadb
    networks:
      - deltachunk-int
    ports:
      - "${APRILANDTREY_GHOST_CONTAINER_PORT}"
    links:
      - mariadb
    volumes:
      - "${APRILANDTREY_GHOST_HOST_DIR}:${APRILANDTREY_GHOST_CONTAINER_DIR}"
  eldon:
    image: ghost:${GHOST_VERSION}
    container_name: eldon
    environment:
      database__client: ${ELDON_GHOST_DATABASE_CLIENT}
      database__connection__host: ${ELDON_GHOST_DATABASE_HOST}
      database__connection__user: ${ELDON_GHOST_DATABASE_USER}
      database__connection__password: ${ELDON_GHOST_DATABASE_PASS}
      database__connection__database: ${ELDON_GHOST_DATABASE}
      url: ${ELDON_GHOST_URL}
    restart: unless-stopped
    depends_on:
      - mariadb
    networks:
      - deltachunk-int
    ports:
      - "${ELDON_GHOST_CONTAINER_PORT}"
    links:
      - mariadb
    volumes:
      - "${ELDON_GHOST_CONTAINER_DIR}/.snapshots/"
      - "${ELDON_GHOST_HOST_DIR}:${ELDON_GHOST_CONTAINER_DIR}"
  commento_aprilandtrey:
    image:  registry.gitlab.com/commento/commento
    container_name:  commento_aprilandtrey
    restart:  unless-stopped
    ports: 
      - "${APRILANDTREY_COMMENTO_CONTAINER_PORT}"
    environment:
      COMMENTO_ORIGIN: "${APRILANDTREY_COMMENTO_ORIGIN}"
      COMMENTO_PORT:  "${APRILANDTREY_COMMENTO_CONTAINER_PORT}"
      COMMENTO_POSTGRES:  "${APRILANDTREY_COMMENTO_URL}"
      COMMENTO_SMTP_HOST: "${GMAIL_HOST}"
      COMMENTO_SMTP_USERNAME: "${GMAIL_USER}"
      COMMENTO_SMTP_PORT: "${GMAIL_PORT}"
      COMMENTO_SMTP_PASSWORD: "${GMAIL_PASS}"
      COMMENTO_SMTP_FROM_ADDRESS:  "noreply@aprilandtrey.us"
      COMMENTO_FORBID_NEW_OWNERS: "true"
      COMMENTO_AKISMET_KEY: "${COMMENTO_AKISMET_API_KEY}"
    networks:
      - deltachunk-int
    depends_on:
      - postgresdb
  commento_eldon:
    image:  registry.gitlab.com/commento/commento
    container_name:  commento_eldon
    restart:  unless-stopped
    ports: 
      - "${ELDON_COMMENTO_CONTAINER_PORT}"
    environment:
      COMMENTO_ORIGIN: "${ELDON_COMMENTO_ORIGIN}"
      COMMENTO_PORT:  "${ELDON_COMMENTO_CONTAINER_PORT}"
      COMMENTO_POSTGRES:  "${ELDON_COMMENTO_URL}"
      COMMENTO_SMTP_HOST: "${GMAIL_HOST}"
      COMMENTO_SMTP_USERNAME: "${GMAIL_USER}"
      COMMENTO_SMTP_PORT: "${GMAIL_PORT}"
      COMMENTO_SMTP_PASSWORD: "${GMAIL_PASS}"
      COMMENTO_SMTP_FROM_ADDRESS:  "noreply@eldon.me"
      COMMENTO_FORBID_NEW_OWNERS: "true"
      COMMENTO_AKISMET_KEY: "${COMMENTO_AKISMET_API_KEY}"
    networks:
      - deltachunk-int
    depends_on:
      - postgresdb
  mariadb:
    image: mariadb:${MARIADB_VERSION}
    container_name: mariadb
    restart: unless-stopped
    networks:
      - deltachunk-int
    ports:
      - "${MARIADB_CONTAINER_PORT}"
    volumes:
      - "${MARIADB_CONTAINER_DATA_DIR}/.snapshots/"
      - "${MARIADB_HOST_DATA_DIR}:${MARIADB_CONTAINER_DATA_DIR}"
      - "${MARIADB_HOST_LOG_DIR}:${MARIADB_CONTAINER_LOG_DIR}"
      - "${MARIADB_HOST_CONF}:${MARIADB_CONTAINER_CONF}:ro"
      - "${MARIADB_HOST_INIT}:${MARIADB_CONTAINER_INIT}:ro"
  postgresdb:
    image: postgres:${POSTGRES_VERSION}
    container_name:  postgresdb
    restart: unless-stopped
    shm_size: "256MB"
    networks:
      - deltachunk-int
    environment:
      POSTGRES_PASSWORD: "${POSTGRES_PASS}"
      POSTGRES_USER: "${POSTGRES_USER}"
      PGDATA: "${POSTGRES_CONTAINER_DIR}"
    ports:
      - "${POSTGRES_CONTAINER_PORT}"
    volumes:
      - "${POSTGRES_HOST_DIR}:${POSTGRES_CONTAINER_DIR}"
      - "${POSTGRES_HOST_INIT}:${POSTGRES_CONTAINER_INIT}:ro"
      - "${POSTGRES_HOST_ETC}:${POSTGRES_CONTAINER_ETC}:ro"
      - "${POSTGRES_PASSWD}:${POSTGRES_CONTAINER_PASSWD}:ro"

