Skip to main content
Docker deployment provides an isolated, reproducible environment for running Social Analyzer. The docker-compose setup includes Selenium Grid integration for advanced detection modes and parallel processing.

Prerequisites

1

Install Docker

Install Docker Engine on your system:
# Ubuntu/Debian
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
2

Install Docker Compose

Install Docker Compose:
sudo apt-get install docker-compose
3

Clone repository

git clone https://github.com/qeeqbox/social-analyzer.git
cd social-analyzer

Quick Start

Simple Docker Run

Run Social Analyzer as a single container:
docker build -t social-analyzer .
docker run -p 9005:9005 social-analyzer
Access the web interface at:
http://localhost:9005/app.html
Use docker-compose for the complete setup with Selenium Grid:
docker-compose up
This starts:
  • Social Analyzer web application
  • Selenium Hub (port 4444)
  • Firefox node for browser automation

Docker Compose Configuration

The docker-compose.yml file defines a multi-container setup:
version: "3" 
services:
  social-analyzer:
    build: .
    ports:
      - "9005:9005"
    depends_on:
      - hub
    links:
      - hub
    entrypoint: npm start -- --docker --grid "http://hub:4444/wd/hub"
    
  hub:
    image: selenium/hub
    ports:
      - "4444:4444"
    environment:
      GRID_MAX_SESSION: 16
      GRID_BROWSER_TIMEOUT: 6000
      GRID_TIMEOUT: 6000
      
  firefox:
    image: selenium/node-firefox
    container_name: web-automation_firefox
    depends_on:
      - hub
    environment:
      SE_EVENT_BUS_HOST: hub
      SE_EVENT_BUS_PUBLISH_PORT: 4442
      SE_EVENT_BUS_SUBSCRIBE_PORT: 4443
      SE_NODE_MAX_SESSIONS: ${CPU_CORES:-2}
    volumes:
      - /dev/shm:/dev/shm
    ports:
      - "9002:5900"
    links:
      - hub

Architecture Overview

The Docker Compose setup consists of three services:
Main application container
  • Runs the Node.js web server
  • Serves the web interface on port 9005
  • Connects to Selenium Hub for browser automation
  • Handles detection and analysis logic

Starting the Services

Start in foreground

docker-compose up
Watch logs in real-time and stop with Ctrl+C.

Start in background

docker-compose up -d
Runs containers in detached mode.

Build and start

docker-compose up --build
Rebuilds images before starting (use after code changes).

Managing Containers

View running containers

docker-compose ps
Shows status of all services:
              Name                            Command               State           Ports         
-------------------------------------------------------------------------------------------------
social-analyzer_hub_1              /opt/bin/entry_point.sh          Up      0.0.0.0:4444->4444/tcp
social-analyzer_social-analyzer_1  docker-entrypoint.sh npm ...    Up      0.0.0.0:9005->9005/tcp
web-automation_firefox             /opt/bin/entry_point.sh          Up      0.0.0.0:9002->5900/tcp

View logs

docker-compose logs -f

Stop services

docker-compose stop
Stops containers without removing them.

Stop and remove

docker-compose down
Stops and removes all containers, networks, and volumes.

Restart services

docker-compose restart
Restarts all services.

Configuration Options

Environment Variables

Customize behavior with environment variables:
CPU_CORES=4 docker-compose up

Available Variables

VariableDescriptionDefault
CPU_CORESFirefox node max sessions2
PORTSocial Analyzer web port9005
GRID_MAX_SESSIONHub max sessions16
GRID_BROWSER_TIMEOUTBrowser timeout (ms)6000
GRID_TIMEOUTGrid timeout (ms)6000

Custom docker-compose.yml

Create a custom configuration:
version: "3"
services:
  social-analyzer:
    build: .
    ports:
      - "8080:9005"  # Custom external port
    environment:
      - NODE_ENV=production
    depends_on:
      - hub
    links:
      - hub
    entrypoint: npm start -- --docker --grid "http://hub:4444/wd/hub"
  
  hub:
    image: selenium/hub:latest
    ports:
      - "4444:4444"
    environment:
      GRID_MAX_SESSION: 32  # Increased capacity
      GRID_BROWSER_TIMEOUT: 10000
      GRID_TIMEOUT: 10000
  
  firefox:
    image: selenium/node-firefox:latest
    deploy:
      replicas: 3  # Multiple Firefox nodes
    environment:
      SE_EVENT_BUS_HOST: hub
      SE_EVENT_BUS_PUBLISH_PORT: 4442
      SE_EVENT_BUS_SUBSCRIBE_PORT: 4443
      SE_NODE_MAX_SESSIONS: 4
    volumes:
      - /dev/shm:/dev/shm
    shm_size: 2gb  # Increased shared memory

Selenium Grid Integration

Grid URL

The application automatically uses the grid when started with docker-compose:
http://hub:4444/wd/hub

