Environment File Setup
Environment Variables (.env)
SMOCS uses a combination of environment variables (.env file) and YAML configuration (config.yaml) to manage system settings. This separation keeps sensitive credentials separate from application logic. This section will go through the environment file required for confidential information you do not want to publish and share.
Quick Setup
Create your .env file from the example:
cd SMOCS/orchestration
nano .env
Complete Environment Variable Reference
InfluxDB Configuration
# InfluxDB Authentication Token
# SECURITY: Change this in production!
INFLUXDB_TOKEN=my-super-secret-auth-token
# InfluxDB Organization Name
INFLUXDB_ORG=myorg
# InfluxDB Bucket for storing metrics
INFLUXDB_BUCKET=kafka_data
Purpose: These variables configure the InfluxDB time-series database for storing metrics, training results, and system telemetry.
Kafka Configuration
# Kafka Broker URL (internal Docker network)
KAFKA_BROKER_URL=kafka-broker:9092
Purpose: Specifies the Kafka broker address. Uses Docker service name for internal container communication.
MySQL/Database Configuration
# MySQL Host (Docker service name or IP)
MYSQL_HOST=localhost
# MySQL Port
MYSQL_PORT=3306
# MySQL User
MYSQL_USER=root
# MySQL Root Password
# Change this in production!
MYSQL_ROOT_PASSWORD=your_secure_password_here
# MySQL Database Name
MYSQL_DATABASE=agentdb
Purpose: Database credentials for agent data storage (sensor data, predictions, replay buffer).
Agent-Specific Ports: Each agent runs its own MySQL instance:
autoencoder-agent1: Port 3307autoencoder-agent2: Port 3305rl-control-agent1: Port 3308
MQTT Producer Configuration
# MQTT Broker Address
MQTT_BROKER=mqtt.example.com
# MQTT Broker Port (1883 = standard, 8883 = SSL)
MQTT_PORT=1883
# MQTT Authentication
MQTT_USERNAME=your_mqtt_user
MQTT_PASSWORD=your_mqtt_password
Purpose: Credentials for connecting to external MQTT brokers for data ingestion.
Required When: Using the mqtt-kafka-producer with --profile mqtt
EPICS Producer Configuration
# EPICS Channel Access Address List
EPICS_CA_ADDR_LIST=IP ADDRESS
# EPICS Channel Access Auto Address List
EPICS_CA_AUTO_ADDR_LIST=NO
Purpose: Network configuration for EPICS Channel Access protocol.
Required When: Using the epics-kafka-producer with --profile epics
Configuration Tips:
EPICS_CA_ADDR_LIST: Broadcast address or specific IOC addresses- Set
EPICS_CA_AUTO_ADDR_LIST=YESfor automatic discovery - Multiple addresses: Space-separated list
Docker Compose Profiles
# Active Docker Compose Profiles
COMPOSE_PROFILES=gymnasium,rl1
Purpose: Controls which services start with docker compose up.
Available Profiles:
gymnasium: Gymnasium environment controllerautoencoder1: First autoencoder anomaly detection agentautoencoder2: Second autoencoder agent (for EPICS data)rl1: First RL control agentmqtt: MQTT-to-Kafka producerepics: EPICS-to-Kafka producerui: Kafka UI for debugging
Profile Combinations:
# RL training only
COMPOSE_PROFILES=gymnasium,rl1
# Anomaly detection only
COMPOSE_PROFILES=autoencoder1
# Both RL and anomaly detection
COMPOSE_PROFILES=gymnasium,rl1,autoencoder1
# Full stack with UI
COMPOSE_PROFILES=gymnasium,rl1,autoencoder1,ui