version: '3.5'

services:
  penpot-frontend:
    image: 'penpotapp/frontend:latest'
    restart: always
    volumes:
      - penpot_assets_data:/opt/data
    env_file:
      - config.env
    depends_on:
      - penpot-backend
      - penpot-exporter
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.penpot-secure.entrypoints=https"
      - "traefik.http.routers.penpot-secure.rule=Host(`penpot.mrdev023.fr`)"
      - "traefik.http.routers.penpot-secure.tls=true"
      - "traefik.http.routers.penpot-secure.tls.certresolver=sslResolver"
      # - "traefik.http.routers.whoami-secure.service=whoami"
      # - "traefik.http.services.whoami.loadbalancer.server.port=9002"
      - "traefik.docker.network=proxy"
    networks:
      - internal
      - proxy

  penpot-backend:
    image: 'penpotapp/backend:latest'
    restart: always
    volumes:
      - penpot_assets_data:/opt/data
    depends_on:
      - penpot-postgres
      - penpot-redis
    env_file:
      - config.env
    networks:
      - internal

  penpot-exporter:
    image: 'penpotapp/exporter:latest'
    restart: always
    env_file:
      - config.env
    environment:
      # Don't touch it; this uses internal docker network to
      # communicate with the frontend.
      - PENPOT_PUBLIC_URI=http://penpot-frontend
    networks:
      - internal

  penpot-postgres:
    image: 'postgres:14'
    restart: always
    environment:
      - POSTGRES_INITDB_ARGS=--data-checksums
      - POSTGRES_DB=penpot
      - POSTGRES_USER=penpot
      - POSTGRES_PASSWORD=penpot
    volumes:
      - penpot_postgres_data:/var/lib/postgresql/data
    networks:
      - internal

  penpot-redis:
    image: redis:7
    restart: always
    networks:
      - internal

volumes:
  penpot_postgres_data:
  penpot_assets_data:

networks:
  internal:
  proxy:
    external: true