# This is the swarm version of docker-compose.yml, for running InstaPy under Docker swarm
# An example configuration / process is available at https://geek-cookbook.funkypenguin.co.nz/recipies/instapy/

version: '3'
services:
  web:
    command: ["./wait-for", "selenium:4444", "--", "python", "docker_quickstart.py"]
    environment:
      - PYTHONUNBUFFERED=0

    # Modify the image to whatever Tim's image tag ends up as. I used funkypenguin/instapy for my build
    image: funkypenguin/instapy:latest

    # When using swarm, you can't use relative paths, so the following needs to be set to the full filesystem path to your logs and docker_quickstart.py
    # Bind-mount docker_quickstart.py, since now that we're using a public image, we can't "bake" our credentials into the image anymore
    volumes:
      - /full/path/to/logs:/code/logs
      - /full/path/to/docker_quickstart.py:/code/docker_quickstart.py:ro

    # This section allows docker to restart the container when it exits (either normally or abnormally), which ensures that
    # InstaPy keeps re-running. Tweak the delay to avoid being banned for excessive activity 
    deploy:
      restart_policy:
        condition: any
        delay: 3600s


  selenium:
    image: selenium/standalone-chrome-debug
    ports:
      - "5900:5900"
