Skip to main content

Overview

Web Scraping Hub uses environment variables to configure runtime behavior, especially in Docker and production deployments. This allows you to customize settings without modifying the source code.

Environment Variables Reference

Docker Environment Variables

When deploying with Docker, the following environment variables are available:
PGID
integer
default:"1000"
Process Group ID for the container. Used for file permissions.
environment:
  - PGID=1000
PUID
integer
default:"1000"
Process User ID for the container. Used for file permissions.
environment:
  - PUID=1000
TZ
string
default:"America/Bogota"
Timezone for the container. Affects logging timestamps and scheduled tasks.
environment:
  - TZ=America/Bogota
Common values:
  • America/New_York
  • Europe/London
  • Asia/Tokyo
  • UTC

Flask Environment Variables

FLASK_ENV
string
default:"production"
Flask environment mode. Controls various Flask behaviors.
environment:
  - FLASK_ENV=production
Options:
  • production - Production mode (recommended for deployment)
  • development - Development mode with hot reload
FLASK_DEBUG
boolean
default:"false"
Enable or disable Flask debug mode.
environment:
  - FLASK_DEBUG=false
Never set FLASK_DEBUG=true in production. It exposes sensitive information and enables the interactive debugger.

Docker Compose Configuration

The complete environment configuration in docker-compose.yml:
services:
  anxerstudios-streaming:
    image: zlosttk/anxerstudios-streaming:latest
    container_name: anxerstudios-streaming
    
    environment:
      - PGID=1000
      - PUID=1000
      - TZ=America/Bogota
      - FLASK_ENV=production
      - FLASK_DEBUG=false
    
    ports:
      - "1234:1234"
    
    volumes:
      - /DATA/AppData/anxerstudios-streaming/app/config:/app/config
      - /DATA/AppData/anxerstudios-streaming/logs:/app/logs

Resource Limits

CPU Configuration

cpu_shares
integer
default:"90"
Relative weight for CPU allocation. Higher values get more CPU time.
cpu_shares: 90

Memory Configuration

memory
string
default:"3369M"
Maximum memory allocation for the container.
deploy:
  resources:
    limits:
      memory: 3369M
Adjust this based on your server’s available resources. For lighter loads, 1GB may be sufficient.

Volume Mounts

Persistent data is stored in mounted volumes:

Configuration Volume

volumes:
  - /DATA/AppData/anxerstudios-streaming/app/config:/app/config
Stores persistent configuration files that survive container restarts.

Logs Volume

volumes:
  - /DATA/AppData/anxerstudios-streaming/logs:/app/logs
Stores application logs for debugging and monitoring.
Change the host paths to match your system’s directory structure. For example:
- /home/user/streaming/config:/app/config
- /home/user/streaming/logs:/app/logs

Health Check Configuration

The container includes health checks to ensure the service is running:
healthcheck:
  test: ["CMD-SHELL", "curl -f http://localhost:1234/api/secciones || exit 1"]
  interval: 30s
  timeout: 10s
  retries: 3
  start_period: 40s
test
array
Command to run for health checking. Tests if the API is responding.
interval
string
default:"30s"
Time between health checks.
timeout
string
default:"10s"
Maximum time to wait for health check response.
retries
integer
default:"3"
Number of consecutive failures before marking as unhealthy.
start_period
string
default:"40s"
Grace period before starting health checks (allows for startup time).

Network Configuration

Port Mapping

ports:
  - "1234:1234"
Maps host port 1234 to container port 1234. Change the first number to use a different host port:
ports:
  - "8080:1234"  # Access on http://localhost:8080

Custom Network

networks:
  - anxerstudios-streaming

networks:
  anxerstudios-streaming:
    name: anxerstudios-streaming
    driver: bridge
Creates an isolated bridge network for the container.

Development Environment

For local development without Docker:

Python Virtual Environment

cd backend
python3 -m venv .venv
source .venv/bin/activate  # Linux/Mac
# or
.venv\Scripts\activate  # Windows

Install Dependencies

pip install -r requirements.txt
Required packages:
  • flask - Web framework
  • flask-cors - CORS support
  • beautifulsoup4 - HTML parsing
  • adblockparser - Ad blocking
  • cloudscraper - Cloudflare bypass
  • pytest - Testing framework

Run Development Server

python -m backend.app
The server will start with debug mode enabled by default in app.py:
if __name__ == '__main__':
    app.run(debug=True, host='0.0.0.0', port="1234")

Production Environment

Docker Deployment

For production deployment, use the provided Docker configuration:
cd docker
docker-compose up -d

Environment File

Create a .env file for easier environment management:
# .env
PGID=1000
PUID=1000
TZ=America/New_York
FLASK_ENV=production
FLASK_DEBUG=false
CONTAINER_PORT=1234
HOST_PORT=1234
Then reference it in docker-compose.yml:
services:
  anxerstudios-streaming:
    env_file: .env
    ports:
      - "${HOST_PORT}:${CONTAINER_PORT}"

CasaOS Configuration

Special configuration for CasaOS deployment:
x-casaos:
  author: ZLostTK
  category: Entertainment
  hostname: linuxlite.local
  icon: https://icon.casaos.io/main/all/anxerstudios-streaming.png
  index: /
  port_map: "1234"
  scheme: http
  store_app_id: anxerstudios-streaming
  title:
    custom: "AnxerStudios Streaming"
    en_us: "AnxerStudios Streaming"
CasaOS uses these metadata fields to properly display and configure the application in its UI.

Environment-Specific Configuration

Development

environment:
  - FLASK_ENV=development
  - FLASK_DEBUG=true
  - TZ=UTC

Staging

environment:
  - FLASK_ENV=production
  - FLASK_DEBUG=false
  - TZ=America/New_York
  - LOG_LEVEL=INFO

Production

environment:
  - FLASK_ENV=production
  - FLASK_DEBUG=false
  - TZ=America/Bogota
  - LOG_LEVEL=WARNING

Troubleshooting

  • Check if port 1234 is already in use
  • Verify volume paths exist and are accessible
  • Check Docker logs: docker logs anxerstudios-streaming
  • Ensure required dependencies are installed in the image
  • Verify PUID and PGID match your user
  • Check volume mount permissions
  • Run: docker exec anxerstudios-streaming id to verify user
  • Verify the container has fully started (wait for start_period)
  • Check if port 1234 is accessible inside container
  • Test manually: docker exec anxerstudios-streaming curl localhost:1234/api/secciones
  • Review Flask logs for errors
  • Verify TZ environment variable is set correctly
  • Restart the container after changing timezone
  • Check timezone inside container: docker exec anxerstudios-streaming date

Environment Variables Best Practices

1

Use .env Files

Keep environment variables in .env files for easier management and keep them out of version control.
2

Secure Sensitive Data

Never commit sensitive environment variables to version control. Use .gitignore to exclude .env files.
3

Document All Variables

Provide an .env.example file with all required variables (without sensitive values).
4

Validate on Startup

Implement startup checks to ensure required environment variables are set.

Backend Configuration

Configure the Flask backend server

Docker Deployment

Deploy with Docker and Docker Compose

Build docs developers (and LLMs) love