Benefits of Grid Mode

  • Parallel Processing: Multiple browser instances run simultaneously
  • Better Performance: Faster execution for advanced detection modes
  • Isolation: Browser processes isolated from main application
  • Scalability: Add more browser nodes as needed

Accessing Grid Console

View the Selenium Grid status page:
http://localhost:4444/grid/console
Shows:
  • Available browser nodes
  • Active sessions
  • Browser versions
  • Node status

VNC Access to Browser

Connect to the Firefox container via VNC for debugging:
vnc://localhost:9002
Default VNC password: secret Watch the browser in real-time as Social Analyzer performs checks.

Scaling Browser Nodes

Add more Firefox nodes

docker-compose up --scale firefox=5
Starts 5 Firefox nodes for increased parallelism.

Add Chrome nodes

Modify docker-compose.yml to include Chrome:
chrome:
  image: selenium/node-chrome
  depends_on:
    - hub
  environment:
    SE_EVENT_BUS_HOST: hub
    SE_EVENT_BUS_PUBLISH_PORT: 4442
    SE_EVENT_BUS_SUBSCRIBE_PORT: 4443
    SE_NODE_MAX_SESSIONS: 2
  volumes:
    - /dev/shm:/dev/shm
  links:
    - hub
Then start:
docker-compose up

Using the Dockerized Application

Once running, access the web interface:

Web Interface

http://localhost:9005/app.html
Use normally - the grid option is automatically enabled.

CLI in Container

Execute CLI commands inside the container:
docker exec -it social-analyzer_social-analyzer_1 node app.js --username "johndoe"

Python CLI in Container

If you’ve built a container with Python support:
docker exec -it social-analyzer_social-analyzer_1 python3 app.py --username "johndoe"

Data Persistence

Volume Mounting

Mount a local directory to persist logs:
social-analyzer:
  build: .
  ports:
    - "9005:9005"
  volumes:
    - ./logs:/app/logs  # Persist logs
    - ./data:/app/data  # Persist data files
Then:
mkdir logs data
docker-compose up

Export Results

Copy results from container:
docker cp social-analyzer_social-analyzer_1:/app/logs ./local-logs

Performance Optimization

Increase Shared Memory

Browser containers need adequate shared memory:
firefox:
  image: selenium/node-firefox
  shm_size: 2gb  # Increase from default

Resource Limits

Set CPU and memory limits:
firefox:
  image: selenium/node-firefox
  deploy:
    resources:
      limits:
        cpus: '2'
        memory: 2G
      reservations:
        cpus: '1'
        memory: 1G

Network Optimization

Use a custom network for better isolation:
networks:
  social-analyzer-net:
    driver: bridge

services:
  social-analyzer:
    networks:
      - social-analyzer-net
  hub:
    networks:
      - social-analyzer-net
  firefox:
    networks:
      - social-analyzer-net

Troubleshooting

Containers won’t start

Check if ports are already in use:
sudo lsof -i :9005
sudo lsof -i :4444
Kill conflicting processes or change ports.

Hub connection failed

Verify hub is running:
docker-compose ps hub
Test hub endpoint:
curl http://localhost:4444/status

Firefox node not connecting

Check Firefox logs:
docker-compose logs firefox
Restart the Firefox service:
docker-compose restart firefox

Out of memory errors

Increase Docker memory allocation in Docker Desktop settings or for Docker daemon:
sudo nano /etc/docker/daemon.json
{
  "default-shm-size": "2gb"
}

Slow performance

  • Reduce GRID_MAX_SESSION to lower concurrent load
  • Increase CPU_CORES if your system has capacity
  • Scale down Firefox nodes if over-subscribed
  • Check host system resources (CPU, memory, disk I/O)

Production Deployment

Do not expose Social Analyzer to the public internet without proper security measures. It lacks built-in authentication and access control.
  1. Reverse Proxy: Use nginx or Apache with authentication
  2. VPN: Restrict access via VPN
  3. Firewall: Only allow specific IP addresses
  4. HTTPS: Use TLS/SSL certificates
  5. Secrets: Use Docker secrets for API keys

Example nginx Configuration

server {
    listen 443 ssl;
    server_name social-analyzer.local;
    
    ssl_certificate /etc/ssl/certs/cert.pem;
    ssl_certificate_key /etc/ssl/private/key.pem;
    
    auth_basic "Restricted Access";
    auth_basic_user_file /etc/nginx/.htpasswd;
    
    location / {
        proxy_pass http://localhost:9005;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
    }
}

Maintenance

Update Images

docker-compose pull
docker-compose up -d

Clean Up

# Remove stopped containers
docker-compose down

# Remove all data
docker-compose down -v

# Remove images
docker-compose down --rmi all

Health Checks

Add health checks to services:
social-analyzer:
  build: .
  healthcheck:
    test: ["CMD", "curl", "-f", "http://localhost:9005/app.html"]
    interval: 30s
    timeout: 10s
    retries: 3

Build docs developers (and LLMs) love