Storage Configuration
Configure storage providers via environment variables
This application uses a dynamic storage configuration that allows you to configure different storage providers via environment variables, without relying on Rails' default storage.yml file.
How It Works
Storage configurations are defined dynamically in config/application.rb using the ACTIVE_STORAGE_CONFIG environment variable. When this environment variable is set, it should contain a Base64-encoded JSON configuration for your storage provider.
Configuration Examples
Local Storage (Default)
If no ACTIVE_STORAGE_CONFIG is provided, the application defaults to local disk storage in the storage/ directory.
MinIO Configuration
For MinIO (S3-compatible storage), create a JSON configuration and encode it as Base64:
{
"service": "S3",
"access_key_id": "minioadmin",
"secret_access_key": "minioadmin",
"region": "us-east-1",
"bucket": "mitigate-chatbot-production-uploads",
"endpoint": "http://localhost:9000",
"force_path_style": true
}To encode this for the environment variable:
echo '{"service":"S3","access_key_id":"minioadmin","secret_access_key":"minioadmin","region": "us-east-1","bucket":"mitigate-chatbot-production-uploads","endpoint":"http://localhost:9000","force_path_style":true}' | base64Set the environment variable:
ACTIVE_STORAGE_CONFIG=eyJzZXJ2aWNlIjoiUzMiLCJhY2Nlc3Nfa2V5X2lkIjoibWluaW9hZG1pbiIsInNlY3JldF9hY2Nlc3Nfa2V5IjoibWluaW9hZG1pbiIsInJlZ2lvbiI6InVzLWVhc3QtMSIsImJ1Y2tldCI6Im1pdGlnYXRlLWNoYXRib3QtZGV2ZWxvcG1lbnQtdXBsb2FkcyIsImVuZHBvaW50IjoiaHR0cDovL2xvY2FsaG9zdDo5MDAwIiwiZm9yY2VfcGF0aF9zdHlsZSI6dHJ1ZX0=AWS S3 Configuration
For production AWS S3:
{
"service": "S3",
"access_key_id": "YOUR_ACCESS_KEY",
"secret_access_key": "YOUR_SECRET_KEY",
"region": "eu-central-1",
"bucket": "mitigate-chatbot-production-uploads"
}Note: For AWS S3, you don't need to specify endpoint or force_path_style.
Other S3-Compatible Providers
The configuration works with any S3-compatible storage provider. Simply adjust the endpoint and credentials accordingly.