---
version: "3.5"



services:
  penpot-frontend:
    image: "penpotapp/frontend:latest"

    volumes:
      - penpot_assets_data:/opt/data

    env_file:
      - .env

    depends_on:
      - penpot-backend
      - penpot-exporter
      
    logging:
      options:
        max-size: '12m'
        max-file: '5'
      driver: json-file
    labels:
      - traefik.enable=true
      - traefik.http.routers.penpot.rule=Host(`${URL_PENPOT}`)
      - traefik.http.routers.penpot.entrypoints=websecure
      - traefik.http.routers.penpot.tls=true
      - traefik.http.routers.penpot.tls.certresolver=lets-encrypt
      - traefik.http.services.penpot.loadbalancer.server.port=${PORT_PENPOT}

    networks:
      - traefik-proxy

  penpot-backend:
    image: "penpotapp/backend:latest"
    container_name: penpot-backend
    volumes:
      - penpot_assets_data:/opt/data

    depends_on:
      - penpot-postgres
      - penpot-redis

    env_file:
      - .env

    networks:
      - traefik-proxy

  penpot-exporter:
    image: "penpotapp/exporter:latest"
    environment:
      # Don't touch it; this uses internal docker network to
      # communicate with the frontend.
      - PENPOT_PUBLIC_URI=http://penpot-frontend
    networks:
      - traefik-proxy

  penpot-postgres:
    image: "postgres:13"
    restart: always
    stop_signal: SIGINT

    environment:
      - POSTGRES_INITDB_ARGS=--data-checksums
      - POSTGRES_DB=penpot
      - POSTGRES_USER=${PENPOT_DATABASE_USERNAME}
      - POSTGRES_PASSWORD=${PENPOT_DATABASE_PASSWORD}
      - PGDATA=/data/postgres
    volumes:
      - datapostgrespenpot:/data/postgres

    networks:
      - traefik-proxy

  penpot-redis:
    image: redis:6
    restart: always
    networks:
      - traefik-proxy

networks:
  traefik-proxy:
    external:
      name: ${NETWORK_TRAEFIK}
      
volumes:
  datapostgrespenpot:
    driver: local
    driver_opts:
      type: none
      device: ${VOLUME_POSTGRES_PENPOT}
      o: bind
  penpot_assets_data:
    driver: local
    driver_opts:
      type: none
      device: ${VOLUME_DATA_PENPOT}
      o: bind