Codumentor logo Codumentor Enterprise

Production Deployment

This guide covers deploying Codumentor in a production environment, including reverse proxy configuration, service management, data management, and operational best practices.

Docker Image

The deployment image is built from the same backend Dockerfile as the development container, but with a different target. Development uses target: dev through docker-compose.dev.yml; production uses the runtime target, which builds the UI and Linux executable in intermediate stages and copies only the executable into the final image.

docker build -f deploy/Dockerfile.backend --target runtime -t codumentor:latest .

Run it with your config, API keys, and persistent data mounted from outside the image:

docker run --rm \
  --name codumentor \
  -p 127.0.0.1:2638:2638 \
  --ulimit nofile=65536:65536 \
  --env-file .env \
  -v "$(pwd)/codumentor.yaml:/app/codumentor.yaml:ro" \
  -v codumentor-data:/app/data \
  -v codumentor-logs:/app/logs \
  -v codumentor-repos:/app/repos \
  codumentor:latest

For Docker deployments, prefer absolute in-container paths in codumentor.yaml:

repos_dir: /app/repos

vector_db:
  path: /app/data/vector_db

agent:
  storage_dir: /app/data/agent_storage

logging:
  file: /app/logs/codumentor.log

Keep repos_dir out of the instance's own files: /app/repos, not /app
or ., and never a folder that holds codumentor.yaml, data/ or logs/.
Where it does (root or project-dir installs), Codumentor refuses those paths to
every agent tool and file view, and hides them from them; see
repos_dir. Keeping them apart is still the
safer layout.

--ulimit nofile=65536:65536 meets the open file limit
requirement. In Compose, set ulimits: { nofile: { soft: 65536, hard: 65536 } }.

The image runs as the non-root codumentor user, exposes port 2638, and defaults to:

/app/codumentor -c /app/codumentor.yaml api --host 0.0.0.0 --port 2638

Because that bind is reachable, the mounted /app/codumentor.yaml must configure an auth provider — the container refuses to start with auth.provider: "none" on 0.0.0.0. If the container network is your boundary and you accept an unauthenticated instance inside it, say so explicitly with auth.allow_unauthenticated_network_access: true. See Authentication.

For private Git repositories, mount SSH credentials or deploy keys as read-only files under /home/codumentor/.ssh.

Reverse Proxy

Codumentor should run behind a reverse proxy in production. Non-container deployments bind to 127.0.0.1:2638 by default. The Docker image binds to 0.0.0.0 inside the container, so keep the published port loopback-only unless another network boundary already protects it.

nginx Example

server {
    listen 443 ssl;
    server_name codumentor.example.com;

    ssl_certificate     /etc/ssl/certs/codumentor.pem;
    ssl_certificate_key /etc/ssl/private/codumentor.key;

    location / {
        proxy_pass http://127.0.0.1:2638;

        # Required for Server-Sent Events (SSE) streaming
        proxy_set_header X-Accel-Buffering no;
        proxy_set_header Connection keep-alive;
        proxy_buffering off;

        # Standard proxy headers
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;

        # Timeout for long-running agent conversations
        proxy_read_timeout 300s;
        proxy_send_timeout 300s;

        # Request body limit (nginx's default is 1m). File attachments and
        # attached-folder copies are sent in chunks that adapt to a lower
        # limit, but larger chunks are faster.
        client_max_body_size 16m;
    }
}

The SSE headers (X-Accel-Buffering: no, Connection: keep-alive, and proxy_buffering off) are essential. Without them, nginx buffers streaming responses and the web UI will not receive real-time updates.

