Skip to content

Latest commit

 

History

History
71 lines (63 loc) · 2.65 KB

How_to_Docker_Compose.md

File metadata and controls

71 lines (63 loc) · 2.65 KB

How to Docker

Requirements

In order to run InstaPy under this setup, is needed to have installed docker and docker-compose

Directory structure

Create a folder called z_{user} in repo root directory, where {user} is your instagram user. Since under this folder we will store sensible data, starting the name with z_ avoids it to be published on GitHub. The configuration is based on 3 files start.py, docker-compose.yaml and data.yaml.

Docker compose

  • Will wait for Selenium to be ready, then execute start.py
  • Uses local files logs, data.yaml configuration file and start.py script.

docker-compose.yaml

version: '3'
services:
  web:
    command: ["./wait-for-selenium.sh", "http://selenium:4444/wd/hub", "--", "python", "start.py"]
    environment:
      - PYTHONUNBUFFERED=0
    build:
      context: ../
      dockerfile: docker_conf/python/Dockerfile
    depends_on:
      - selenium
    volumes:
      - ./start.py:/code/start.py
      - ./data.yaml:/code/data.yaml
      - ./logs:/code/logs
  selenium:
    image: selenium/standalone-chrome
    shm_size: 128M

Data file

What it stores in the example Friends last post likes and interact with user based on hashtags:

  • Our credentials
  • A protected friend list which we want to keep after any acction from InstaPy
  • A list of hashtags that we whant to interact with
  • Control Flow

data.yaml

username: string
password: string
friends_interaction: boolean
do_comments: boolean
do_follow: boolean
user_interact: boolean
do_unfollow: boolean
friendlist: [list]
hashtags: [list]
  • username: Instagram Username
  • password: Instagram Password
  • friends_interaction: If True will like last two post from friendlist, if not, it won't even create friends session
  • do_comments: If True will enable comments in like_by_tags interaction
  • do_follow: If True will enable follow users in like_by_tags interaction
  • user_interact: If True will enable interact with user's posts in like_by_tags interaction
  • do_unfollow: If True will enable unfollow execution

Script

You can check this example to run the script using data.yaml file and specific config for running in docker.

How to run

Inside z_{user} directory:

  • run in background: docker-compose down && docker-compose up -d --build
  • run with log in terminal: docker-compose down && docker-compose up -d --build && docker-compose logs -f