version: "2"
volumes:
  pgdata:
  cache:
services:
  postgres:
    image: "openmaptiles/postgis:${TOOLS_VERSION}"
    volumes:
      - pgdata:/var/lib/postgresql/data
    networks:
      - postgres_conn
    ports:
      - "5432"
    env_file: .env
  import-natural-earth:
    image: "openmaptiles/import-natural-earth:${TOOLS_VERSION}"
    env_file: .env
    networks:
      - postgres_conn
  import-water:
    image: "openmaptiles/import-water:${TOOLS_VERSION}"
    env_file: .env
    networks:
      - postgres_conn
  import-lakelines:
    image: "openmaptiles/import-lakelines:${TOOLS_VERSION}"
    env_file: .env
    networks:
      - postgres_conn
  import-osm:
    image: "openmaptiles/import-osm:${TOOLS_VERSION}"
    env_file: .env
    environment:
      DIFF_MODE: ${DIFF_MODE}
    networks:
      - postgres_conn
    volumes:
      - ./data:/import
      - ./build:/mapping
      - cache:/cache
  import-osmborder:
    image: "openmaptiles/import-osmborder:${TOOLS_VERSION}"
    env_file: .env
    networks:
      - postgres_conn
  import-osm-diff:
    image: "openmaptiles/import-osm:${TOOLS_VERSION}"
    env_file: .env
    command: ./import_diff.sh
    environment:
      DIFF_MODE: ${DIFF_MODE}
    networks:
      - postgres_conn
    volumes:
      - ./data:/import
      - ./build:/mapping
      - cache:/cache
  update-osm:
    image: "openmaptiles/import-osm:${TOOLS_VERSION}"
    env_file: .env
    environment:
      DIFF_MODE: ${DIFF_MODE}
    command: ./import_update.sh
    networks:
      - postgres_conn
    volumes:
      - ./data:/import
      - ./build:/mapping
      - cache:/cache
  import-sql:
    # This target is obsolete, and was left for backwards compatibility
    # Use openmaptiles-tools target instead
    image: "openmaptiles/openmaptiles-tools:${TOOLS_VERSION}"
    command: import-sql
    env_file: .env
    networks:
      - postgres_conn
    volumes:
      - .:/tileset
      - ./build:/sql
  import-wikidata:
    image: "openmaptiles/import-wikidata:${TOOLS_VERSION}"
    env_file: .env
    command: import-wikidata
    networks:
      - postgres_conn
    volumes:
      - ./wikidata:/import
  openmaptiles-tools:
    image: "openmaptiles/openmaptiles-tools:${TOOLS_VERSION}"
    env_file: .env
    networks:
      - postgres_conn
    volumes:
      - .:/tileset
      - ./build:/sql
  generate-changed-vectortiles:
    image: "openmaptiles/generate-vectortiles:${TOOLS_VERSION}"
    command: ./export-list.sh
    volumes:
      - ./data:/export
      - ./build/openmaptiles.tm2source:/tm2source
    networks:
      - postgres_conn
    env_file: .env
  generate-vectortiles:
    image: "openmaptiles/generate-vectortiles:${TOOLS_VERSION}"
    volumes:
      - ./data:/export
      - ./build/openmaptiles.tm2source:/tm2source
    networks:
      - postgres_conn
    env_file: .env
    environment:
      BBOX: ${BBOX}
      MIN_ZOOM: ${MIN_ZOOM}
      MAX_ZOOM: ${MAX_ZOOM}
  postserve:
    image: "openmaptiles/openmaptiles-tools:${TOOLS_VERSION}"
    command: postserve openmaptiles.yaml --verbose
    env_file: .env
    networks:
      - postgres_conn
    ports:
      - "8090:8090"
    volumes:
      - .:/tileset

networks:
  postgres_conn:
    driver: bridge
