Configuration#
NexusLIMS-CDCS is configured through environment variables defined in a .env file. This guide documents all available configuration options.
Configuration Files#
File |
Purpose |
|---|---|
|
Development defaults (tracked in git) |
|
Production template (tracked in git) |
|
Active configuration (gitignored, copy from template) |
Setup:
Development:
cp .env.dev .envProduction:
cp .env.prod.example .envand customize
Warning
Never commit .env to version control - it contains secrets!
Environment Variables Reference#
Project Identification#
Variable |
Description |
Dev Default |
Prod Example |
|---|---|---|---|
|
Docker Compose project name |
|
|
|
Docker image version tag |
|
|
Domain Configuration#
Variable |
Description |
Dev Default |
Prod Example |
|---|---|---|---|
|
Main application domain |
|
|
|
File server domain |
|
|
|
Full server URL (derived) |
|
|
|
Django allowed hosts |
|
|
|
Django CSRF trusted origins |
|
|
Django Configuration#
Variable |
Description |
Dev Default |
Prod Example |
|---|---|---|---|
|
Settings module path |
|
|
|
Secret key for crypto operations |
(dev key) |
Generate unique key! |
|
Enable debug mode |
|
|
Generate a secret key:
python3 -c "from secrets import token_urlsafe; print(token_urlsafe(50))"
Database Configuration#
Variable |
Description |
Dev Default |
Prod Example |
|---|---|---|---|
|
PostgreSQL version |
|
|
|
Database name |
|
|
|
Database user |
|
|
|
Database password |
(dev password) |
Generate unique password! |
|
Database hostname |
|
|
|
Internal port |
|
|
|
Host-exposed port |
|
|
Generate a password:
python3 -c "from secrets import token_urlsafe; print(token_urlsafe(32))"
Redis Configuration#
Variable |
Description |
Dev Default |
Prod Example |
|---|---|---|---|
|
Redis version |
|
|
|
Redis password |
(dev password) |
Generate unique password! |
|
Redis hostname |
|
|
|
Internal port |
|
|
|
Host-exposed port |
|
|
Caddy Configuration#
Variable |
Description |
Dev Default |
Prod Example |
|---|---|---|---|
|
Caddyfile to use |
|
|
|
Email for Let’s Encrypt |
- |
|
|
Path to manual certificates |
- |
|
File Serving Configuration#
Variable |
Description |
Dev Default |
Prod Example |
|---|---|---|---|
|
Container path for preview data |
|
|
|
Container path for instrument data |
|
|
|
Host path for preview data |
|
|
|
Host path for instrument data |
|
|
XSLT Configuration#
Variable |
Description |
Dev Default |
Prod Example |
|---|---|---|---|
|
Base URL for instrument data links |
|
|
|
Base URL for preview image links |
|
|
These URLs are patched into XSLT stylesheets when they’re uploaded to the database.
Backup Configuration#
Variable |
Description |
Dev Default |
Prod Example |
|---|---|---|---|
|
Timezone for backup timestamps |
|
|
|
Host path for backups |
- |
|
Gunicorn Configuration (Production Only)#
Variable |
Description |
Default |
Notes |
|---|---|---|---|
|
Number of worker processes |
|
2-4 × CPU cores |
|
Threads per worker |
|
2-4 typical |
|
Request timeout (seconds) |
|
Increase for long operations |
Recommended configurations:
Server Size |
Cores |
RAM |
Workers |
Threads |
|---|---|---|---|---|
Small |
2-4 |
4-8 GB |
4 |
2 |
Medium |
4-8 |
8-16 GB |
8 |
2 |
Large |
8+ |
16+ GB |
12 |
4 |
Development vs Production#
Key differences between development and production configurations:
Aspect |
Development |
Production |
|---|---|---|
Debug mode |
Enabled ( |
Disabled ( |
Web server |
Django runserver |
Gunicorn |
Certificates |
Local CA (self-signed) |
Let’s Encrypt (ACME) |
Domains |
|
Real domains |
File paths |
Test data directory |
Network storage mounts |
Passwords |
Simple defaults |
Strong generated passwords |
Code mounting |
Yes (hot reload) |
No (built into image) |
XSLT URL Configuration#
XSLT stylesheets contain URLs for linking to instrument data and preview images. These URLs must match your deployment:
%%{init: {'theme': 'base'}}%%
flowchart LR
subgraph XSLT["XSLT Stylesheet"]
DatasetURL["datasetBaseUrl"]
PreviewURL["previewBaseUrl"]
end
subgraph ENV["Environment Variables"]
XSLT_DATASET_BASE_URL
XSLT_PREVIEW_BASE_URL
end
subgraph Caddy["Caddy File Server"]
InstrumentData["/instrument-data/"]
PreviewData["/data/"]
end
XSLT_DATASET_BASE_URL --> DatasetURL
XSLT_PREVIEW_BASE_URL --> PreviewURL
DatasetURL -->|links to| InstrumentData
PreviewURL -->|links to| PreviewData
Update Process#
When you run dev-update-xslt or admin-init, the scripts:
Read the XSL file from
xslt/Replace placeholder URLs with values from environment variables
Upload the patched stylesheet to the database
Manual URL Patching#
If you need to update URLs manually:
# Inside CDCS container
python manage.py shell
from core_main_app.components.xsl_transformation.models import XslTransformation
# Get stylesheet
xslt = XslTransformation.objects.get(name="detail_stylesheet.xsl")
# Update content
xslt.content = xslt.content.replace(
"https://old-url.com/data",
"https://new-url.com/data"
)
xslt.save()
Optional Integrations#
SAML2 Authentication#
SAML2 configuration is stored in deployment/saml2/.env. Consult the MDCS documentation for SAML2 setup.
Handle System#
Handle system configuration is stored in deployment/handle/.env. This enables persistent identifiers for records.
Custom Settings#
For advanced customization, create a custom settings module:
Create
config/settings/custom_settings.pyImport from
prod_settings.pyand override as neededSet
DJANGO_SETTINGS_MODULE=config.settings.custom_settings
Troubleshooting Configuration#
Environment Not Loading#
Verify .env file exists and is readable:
ls -la .env
cat .env | head -20
Variables Not Applied#
Docker Compose caches environment. Force reload:
dc-prod down
dc-prod up -d
XSLT URLs Not Updating#
XSLT stylesheets must be re-uploaded after changing URL variables:
dev-update-xslt # Development
# or
admin-init # Production (re-runs full initialization)
Secret Key Errors#
If Django complains about the secret key:
Ensure
DJANGO_SECRET_KEYis setKey must be at least 50 characters
Don’t use special characters that need escaping
Next Steps#
Production Deployment - Apply configuration for production deployment
Administration - Manage backups and updates
Development Setup - Set up local development environment