Configuration
This document provides comprehensive information about configuring the ManufactAI Factory application through environment variables. Proper configuration is critical for system functionality.
Configuration Overview
ManufactAI Factory is configured primarily through environment variables that are passed to the Docker containers. These environment variables control all aspects of the application's behavior, from database connections to authentication methods.
Environment Variables Reference
Core Application Parameters
Parameter | Description | Default | Required | Effect |
---|---|---|---|---|
PORT | Port the API server listens on | 8080 | Yes | Changes the port where the API service runs |
APP_URL | Public URL of the frontend application | None | Yes | Used for generating links in emails and redirects |
Database Configuration
Parameter | Description | Default | Required | Effect |
---|---|---|---|---|
DB_URI | MongoDB connection string | None | Yes | Required for connecting to the MongoDB database |
S3 Storage Configuration
Parameter | Description | Default | Required | Effect |
---|---|---|---|---|
S3_ENDPOINT_URL | URL of the S3-compatible storage service | None | Yes | Specifies the connection endpoint for S3 operations |
S3_ACCESS_KEY | Access key for S3 authentication | None | Yes | Required for authenticating with the S3 service |
S3_SECRET_KEY | Secret key for S3 authentication | None | Yes | Required for authenticating with the S3 service |
S3_BUCKET | Name of the S3 bucket to use | "factory" | Yes | Determines where files are stored in S3 |
S3_REGION | AWS region for S3 operations | "eu-central-1" | No | Required for AWS S3 services, optional for other S3-compatible services |
S3_PATH_PREFIX | Prefix for all paths in the S3 bucket | "" | No | Adds a prefix to all object keys in S3, useful for organizing data |
S3_UPLOAD_EXPIRES_IN | Expiration time for upload URLs in seconds | 3600 (1 hour) | No | Controls how long presigned upload URLs remain valid |
S3_DOWNLOAD_EXPIRES_IN | Expiration time for download URLs in seconds | 3600 (1 hour) | No | Controls how long presigned download URLs remain valid |
Security and Licensing
Parameter | Description | Default | Required | Effect |
---|---|---|---|---|
SECRET_KEY | Secret key for token generation | Generated | Yes | Used to sign JWTs and secure cookies, should be changed in production |
LICENSE_KEY | License key for the installation | None | Yes | Required for activating the software |
CORS Configuration
Parameter | Description | Default | Required | Effect |
---|---|---|---|---|
ALLOW_ORIGINS | List of allowed origins for CORS | ["*"] | No | Controls which domains can access the API |
ALLOW_METHODS | List of allowed HTTP methods for CORS | ["*"] | No | Controls which HTTP methods can be used with the API |
ALLOW_HEADERS | List of allowed HTTP headers for CORS | ["*"] | No | Controls which HTTP headers can be sent to the API |
EXPOSE_HEADERS | List of headers exposed to the client | ["X-Total-Count", etc.] | No | Controls which headers the client can read from API responses |
SMTP Email Configuration
Parameter | Description | Default | Required | Effect |
---|---|---|---|---|
SMTP_HOST | Hostname of the SMTP server | None | Yes* | Required for sending emails |
SMTP_PORT | Port of the SMTP server | 587 | Yes* | Required for connecting to the SMTP server |
SMTP_USER | Username for SMTP authentication | None | Yes* | Required for authenticating with the SMTP server |
SMTP_PASSWORD | Password for SMTP authentication | None | Yes* | Required for authenticating with the SMTP server |
SMTP_MAIL | Email address used as the sender | None | Yes* | Sets the "From" address in sent emails |
*Required if email functionality is needed (user registration, password reset, notifications)
Single Sign-On Configuration
Parameter | Description | Default | Required | Effect |
---|---|---|---|---|
SSO_ENABLED | Master switch to enable/disable SSO | false | No | When false, all SSO providers are disabled |
SSO_DISABLE_EMAIL_LOGIN | Flag to disable email/password login | false | No | When true, only SSO authentication is allowed |
For detailed SSO configuration, see the Authentication Guide.
Performance Tuning
Parameter | Description | Default | Required | Effect |
---|---|---|---|---|
GUNICORN_WORKERS | Number of worker processes | 4 | No | Determines how many parallel requests can be processed |
GUNICORN_WORKER_CONNECTIONS | Maximum number of connections per worker | 1000 | No | Limits the number of concurrent connections per worker |
GUNICORN_TIMEOUT | Worker timeout in seconds | 120 | No | Workers exceeding this time are terminated and restarted |
GUNICORN_KEEPALIVE | Keep-alive timeout in seconds | 5 | No | How long to keep idle connections open |
GUNICORN_LOG_LEVEL | Log level for Gunicorn logs | "info" | No | Controls verbosity of server logs |
GUNICORN_MAX_REQUESTS | Maximum number of requests per worker | 1000 | No | Workers are restarted after handling this many requests |
GUNICORN_MAX_REQUESTS_JITTER | Random jitter added to max requests | 50 | No | Prevents all workers from restarting simultaneously |
Configuration Best Practices
Security Recommendations
-
Use Strong Secrets
- Generate a strong random value for
SECRET_KEY
- Use complex passwords for database and S3 access
- Never use default or example credentials in production
- Generate a strong random value for
-
Restrict Access
- Configure
ALLOW_ORIGINS
to only include trusted domains - Use firewalls to restrict access to your MongoDB and S3 services
- Enable HTTPS for all external communication
- Configure
-
Regular Updates
- Keep your Factory installation up to date with the latest security patches
- Regularly rotate credentials, especially for S3 and database access
Performance Optimization
-
Worker Configuration
- Set
GUNICORN_WORKERS
to (2 × CPU cores) + 1 for optimal performance - Adjust
GUNICORN_WORKER_CONNECTIONS
based on expected concurrent users
- Set
-
Database Indexing
- Monitor database performance and adjust resources as needed
-
Resource Allocation
- Provide sufficient CPU and memory resources to the Factory containers
- Consider using dedicated hosts for MongoDB and S3 storage in high-load scenarios