We provide a configuration for running Docs in production using docker compose. This configuration is experimental, the official way to deploy Docs in production is to use k8s
- A modern version of Docker and its Compose plugin
- A domain name or subdomain (e.g., areum-hub.duckdns.org)
- UFW firewall (or similar) for securing access
- Let's Encrypt for SSL certificates
-
Clone this repository:
git clone https://github.com/VolkerFelix/docs_home_server.git cd docs
-
Set up SSL certificates using Let's Encrypt:
sudo apt install certbot sudo certbot certonly --standalone -d your-domain.com
The certificates will be stored in
/etc/letsencrypt/live/your-domain.com/
-
Configure firewall rules:
sudo ufw allow 8443/tcp # Keycloak sudo ufw allow 8444/tcp # Main application
-
Initialize the production environment:
make bootstrap-production
The SSL certificates from Let's Encrypt are automatically mounted in the containers:
-
For the main application (nginx):
- Certificates are mounted at
/etc/nginx/ssl
in the ingress container - Used in
docker/files/production/etc/nginx/conf.d/default.conf
- Certificates are mounted at
-
For Keycloak:
- Certificates are mounted at
/etc/ssl/certs
in the Keycloak container - The paths are configured in the compose file
- Certificates are mounted at
-
env.d/production/minio
:MINIO_ROOT_USER=<YOUR_MINIO_ACCESS_KEY> MINIO_ROOT_PASSWORD=<YOUR_MINIO_SECRET_KEY>
-
env.d/production/postgresql
:POSTGRES_DB=docs POSTGRES_USER=docs POSTGRES_PASSWORD=<YOUR_DB_PASSWORD>
-
env.d/production/yprovider
:Y_PROVIDER_SECRET_KEY=<YOUR_Y_PROVIDER_SECRET_KEY> Y_PROVIDER_ALLOWED_HOSTS=your-domain.com Y_PROVIDER_DEBUG=False Y_PROVIDER_REDIS_URL=redis://redis:6379/0 Y_PROVIDER_CORS_ORIGINS=https://your-domain.com:8444 COLLABORATION_LOGGING=true COLLABORATION_API_URL=https://your-domain.com:8444/collaboration/api/ COLLABORATION_SERVER_ORIGIN=https://your-domain.com:8444 COLLABORATION_SERVER_ORIGIN_ALLOWED=true COLLABORATION_SERVER_SECRET=<YOUR_COLLABORATION_SERVER_SECRET> Y_PROVIDER_API_KEY=<YOUR_Y_PROVIDER_API_KEY>
-
env.d/production/kc_postgresql
:POSTGRES_DB=keycloak POSTGRES_USER=keycloak POSTGRES_PASSWORD=<YOUR_KEYCLOAK_DB_PASSWORD>
-
env.d/production/keycloak
:KEYCLOAK_ADMIN=<YOUR_KEYCLOAK_ADMIN_USER> KEYCLOAK_ADMIN_PASSWORD=<YOUR_KEYCLOAK_ADMIN_PASSWORD> KC_DB=postgres KC_DB_URL=jdbc:postgresql://kc_postgresql:5432/keycloak KC_DB_USERNAME=keycloak KC_DB_PASSWORD=<YOUR_KEYCLOAK_DB_PASSWORD> KC_HOSTNAME=your-domain.com KC_HOSTNAME_STRICT=false KC_HOSTNAME_STRICT_HTTPS=false KC_HTTP_ENABLED=true KC_PROXY=edge
-
env.d/production/backend
: Configure all Django and OIDC settings. Important settings include:DJANGO_SECRET_KEY=<YOUR_DJANGO_SECRET_KEY> DJANGO_ALLOWED_HOSTS=localhost,127.0.0.1,your-domain.com DJANGO_DATABASE_URL=postgres://docs:<YOUR_DB_PASSWORD>@postgresql:5432/docs DJANGO_MEDIA_ACCESS_KEY=<YOUR_MINIO_ACCESS_KEY> DJANGO_MEDIA_SECRET_KEY=<YOUR_MINIO_SECRET_KEY>
For all placeholder values (marked with <YOUR_*>
), generate secure random keys:
# Generate a secure random key
openssl rand -base64 32
-
Start the services:
make deploy
-
Access Keycloak admin interface at
https://your-domain.com:8443
- Log in with the admin credentials set in
env.d/production/keycloak
- Log in with the admin credentials set in
-
Create a new client:
- Go to "Clients" → "Create"
- Set Client ID to "docs"
- Enable "Client authentication"
- Set Valid redirect URIs to
https://your-domain.com:8444/*
- Save the client
-
Get the client secret:
- Go to the "Credentials" tab of your client
- Copy the client secret
- Update
OIDC_RP_CLIENT_SECRET
inenv.d/production/backend
-
Configure user attributes:
- In the realm settings, go to "Client Scopes" → "roles" → "Mappers"
- Add mappers for "given_name" and "usual_name"
-
Restart the services:
make clean-production make deploy
-
Start all services:
make deploy
-
Monitor the services:
COMPOSE_FILE=compose.production.yaml ./bin/compose ps
-
Access the application:
- Main application:
https://your-domain.com:8444
- Keycloak admin:
https://your-domain.com:8443
- Main application:
Important directories to backup:
data/production/databases/backend/
- Contains the main application databasedata/production/databases/keycloak/
- Contains the Keycloak databasedata/production/media/
- Contains uploaded files and mediaenv.d/production/
- Contains all configuration files/etc/letsencrypt/
- Contains SSL certificates
-
Check logs for specific services:
COMPOSE_FILE=compose.production.yaml ./bin/compose logs -f service_name
-
Common issues:
- If user collaboration doesn't work, check Y-provider logs and CORS settings
- If authentication fails, verify Keycloak client settings and secrets
- For SSL issues, ensure certificates are properly mounted and configured