Use a valid, CA-signed certificate — not a self-signed one. The browser's File System Access API (used by the Attach Local Folder feature, see Web UI) is only exposed in a secure context. A self-signed or otherwise invalid certificate does not qualify as a secure context, even if users click through the browser's certificate warning. In that situation the browser loads the page but the File System Access API is unavailable, so attaching a local folder silently fails. If you need a locally-issued certificate, distribute your internal CA to the client machines so the certificate chain validates, or use a public CA (e.g. Let's Encrypt).

Open file limit (required)

The server process needs an RLIMIT_NOFILE (open files) of at least
65536. Lower limits are not supported.

Codumentor keeps many descriptors open for as long as a conversation is active:
SQLite databases per conversation, streaming client connections, MCP and LLM
connections, and the namespace handles of each sandboxed workspace. Most Linux
distributions and systemd start services with a soft limit of 1024. A busy
instance with many repositories can reach that. When it does, accepts,
database opens and sandbox spawns fail with Too many open files (EMFILE)
until the server restarts.

What the server does itself. At startup the server raises its own soft
limit to 65536. A process may do that without privileges, up to its hard
limit. The usual hard limits are well above 65536: 524288 under systemd 240+
and 1048576 under Docker. On such a host there is nothing to configure. The
startup log shows Open file limit: 65536. The server does not go higher than
65536, because sandboxed commands inherit the limit and some programs slow down
with very large limits. A higher limit you set yourself is kept.

When you must act. If the hard limit is below 65536, the server logs a
warning at startup (Open file limit is … the server needs 65536) and runs
with what it got. Raise the hard limit:

Launched bySetting
systemdLimitNOFILE=65536 in the [Service] section (see the unit file); systemctl edit codumentor for an existing unit
Docker--ulimit nofile=65536:65536, or ulimits: in Compose
A shell or scriptulimit -Hn 65536 as root, or in /etc/security/limits.conf (codumentor hard nofile 65536)

The example unit and docker run above set the limit explicitly anyway, so the
requirement stays visible in the deployment files.

The raise happens in the supervisor's child, which does
the real work. The supervisor keeps the limit it was started with. To check a
running instance, list the server's processes with their soft limit and the
number of fds they hold. The child is the one holding the most:

for pid in $(pgrep -u codumentor -f 'codumentor.* api'); do
  printf '%s  limit=%s  open=%s\n' "$pid" \
    "$(awk '/Max open files/ {print $4}' /proc/$pid/limits)" \
    "$(sudo ls /proc/$pid/fd | wc -l)"
done

On a steady workload the open count levels off. If it keeps growing, there is a
leak. Report it with the output of sudo ls -l /proc/<pid>/fd.

Systemd Service

Create a systemd unit to manage the Codumentor API server as a background service.

Service Unit File

Create /etc/systemd/system/codumentor.service:

[Unit]
Description=Codumentor API Server
After=network.target

[Service]
Type=simple
User=codumentor
Group=codumentor
WorkingDirectory=/opt/codumentor
# The stable launcher a `.run` install creates (see the self-hosting walkthrough)
ExecStart=/opt/codumentor/bin/codumentor -c /opt/codumentor/codumentor.yaml api
Restart=on-failure
RestartSec=5

# Required: at least 65536 open files. The server raises its soft limit
# itself up to the hard limit; this sets both. See "Open file limit" above.
LimitNOFILE=65536

# API keys and other secrets (KEY=value lines, mode 600, owned by codumentor);
# do not store them in config files
EnvironmentFile=/opt/codumentor/codumentor.env

# Let the server give each sandbox session its own cgroup (pids, memory,
# CPU budgets). Needs systemd 254+; without it sandbox budgets fall back to a
# weaker per-user process limit. See sandbox-resource-limits.md.
Delegate=pids memory cpu
DelegateSubgroup=server

# Security hardening
NoNewPrivileges=true
ProtectSystem=strict
ReadWritePaths=/opt/codumentor/data /opt/codumentor/logs

[Install]
WantedBy=multi-user.target

Delegate= and DelegateSubgroup= are needed whenever workspace isolation
or the light sandbox is enabled. Sandbox resource budgets
explains why. For an existing unit, add the two lines with systemctl edit
codumentor
(systemctl --user edit <unit> for a user service), then reload
and restart. Every instance's unit needs them. At startup the server logs
Sandbox resource limits: cgroup v2, … when they work, and
Sandbox resource limits: prlimit fallback, … when they don't.

Managing the Service

# Reload after creating or editing the unit file
sudo systemctl daemon-reload

# Start the service
sudo systemctl start codumentor

# Enable start on boot
sudo systemctl enable codumentor

# Check status
sudo systemctl status codumentor

# View logs
sudo journalctl -u codumentor -f

Process supervisor

Every codumentor api start runs a small stdlib supervisor as the process
you launched. Bare codumentor does the same in the community edition (default
command api); enterprise defaults to tui, so bare enterprise does not start
the supervisor. The supervisor spawns a child that does the real work
(CODUMENTOR_SUPERVISED=1). It loads no configuration.

What the service manager sees. systemd, Docker, and a double-clicked
executable all track the supervisor's PID. Stopping that process stops the
child as well (Linux PDEATHSIG, a Windows job object, or a poll on macOS).
Do not point monitoring at the child's PID alone.

Admin restart vs crash recovery. From the Admin page, Restart server…
asks the child to exit with a restart request; the supervisor starts a new
child on the same port. That path needs no systemd unit change, no Docker
restart policy, and no shell on the host — the button works the same under
systemd, under Docker, and after a double-click. Ephemeral homes cannot
restart (their data would disappear with the dying child).

Crashes and ordinary exits still leave the supervisor: it does not
respawn a crashed child. Keep Restart=on-failure on the systemd unit (as in
the example above) and any Docker restart policy you already use so a dead
supervisor is brought back by the service manager. Admin restart is not a
failure exit that systemd or Docker must handle.

When to use --no-supervisor. Pass it when something outside Codumentor
must track a single PID that is the server (test harnesses, some launchers).
--reload (development) also skips the supervisor, because uvicorn already
owns a reloader process. Without a supervisor, the Admin restart button is
unavailable — restart with your service manager instead.

For what the confirmation dialog warns about and who may click Restart, see
Restarting the server from the Admin page.

Data Directories

Codumentor stores persistent data in the following directories. Ensure they exist and are writable by the service user before starting the application.

DirectoryPurposeDefault Path
data/vector_dbChromaDB vector database for indexed repository content./data/vector_db
data/agent_storageAgent conversation history and state (subagent transcripts in subagents/, one file per conversation)./data/agent_storage
logs/Application log files./logs/
mkdir -p /opt/codumentor/data/vector_db
mkdir -p /opt/codumentor/data/agent_storage
mkdir -p /opt/codumentor/logs
chown -R codumentor:codumentor /opt/codumentor/data /opt/codumentor/logs

Backup Strategy

What to Back Up

  1. SQLite databases -- Agent storage contains conversation history and session data. Back up all .db files under data/agent_storage/, including its subdirectories.
  2. Vector database directory -- The entire data/vector_db/ directory contains indexed repository content. This can be rebuilt by re-running ingestion, but backing it up avoids downtime.
  3. Configuration files -- Back up codumentor.yaml and any extended config files.

Example Backup Script

#!/bin/bash
BACKUP_DIR="/backups/codumentor/$(date +%Y%m%d)"
mkdir -p "$BACKUP_DIR"

# Stop the service briefly for consistent SQLite backups
sudo systemctl stop codumentor

cp -r /opt/codumentor/data/agent_storage "$BACKUP_DIR/"
cp -r /opt/codumentor/data/vector_db "$BACKUP_DIR/"
cp /opt/codumentor/codumentor.yaml "$BACKUP_DIR/"

sudo systemctl start codumentor

For zero-downtime backups, use SQLite's .backup command or sqlite3 CLI to create consistent copies without stopping the service.

Environment Variables for Production

API keys and secrets must be provided through environment variables, not stored in configuration files. Use the ${VAR_NAME} substitution syntax in codumentor.yaml:

models:
  agent_api_key: "${OPENAI_API_KEY}"
  embedding_api_key: "${GOOGLE_API_KEY}"

auth:
  provider: ldap
  ldap:
    bind_password: "${LDAP_BIND_PASSWORD}"

Set the variables in the systemd EnvironmentFile, in your shell profile, or through your secrets manager. Never commit actual secret values to version control.

Logging in Production

JSON Logging

Enable structured JSON logging for integration with log aggregation systems (ELK, Splunk, Datadog):

logging:
  level: INFO
  file: ./logs/codumentor.log
  json_logging: true
  json_log_file: ./logs/codumentor.json.log

Each log entry is a single JSON line suitable for machine parsing:

{
  "timestamp": "2026-02-16T10:30:00.123",
  "level": "INFO",
  "logger": "codumentor.api",
  "message": "Request completed",
  "context": {
    "session_id": "abc123"
  }
}

Log Rotation

Configure log rotation to prevent log files from consuming all disk space. Example logrotate configuration at /etc/logrotate.d/codumentor:

/opt/codumentor/logs/*.log {
    daily
    rotate 14
    compress
    delaycompress
    missingok
    notifempty
    copytruncate
}

See Also