refactor: flatten structure, sparse-checkout upstream, add base compose for dockge/traefik

Replace the nested `onyx/` full-clone approach with a flattened, self-contained
deployment structure:

- `make setup` now uses `git sparse-checkout` to fetch only `web/` and
  `deployment/data/nginx/` from upstream, extracting them flat into `./web`
  and `./data/nginx`. This avoids downloading the entire Onyx repository
  when we only rebuild the branded web container ourselves.
- Add a top-level `docker-compose.yml` as the base stack file instead of
  referencing paths inside `onyx/deployment/...`. This keeps the compose
  project in the repo root so it can be managed by dockge and simplifies
  putting Traefik in front of the Onyx nginx.
- Update `docker-compose.branding.yml` build context from `./onyx/web` to `./web`.
- Update `branding.config.json`:
  - `webSrcRoot`: `onyx/web` → `web`
  - `pinnedCommit`: pinned hash → `main`
  - Add rename literals for "Open Source AI Platform" → "Powered by Livtec"
    and `https://www.onyx.app` → `https://livtec.cloud`
- Replace the minimal `.env.example` with the full Onyx deployment template.
- Add `setup.sh` for server provisioning (Node.js 25, make, /opt/stacks/onyx).
- Update `make verify` to search `./web/src` instead of `./onyx/web/src`.

All backend/model services continue to use official upstream Docker images;
only the `web_server` image is built locally from the branded source.
This commit is contained in:
livdebus 2026-06-29 12:43:31 +02:00
parent c6e3776617
commit 1d650c4d30
7 changed files with 917 additions and 55 deletions

View file

@ -1,34 +1,324 @@
# ─────────────────────────────────────────────────────────────────────────────
# Deployment environment for the AIDO (Onyx CE) white-label.
# Copy to `.env` (same directory) and fill in real secrets: cp .env.example .env
#
# NOTE: Branding (name/logo/favicon/links) is NOT configured here — it is baked
# into the web image at build time from branding/branding.config.json. This file
# only holds DEPLOYMENT settings (secrets, auth, image version).
# ─────────────────────────────────────────────────────────────────────────────
# Copy this file to .env so it's picked up by the docker compose yaml files
# Uncomment the values you would like to set
# No edits necessary, works out of the box
# Pin BOTH the upstream image tag and the ./onyx checkout to the same release for
# a reproducible, version-matched deployment. `latest` follows upstream main.
################################################################################
## COMMONLY MODIFIED CONFIGURATIONS
################################################################################
## Version of Onyx to deploy, default is latest (main built nightly).
## Craft uses this same tag for the sandbox image; do not set a separate
## sandbox image for normal deployments.
IMAGE_TAG=latest
# Branded web image tag (built locally; any value is fine).
AIDO_TAG=local
## Onyx Craft Configuration (off by default).
## When enabling Craft through install.sh --include-craft or by manually adding
## docker-compose.craft.yml, the sandbox image follows IMAGE_TAG above.
# ENABLE_CRAFT=true
#
## docker backend drives sandboxes via the host Docker socket (root-equivalent;
## trusted hosts only) and needs v4.0.6+ images. install.sh picks docker vs
## kubernetes by image tag.
# SANDBOX_BACKEND=docker
#
## SANDBOX_API_SERVER_URL must be a *public* HTTPS URL the sandbox can reach
## the same way any other Onyx client does — internal compose hostnames like
## "http://api_server:8080" do not resolve from inside the sandbox bridge.
# SANDBOX_API_SERVER_URL=https://onyx.your-org.example
#
## Sandbox bridge network. Created by install.sh (or manually:
## docker network create onyx_craft_sandbox
## Sandboxes join only this network — they cannot reach postgres, redis,
## minio, or any other compose service by name.
# SANDBOX_DOCKER_NETWORK=onyx_craft_sandbox
#
## Per-sandbox container resource limits. Defaults match K8s pod *requests*
## (1 CPU / 2Gi), not its limits (2 CPU / 10Gi), since single-VM compose
## deployments rarely have headroom to over-commit every sandbox.
# SANDBOX_DOCKER_MEMORY_LIMIT=2g
# SANDBOX_DOCKER_CPU_LIMIT=1.0
#
## EC2 IMDS note: on EC2 the Docker daemon's default bridge allows traffic to
## 169.254.169.254 (Instance Metadata Service), which can hand out IAM role
## credentials. The fix is a host-level DOCKER-USER iptables rule that drops
## bridge traffic to that address. install.sh --include-craft installs this
## rule automatically when it has sudo/iptables access, and prints manual
## instructions otherwise.
# ── Object storage (MinIO) — REQUIRED, the compose refuses to start otherwise ──
MINIO_ROOT_USER=aido_minio_admin
MINIO_ROOT_PASSWORD=change-me-strong-password
S3_AWS_ACCESS_KEY_ID=aido_minio_admin
S3_AWS_SECRET_ACCESS_KEY=change-me-strong-password
## Auth Settings
### https://docs.onyx.app/deployment/authentication
AUTH_TYPE=oidc
SESSION_EXPIRE_TIME_SECONDS=604800 # 7 days
AUTH_COOKIE_EXPIRE_TIME_SECONDS=604800 # 7 days
### Signs password reset, email verification, OAuth login state, and captcha cookies.
### REQUIRED: the API server refuses to start with an empty value (secure by default).
### If using install.sh this is auto-generated; if setting manually, run: openssl rand -hex 32
USER_AUTH_SECRET=
### Recommend to set this for security
# ENCRYPTION_KEY_SECRET=
### Bearer token for the API server's /metrics endpoint. Auth is REQUIRED by
### default: scrapers must send `Authorization: Bearer <token>` (Prometheus
### scrape config: `authorization`). If you set neither this token nor
### DISABLE_METRICS_AUTH, /metrics is locked (returns 401).
# METRICS_AUTH_TOKEN=
### Set to "true" to expose /metrics with NO authentication (explicit opt-out).
# DISABLE_METRICS_AUTH=
### Set to "true" to expose the interactive API docs and schema (/openapi.json,
### /docs, /redoc) publicly with NO authentication. Off by default so the API
### surface is not exposed; when off these routes are not registered (404).
# ENABLE_PUBLIC_DOCS=
### Optional
# API_KEY_HASH_ROUNDS=
### You can add a comma separated list of domains like onyx.app, only those domains will be allowed to signup/log in
# VALID_EMAIL_DOMAINS=
### Set to "true" to restrict GET /users to admins. Non-admins can't enumerate
### accounts or share agents with individual users; group sharing still works.
# USER_DIRECTORY_ADMIN_ONLY=
# ── Auth ──
# Easiest first-run option is `disabled` (no login wall) to verify branding.
# For production use `oidc` / `google_oauth` / `basic` and add the matching vars
# from Onyx's docs. See onyx/deployment/docker_compose/.env.* examples upstream.
AUTH_TYPE=disabled
## Chat Configuration
# HARD_DELETE_CHATS=
# MAX_ALLOWED_UPLOAD_SIZE_MB=250
# Default per-user upload size limit (MB) when no admin value is set.
# Automatically clamped to MAX_ALLOWED_UPLOAD_SIZE_MB at runtime.
# DEFAULT_USER_FILE_MAX_UPLOAD_SIZE_MB=100
# Public URL the app is served from (used for callbacks / absolute links).
WEB_DOMAIN=http://localhost:3000
## Base URL for redirects
WEB_DOMAIN=
FQDN=
## Set to false to let any origin embed Onyx in an <iframe>, disabling
## clickjacking protection. Protected by default.
# WEB_FRAME_PROTECTION_ENABLED=false
# ── Postgres ── (defaults work for a local run; change for production)
## Enterprise Features, requires a paid plan and licenses
ENABLE_PAID_ENTERPRISE_EDITION_FEATURES=false
################################################################################
## SERVICES CONFIGURATIONS
################################################################################
## Database Configuration
POSTGRES_USER=postgres
POSTGRES_PASSWORD=password
POSTGRES_PASSWORD=
# POSTGRES_DB=
# POSTGRES_DEFAULT_SCHEMA=
# POSTGRES_USE_NULL_POOL=
# POSTGRES_API_SERVER_POOL_SIZE=
# POSTGRES_API_SERVER_POOL_OVERFLOW
# POSTGRES_IDLE_SESSIONS_TIMEOUT=
# POSTGRES_POOL_RECYCLE=
# Client-side TCP keepalives for the sync engine (sent on idle sockets to
# stop PgBouncer / NLB from silently closing them). Enabled by default.
# POSTGRES_TCP_KEEPALIVES=
# POSTGRES_TCP_KEEPALIVES_IDLE=
# POSTGRES_TCP_KEEPALIVES_INTERVAL=
# POSTGRES_TCP_KEEPALIVES_COUNT=
# DB_READONLY_USER=
# DB_READONLY_PASSWORD=
## File Store Backend: "s3" (default, uses MinIO) or "postgres" (no extra services needed)
## COMPOSE_PROFILES activates the MinIO service. To use PostgreSQL file storage instead,
## remove s3-filestore from COMPOSE_PROFILES and set FILE_STORE_BACKEND=postgres.
COMPOSE_PROFILES=s3-filestore
FILE_STORE_BACKEND=s3
## MinIO/S3 Configuration (only needed when FILE_STORE_BACKEND=s3)
## SECURITY: minioadmin is a local-dev default. install.sh randomizes it; if you
## edit .env by hand, change all four values before production. Keep the S3_AWS_*
## pair identical to MINIO_ROOT_* (the app uses MinIO's root creds).
S3_ENDPOINT_URL=
S3_AWS_ACCESS_KEY_ID=
S3_AWS_SECRET_ACCESS_KEY=
S3_FILE_STORE_BUCKET_NAME=
#MINIO_ROOT_USER=
#MINIO_ROOT_PASSWORD=
## GCS Configuration (only needed when FILE_STORE_BACKEND=gcs)
## No sidecar container needed — GCS is a managed service.
## Remove s3-filestore from COMPOSE_PROFILES when using FILE_STORE_BACKEND=gcs.
## By default, Application Default Credentials (ADC) are used, which supports
## GKE Workload Identity, Compute Engine instance SA, and gcloud CLI auth.
# FILE_STORE_BACKEND=gcs
# GCS_FILE_STORE_BUCKET_NAME=your-gcs-bucket-name
# GCS_FILE_STORE_PREFIX=onyx-files
# GCS_PROJECT_ID=your-gcp-project
# GCS_SERVICE_ACCOUNT_KEY_PATH=/path/to/service-account-key.json
# GCS_SERVICE_ACCOUNT_KEY_JSON=
## Nginx Proxy Timeout Configuration (in seconds)
## These settings control how long nginx waits for upstream servers (api_server/web_server)
## Increase these values if you experience timeout errors with long-running requests
# NGINX_PROXY_CONNECT_TIMEOUT=300
# NGINX_PROXY_SEND_TIMEOUT=300
# NGINX_PROXY_READ_TIMEOUT=300
## MCP Server Configuration
## The MCP (Model Context Protocol) server allows external MCP clients to interact with Onyx
## Set to true to enable the MCP server (disabled by default)
# MCP_SERVER_ENABLED=false
## Port for the MCP server (defaults to 8090)
# MCP_SERVER_PORT=8090
## CORS origins for MCP clients (comma-separated list)
# MCP_SERVER_CORS_ORIGINS=
## Discord Bot Configuration
## The Discord bot allows users to interact with Onyx from Discord servers
## Bot token from Discord Developer Portal (required to enable the bot)
# DISCORD_BOT_TOKEN=
## Command prefix for bot commands (default: "!")
# DISCORD_BOT_INVOKE_CHAR=!
## Celery Configuration
CELERY_BROKER_POOL_LIMIT=0
CELERY_WORKER_DOCFETCHING_CONCURRENCY=2
CELERY_WORKER_DOCPROCESSING_CONCURRENCY=1
CELERY_WORKER_LIGHT_CONCURRENCY=4
CELERY_WORKER_LIGHT_PREFETCH_MULTIPLIER=1
## AWS Configuration
# AWS_ACCESS_KEY_ID=
# AWS_SECRET_ACCESS_KEY=
# AWS_REGION_NAME=
# Set to true when using IAM authentication for Postgres connections.
USE_IAM_AUTH=false
################################################################################
## DEVELOPER, DEBUGGING, AND LOGGING
################################################################################
## Logging and Telemetry
# LOG_LEVEL is the global knob for log verbosity across every Onyx process:
# api_server, web_server, model servers, slack/discord bots, AND all Celery
# workers (primary, light, heavy, docprocessing, docfetching, monitoring,
# scheduled_tasks, user_file_processing, beat). For per-worker overrides,
# explicitly add `--loglevel=<value>` to that worker's command in
# backend/supervisord.conf — an explicit CLI flag takes precedence over
# LOG_LEVEL inside the worker process.
LOG_LEVEL=info
LOG_ONYX_MODEL_INTERACTIONS=False
# LOG_VESPA_TIMING_INFORMATION=
# LOG_ENDPOINT_LATENCY=
# LOG_POSTGRES_LATENCY=
# LOG_POSTGRES_CONN_COUNTS=
# DISABLE_TELEMETRY=
## Feature Flags
SHOW_EXTRA_CONNECTORS=true
# DISABLE_MODEL_SERVER=false
## Analytics
# SENTRY_DSN=
## Demo/Testing
# MOCK_CONNECTOR_FILE_PATH=
################################################################################
## ADVANCED CONFIGURATIONS
################################################################################
## SlackBot Configuration
# ONYX_BOT_DISABLE_DOCS_ONLY_ANSWER=
# ONYX_BOT_FEEDBACK_VISIBILITY=
# ONYX_BOT_DISPLAY_ERROR_MSGS=
# NOTIFY_SLACKBOT_NO_ANSWER=
# ONYX_BOT_MAX_QPM=
# ONYX_BOT_MAX_WAIT_TIME=
## Advanced Auth Settings
# GOOGLE_OAUTH_CLIENT_ID=
# GOOGLE_OAUTH_CLIENT_SECRET=
# REQUIRE_EMAIL_VERIFICATION=
# SMTP_SERVER=
# SMTP_PORT=
# SMTP_USER= # Optional - omit for unauthenticated relays
# SMTP_PASS= # Optional - omit for unauthenticated relays
# SMTP_STARTTLS=true # Set to "false" for servers that don't support TLS
# ENABLE_EMAIL_INVITES=
# EMAIL_FROM= # Required when SMTP_USER is not set
# EMAIL_ARCHIVE_BCC_ADDRESSES= # Optional comma-separated BCC archive recipients for all emails
OAUTH_CLIENT_ID=
OAUTH_CLIENT_SECRET=
OPENID_CONFIG_URL=
OIDC_PKCE_ENABLED=true
TRACK_EXTERNAL_IDP_EXPIRY=false
OIDC_SCOPE_OVERRIDE=openid,email,profile,offline_access
# Comma-separated list of origins allowed to make cross-origin (CORS) requests,
# e.g. "https://onyx.example.com". When unset, all origins are allowed but
# credentialed (cookie-authenticated) cross-origin requests are disabled.
CORS_ALLOWED_ORIGIN=
# INTEGRATION_TESTS_MODE=
# JWT_PUBLIC_KEY_URL=
## Gen AI Settings
GEN_AI_MAX_TOKENS=250000
# LLM_SOCKET_READ_TIMEOUT=
# MAX_CHUNKS_FED_TO_CHAT=
# DISABLE_LITELLM_STREAMING=
# LITELLM_EXTRA_HEADERS=
# GEN_AI_API_KEY=
# GENERATIVE_MODEL_ACCESS_CHECK_FREQ=
# LITELLM_CUSTOM_ERROR_MESSAGE_MAPPINGS=
## Query Options
# DOC_TIME_DECAY=
# HYBRID_ALPHA=
# EDIT_KEYWORD_QUERY=
# USE_SEMANTIC_KEYWORD_EXPANSIONS_BASIC_SEARCH=
## Model Configuration
# EMBEDDING_BATCH_SIZE=
# DOCUMENT_ENCODER_MODEL=
# DOC_EMBEDDING_DIM=
# NORMALIZE_EMBEDDINGS=
# ASYM_QUERY_PREFIX=
# ASYM_PASSAGE_PREFIX=
# DISABLE_RERANK_FOR_STREAMING=
# MODEL_SERVER_PORT=
# INDEX_BATCH_SIZE=
# MIN_THREADS_ML_MODELS=
# CLIENT_EMBEDDING_TIMEOUT=
## Indexing Configuration
# VESPA_SEARCHER_THREADS=
# ENABLED_CONNECTOR_TYPES=
# DISABLE_INDEX_UPDATE_ON_SWAP=
# CONTINUE_ON_CONNECTOR_FAILURE=
# CONFLUENCE_CONNECTOR_LABELS_TO_SKIP=
# JIRA_CONNECTOR_LABELS_TO_SKIP=
# JIRA_SERVER_API_VERSION=
# JIRA_CLOUD_API_VERSION=
# GONG_CONNECTOR_START_TIME=
# NOTION_CONNECTOR_ENABLE_RECURSIVE_PAGE_LOOKUP=
# GITHUB_CONNECTOR_BASE_URL=
# MAX_DOCUMENT_CHARS=
# MAX_FILE_SIZE_BYTES=
## OAuth Connector Configs
# EGNYTE_CLIENT_ID=
# EGNYTE_CLIENT_SECRET=
# EGNYTE_LOCALHOST_OVERRIDE=
# LINEAR_CLIENT_ID=
# LINEAR_CLIENT_SECRET=
## Miscellaneous
# ONYX_QUERY_HISTORY_TYPE=
# Hide the Query History page from the admin sidebar (visibility-only; the history
# APIs + recording keep working, unlike ONYX_QUERY_HISTORY_TYPE=disabled).
# HIDE_QUERY_HISTORY_FROM_ADMIN_PANEL=true
# CHECK_TTL_MANAGEMENT_TASK_FREQUENCY_IN_HOURS=
# VESPA_LANGUAGE_OVERRIDE=
## Frontend Configs
# THEME_IS_DARK=
# NEXT_PUBLIC_DISABLE_LOGOUT=
# NEXT_PUBLIC_FORGOT_PASSWORD_ENABLED=
# NEXT_PUBLIC_THEME=
# NEXT_PUBLIC_DO_NOT_USE_TOGGLE_OFF_DANSWER_POWERED=
# NEXT_PUBLIC_CUSTOM_REFRESH_URL=
## Pointer to services
POSTGRES_HOST=relational_db
REDIS_HOST=cache
MODEL_SERVER_HOST=inference_model_server
INDEXING_MODEL_SERVER_HOST=indexing_model_server
INTERNAL_URL=http://api_server:8080
ENABLE_CONTEXTUAL_RAG=true

View file

@ -1,17 +0,0 @@
# ─────────────────────────────────────────────────────────────────────────────
# nginx environment for the AIDO (Onyx CE) white-label.
# Copy to `.env.nginx` (same directory): cp .env.nginx.example .env.nginx
#
# This is Onyx's standard nginx config (not branding-specific). The DOMAIN is used
# to render the server_name; the SSL_* names point at cert files you place in
# onyx/deployment/data/sslcerts/ for the no-letsencrypt profile.
# ─────────────────────────────────────────────────────────────────────────────
DOMAIN=localhost
# For the prod-no-letsencrypt profile, drop your cert + key in
# onyx/deployment/data/sslcerts/ and name them here. For a quick local test you
# can self-sign: openssl req -x509 -newkey rsa:2048 -nodes -days 365 \
# -keyout onyx/deployment/data/sslcerts/ssl.key \
# -out onyx/deployment/data/sslcerts/ssl.crt -subj "/CN=localhost"
SSL_CERT_FILE_NAME=ssl.crt
SSL_CERT_KEY_FILE_NAME=ssl.key

View file

@ -15,7 +15,7 @@
# Use the no-letsencrypt prod compose by default (no TLS/domain needed). Override
# with `make COMPOSE_BASE=onyx/deployment/docker_compose/docker-compose.prod.yml`.
COMPOSE_BASE ?= onyx/deployment/docker_compose/docker-compose.prod-no-letsencrypt.yml
COMPOSE_BASE ?= ./docker-compose.yml
COMPOSE = docker compose --project-directory . -f $(COMPOSE_BASE) -f docker-compose.branding.yml
.PHONY: setup rebrand apply build up down restart logs verify config
@ -24,13 +24,28 @@ COMPOSE = docker compose --project-directory . -f $(COMPOSE_BASE) -f docker-comp
# Reads upstream.repo / upstream.pinnedCommit from branding/branding.config.json.
ONYX_REPO = $(shell node -e "console.log(require('./branding/branding.config.json').upstream.repo)")
ONYX_COMMIT = $(shell node -e "console.log(require('./branding/branding.config.json').upstream.pinnedCommit)")
setup:
@if [ -d onyx/.git ] || [ -d onyx/web ]; then \
echo "onyx/ already present — skipping clone."; \
else \
echo "Cloning $(ONYX_REPO) @ $(ONYX_COMMIT) into ./onyx ..."; \
git clone $(ONYX_REPO) onyx && git -C onyx checkout $(ONYX_COMMIT); \
fi
@set -e; \
TMP=".onyx-sparse-tmp"; \
echo "Fetching $(ONYX_REPO) @ $(ONYX_COMMIT) ..."; \
rm -rf "$$TMP"; \
git clone --filter=blob:none --no-checkout $(ONYX_REPO) "$$TMP"; \
git -C "$$TMP" sparse-checkout init --cone; \
git -C "$$TMP" sparse-checkout set web deployment/data/nginx; \
git -C "$$TMP" checkout $(ONYX_COMMIT); \
\
echo "Extracting web/ ..."; \
rm -rf web; \
cp -r "$$TMP/web" ./web; \
\
echo "Extracting deployment/data/nginx/ -> data/nginx/ ..."; \
rm -rf data/nginx; \
mkdir -p data; \
cp -r "$$TMP/deployment/data/nginx" ./data/nginx; \
\
rm -rf "$$TMP"; \
echo "Done."
rebrand: apply build up
@ -57,5 +72,5 @@ config:
verify:
@echo "Stray standalone 'Onyx' in shipping web source (expect 0):"
@grep -rnE '\bOnyx\b' onyx/web/src --include='*.ts' --include='*.tsx' \
@grep -rnE '\bOnyx\b' web/src --include='*.ts' --include='*.tsx' \
| grep -vE '\.test\.|\.spec\.|\.stories\.|__tests__|__mocks__' | wc -l

View file

@ -11,8 +11,8 @@
"upstream": {
"$comment": "Pin the exact Onyx commit/tag this overlay was authored against. Bump together with branding.apply when upgrading. Used only for documentation/verification.",
"repo": "https://github.com/onyx-dot-app/onyx",
"pinnedCommit": "d0f3b66",
"webSrcRoot": "onyx/web"
"pinnedCommit": "main",
"webSrcRoot": "web"
},
"assets": {
@ -54,7 +54,9 @@
"$comment": "Drives the user-visible string codemod. `word` replaces standalone, capitalised whole-word matches of \\bOnyx\\b only — camelCase identifiers (OnyxDocument, SvgOnyxLogo), lowercase package refs (@onyx, onyx.app, onyx.ico) are never touched. `literals` are exact-string replacements applied before the word pass for multi-word brand terms.",
"word": { "Onyx": "AIDO" },
"literals": {
"https://docs.onyx.app": "https://portal.livtec.cloud"
"Open Source AI Platform": "Powered by Livtec",
"https://docs.onyx.app": "https://portal.livtec.cloud",
"https://www.onyx.app": "https://livtec.cloud"
}
}
}

View file

@ -23,6 +23,6 @@ services:
# Project directory is the repo root (--project-directory .), so point the
# build context at the branded source. Everything else inherits from the
# upstream base file (Dockerfile, NEXT_PUBLIC build args).
context: ./onyx/web
context: ./web
dockerfile: Dockerfile
pull_policy: never

563
docker-compose.yml Normal file
View file

@ -0,0 +1,563 @@
# =============================================================================
# ONYX DOCKER COMPOSE
# =============================================================================
# This is the default configuration for Onyx. This file is fairly configurable,
# also see env.template for possible settings.
#
# PRODUCTION DEPLOYMENT CHECKLIST:
# To convert this setup to a production deployment following best practices,
# follow the checklist below. Note that there are other ways to secure the Onyx
# deployment so these are not strictly necessary for all teams.
#
# 1. SECURITY HARDENING:
# - Remove all port exposures except nginx (80/443)
# - Comment out ports for: api_server, relational_db, cache, minio
# - Set strong MinIO/S3 credentials (MINIO_ROOT_* + S3_AWS_*), not minioadmin
#
# 2. SSL/TLS SETUP:
# - Uncomment the certbot service (see below)
# - Add SSL certificate volumes to nginx service
# - Change nginx command from app.conf.template to app.conf.template.prod
#
# 3. ENVIRONMENT CONFIGURATION:
# - Replace env_file with explicit environment variables
#
# 4. AUTHENTICATION:
# - Select an authentication method like Basic, Google OAuth, OIDC, or SAML
#
# 5. CA CERTIFICATES:
# - Uncomment custom CA certificate volumes if needed
#
# 6. DOMAIN CONFIGURATION:
# - Set proper DOMAIN environment variable for nginx
# - Configure DNS and SSL certificates
#
# For a complete production setup, refer to docker-compose.prod.yml
# =============================================================================
name: onyx
services:
api_server:
image: ${ONYX_BACKEND_IMAGE:-onyxdotapp/onyx-backend:${IMAGE_TAG:-latest}}
build:
context: ../../backend
dockerfile: Dockerfile
command: >
/bin/sh -c "alembic upgrade head && echo \"Starting Onyx Api Server\" &&
uvicorn onyx.main:app --host 0.0.0.0 --port 8080"
# Check env.template and copy to .env for env vars
env_file:
- path: .env
required: false
depends_on:
relational_db:
condition: service_started
opensearch:
condition: service_started
cache:
condition: service_started
inference_model_server:
condition: service_started
restart: unless-stopped
networks:
- onyx-network
# DEV: To expose ports, either:
# 1. Use docker-compose.dev.yml: docker compose -f docker-compose.yml -f docker-compose.dev.yml up -d --wait
# 2. Uncomment the ports below
# ports:
# - "8080:8080"
environment:
# Auth Settings
- AUTH_TYPE=${AUTH_TYPE:-basic}
- FILE_STORE_BACKEND=${FILE_STORE_BACKEND:-s3}
- POSTGRES_HOST=${POSTGRES_HOST:-relational_db}
- OPENSEARCH_HOST=${OPENSEARCH_HOST:-opensearch}
- OPENSEARCH_ADMIN_PASSWORD=${OPENSEARCH_ADMIN_PASSWORD:-StrongPassword123!}
- REDIS_HOST=${REDIS_HOST:-cache}
- MODEL_SERVER_HOST=${MODEL_SERVER_HOST:-inference_model_server}
- CODE_INTERPRETER_BASE_URL=${CODE_INTERPRETER_BASE_URL:-http://code-interpreter:8000}
- S3_ENDPOINT_URL=${S3_ENDPOINT_URL:-http://minio:9000}
- S3_REGION=us-east-1
- S3_AWS_ACCESS_KEY_ID=${S3_AWS_ACCESS_KEY_ID:-minioadmin}
- S3_AWS_SECRET_ACCESS_KEY=${S3_AWS_SECRET_ACCESS_KEY:-minioadmin}
# Onyx Craft configuration (disabled by default, set ENABLE_CRAFT=true in .env to enable)
# Use --include-craft with install script, or manually set in .env file
- ENABLE_CRAFT=${ENABLE_CRAFT:-false}
# PRODUCTION: Uncomment the line below to use if IAM_AUTH is true and you are using iam auth for postgres
# volumes:
# - ./bundle.pem:/app/bundle.pem:ro
extra_hosts:
- host.docker.internal:host-gateway
logging:
driver: json-file
options:
max-size: 50m
max-file: "6"
healthcheck:
test:
- CMD
- python
- -c
- import urllib.request;
urllib.request.urlopen('http://localhost:8080/health')
interval: 30s
timeout: 20s
retries: 3
# Generous start_period so that `docker compose up --wait` does not flag
# the container unhealthy while alembic migrations run on a fresh DB.
# Healthy is reported as soon as /health responds, so this does not slow
# down fast boots.
start_period: 600s
# Optional, only for debugging purposes
volumes:
- ./api_server_logs:/var/log/onyx
# Shared volume for persistent document storage (Craft file-system mode)
- ./file-system:/app/file-system
background:
image: ${ONYX_BACKEND_IMAGE:-onyxdotapp/onyx-backend:${IMAGE_TAG:-latest}}
build:
context: ../../backend
dockerfile: Dockerfile
command: |
/bin/sh -c " if [ -f /etc/ssl/certs/custom-ca.crt ]; then
update-ca-certificates;
fi && /app/scripts/supervisord_entrypoint.sh"
networks:
- onyx-network
env_file:
- path: .env
required: false
depends_on:
relational_db:
condition: service_started
opensearch:
condition: service_started
cache:
condition: service_started
inference_model_server:
condition: service_started
indexing_model_server:
condition: service_started
restart: unless-stopped
environment:
- FILE_STORE_BACKEND=${FILE_STORE_BACKEND:-s3}
- POSTGRES_HOST=${POSTGRES_HOST:-relational_db}
- OPENSEARCH_HOST=${OPENSEARCH_HOST:-opensearch}
- OPENSEARCH_ADMIN_PASSWORD=${OPENSEARCH_ADMIN_PASSWORD:-StrongPassword123!}
- REDIS_HOST=${REDIS_HOST:-cache}
- MODEL_SERVER_HOST=${MODEL_SERVER_HOST:-inference_model_server}
- INDEXING_MODEL_SERVER_HOST=${INDEXING_MODEL_SERVER_HOST:-indexing_model_server}
- S3_ENDPOINT_URL=${S3_ENDPOINT_URL:-http://minio:9000}
- S3_REGION=us-east-1
- S3_AWS_ACCESS_KEY_ID=${S3_AWS_ACCESS_KEY_ID:-minioadmin}
- S3_AWS_SECRET_ACCESS_KEY=${S3_AWS_SECRET_ACCESS_KEY:-minioadmin}
- DISCORD_BOT_TOKEN=${DISCORD_BOT_TOKEN:-}
- DISCORD_BOT_INVOKE_CHAR=${DISCORD_BOT_INVOKE_CHAR:-!}
# API Server connection for Discord bot message processing
- API_SERVER_PROTOCOL=${API_SERVER_PROTOCOL:-http}
- API_SERVER_HOST=${API_SERVER_HOST:-api_server}
# Onyx Craft configuration (set up automatically on container startup)
- ENABLE_CRAFT=${ENABLE_CRAFT:-false}
# PRODUCTION: Uncomment the line below to use if IAM_AUTH is true and you are using iam auth for postgres
# volumes:
# - ./bundle.pem:/app/bundle.pem:ro
extra_hosts:
- host.docker.internal:host-gateway
# Optional, only for debugging purposes
volumes:
- ./background_logs:/var/log/onyx
# Shared volume for persistent document storage (Craft file-system mode)
- ./file-system:/app/file-system
logging:
driver: json-file
options:
max-size: 50m
max-file: "6"
# PRODUCTION: Uncomment the following lines if you need to include a custom CA certificate
# This section enables the use of a custom CA certificate
# If present, the custom CA certificate is mounted as a volume
# The container checks for its existence and updates the system's CA certificates
# This allows for secure communication with services using custom SSL certificates
# Optional volume mount for CA certificate
# volumes:
# # Maps to the CA_CERT_PATH environment variable in the Dockerfile
# - ${CA_CERT_PATH:-./custom-ca.crt}:/etc/ssl/certs/custom-ca.crt:ro
web_server:
image: ${ONYX_WEB_SERVER_IMAGE:-onyxdotapp/onyx-web-server:${IMAGE_TAG:-latest}}
build:
context: ../../web
dockerfile: Dockerfile
args:
- NEXT_PUBLIC_DISABLE_LOGOUT=${NEXT_PUBLIC_DISABLE_LOGOUT:-}
- NEXT_PUBLIC_FORGOT_PASSWORD_ENABLED=${NEXT_PUBLIC_FORGOT_PASSWORD_ENABLED:-}
# Enterprise Edition only
- NEXT_PUBLIC_THEME=${NEXT_PUBLIC_THEME:-}
# DO NOT TURN ON unless you have EXPLICIT PERMISSION from Onyx.
- NEXT_PUBLIC_DO_NOT_USE_TOGGLE_OFF_DANSWER_POWERED=${NEXT_PUBLIC_DO_NOT_USE_TOGGLE_OFF_DANSWER_POWERED:-false}
- NODE_OPTIONS=${NODE_OPTIONS:-"--max-old-space-size=4096"}
networks:
- onyx-network
env_file:
- path: .env
required: false
depends_on:
- api_server
restart: unless-stopped
environment:
- INTERNAL_URL=${INTERNAL_URL:-http://api_server:8080}
healthcheck:
test:
- CMD
- node
- -e
- "require('http').get('http://127.0.0.1:3000/', (r) =>
process.exit(r.statusCode < 500 ? 0 : 1)).on('error', () =>
process.exit(1))"
interval: 30s
timeout: 10s
retries: 5
start_period: 30s
# Uncomment the block below to enable the MCP server for Onyx.
# mcp_server:
# image: ${ONYX_BACKEND_IMAGE:-onyxdotapp/onyx-backend:${IMAGE_TAG:-latest}}
# build:
# context: ../../backend
# dockerfile: Dockerfile
# command: >
# /bin/sh -c "if [ \"${MCP_SERVER_ENABLED:-}\" != \"True\" ] && [ \"${MCP_SERVER_ENABLED:-}\" != \"true\" ]; then
# echo 'MCP server is disabled (MCP_SERVER_ENABLED=false), skipping...';
# exit 0;
# else
# exec python -m onyx.mcp_server_main;
# fi"
# env_file:
# - path: .env
# required: false
# depends_on:
# - relational_db
# - cache
# restart: "no"
# environment:
# - POSTGRES_HOST=${POSTGRES_HOST:-relational_db}
# - REDIS_HOST=${REDIS_HOST:-cache}
# # MCP Server Configuration
# - MCP_SERVER_ENABLED=${MCP_SERVER_ENABLED:-false}
# - MCP_SERVER_PORT=${MCP_SERVER_PORT:-8090}
# - MCP_SERVER_CORS_ORIGINS=${MCP_SERVER_CORS_ORIGINS:-}
# - API_SERVER_PROTOCOL=${API_SERVER_PROTOCOL:-http}
# - API_SERVER_HOST=${API_SERVER_HOST:-api_server}
# extra_hosts:
# - "host.docker.internal:host-gateway"
# logging:
# driver: json-file
# options:
# max-size: "50m"
# max-file: "6"
# # Optional, only for debugging purposes
# volumes:
# - mcp_server_logs:/var/log/onyx
inference_model_server:
image: ${ONYX_MODEL_SERVER_IMAGE:-onyxdotapp/onyx-model-server:${IMAGE_TAG:-latest}}
build:
context: ../../backend
dockerfile: Dockerfile.model_server
# GPU Support: Uncomment the following lines to enable GPU support
# Requires nvidia-container-toolkit to be installed on the host
# deploy:
# resources:
# reservations:
# devices:
# - driver: nvidia
# count: all
# capabilities: [gpu]
command: >
/bin/sh -c "if [ \"${DISABLE_MODEL_SERVER:-}\" = \"True\" ] || [
\"${DISABLE_MODEL_SERVER:-}\" = \"true\" ]; then
echo 'Skipping service...';
exit 0;
else
exec uvicorn model_server.main:app --host 0.0.0.0 --port 9000;
fi"
networks:
- onyx-network
env_file:
- path: .env
required: false
restart: unless-stopped
volumes:
# Not necessary, this is just to reduce download time during startup
- ./model_cache_huggingface:/app/.cache/huggingface/
# Optional, only for debugging purposes
- ./inference_model_server_logs:/var/log/onyx
logging:
driver: json-file
options:
max-size: 50m
max-file: "6"
healthcheck:
test:
- CMD
- python
- -c
- import urllib.request;
urllib.request.urlopen('http://localhost:9000/api/health')
interval: 20s
timeout: 5s
retries: 3
# Generous start_period to absorb HuggingFace model downloads on first
# boot. Healthy is reported as soon as /api/health responds.
start_period: 600s
indexing_model_server:
image: ${ONYX_MODEL_SERVER_IMAGE:-onyxdotapp/onyx-model-server:${IMAGE_TAG:-latest}}
build:
context: ../../backend
dockerfile: Dockerfile.model_server
# GPU Support: Uncomment the following lines to enable GPU support
# Requires nvidia-container-toolkit to be installed on the host
# deploy:
# resources:
# reservations:
# devices:
# - driver: nvidia
# count: all
# capabilities: [gpu]
command: >
/bin/sh -c "if [ \"${DISABLE_MODEL_SERVER:-}\" = \"True\" ] || [
\"${DISABLE_MODEL_SERVER:-}\" = \"true\" ]; then
echo 'Skipping service...';
exit 0;
else
exec uvicorn model_server.main:app --host 0.0.0.0 --port 9000;
fi"
networks:
- onyx-network
env_file:
- path: .env
required: false
restart: unless-stopped
environment:
- INDEXING_ONLY=True
volumes:
# Not necessary, this is just to reduce download time during startup
- ./indexing_huggingface_model_cache:/app/.cache/huggingface/
# Optional, only for debugging purposes
- ./indexing_model_server_logs:/var/log/onyx
logging:
driver: json-file
options:
max-size: 50m
max-file: "6"
healthcheck:
test:
- CMD
- python
- -c
- import urllib.request;
urllib.request.urlopen('http://localhost:9000/api/health')
interval: 20s
timeout: 5s
retries: 3
# Generous start_period to absorb HuggingFace model downloads on first
# boot. Healthy is reported as soon as /api/health responds.
start_period: 600s
relational_db:
image: ${BASE_IMAGE_REGISTRY:-docker.io}/library/postgres:15.2-alpine
shm_size: 1g
command: -c 'max_connections=250'
networks:
- onyx-network
env_file:
- path: .env
required: false
restart: unless-stopped
# PRODUCTION: Override the defaults by passing in the environment variables
environment:
- POSTGRES_USER=${POSTGRES_USER:-postgres}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-password}
# DEV: To expose ports, either:
# 1. Use docker-compose.dev.yml: docker compose -f docker-compose.yml -f docker-compose.dev.yml up -d --wait
# 2. Uncomment the ports below
# ports:
# - "5432:5432"
healthcheck:
test:
- CMD-SHELL
- pg_isready -U ${POSTGRES_USER:-postgres}
interval: 10s
timeout: 5s
retries: 5
volumes:
- ./db_volume:/var/lib/postgresql/data
opensearch:
image: ${BASE_IMAGE_REGISTRY:-docker.io}/opensearchproject/opensearch:3.6.0
restart: unless-stopped
# OpenSearch is the search backend and is enabled by default. To run against
# an external OpenSearch instance, set OPENSEARCH_HOST in your env and
# remove this service from the compose file (or skip it via the service list
# when running `docker compose up`).
environment:
# We need discovery.type=single-node so that OpenSearch doesn't try
# forming a cluster and waiting for other nodes to become live.
- discovery.type=single-node
- OPENSEARCH_INITIAL_ADMIN_PASSWORD=${OPENSEARCH_ADMIN_PASSWORD:-StrongPassword123!}
# This and the JVM config below come from the example in https://docs.opensearch.org/latest/install-and-configure/install-opensearch/docker/
# We do this to avoid unstable performance from page swaps.
- bootstrap.memory_lock=true # Disable JVM heap memory swapping.
# Java heap should be ~50% of memory limit. For now we assume a limit of
# 4g although in practice the container can request more than this.
# See https://opster.com/guides/opensearch/opensearch-basics/opensearch-heap-size-usage-and-jvm-garbage-collection/
# Xms is the starting size, Xmx is the maximum size. These should be the
# same.
- OPENSEARCH_JAVA_OPTS=-Xms2g -Xmx2g
networks:
- onyx-network
volumes:
- opensearch-data:/usr/share/opensearch/data
# These come from the example in https://docs.opensearch.org/latest/install-and-configure/install-opensearch/docker/
ulimits:
# Similarly to bootstrap.memory_lock, we don't want to impose limits on
# how much memory a process can lock from being swapped.
memlock:
soft: -1 # Set memlock to unlimited (no soft or hard limit).
hard: -1
nofile:
soft: 65536 # Maximum number of open files for the opensearch user - set to at least 65536.
hard: 65536
logging:
driver: json-file
options:
max-size: 50m
max-file: "6"
nginx:
image: ${BASE_IMAGE_REGISTRY:-docker.io}/library/nginx:1.25.5-alpine
restart: unless-stopped
# nginx will immediately crash with `nginx: [emerg] host not found in upstream`
# if api_server / web_server are not up
depends_on:
api_server:
condition: service_healthy
web_server:
condition: service_healthy
env_file:
- path: .env
required: false
environment:
- DOMAIN=localhost
# Nginx proxy timeout settings (in seconds)
- NGINX_PROXY_CONNECT_TIMEOUT=${NGINX_PROXY_CONNECT_TIMEOUT:-300}
- NGINX_PROXY_SEND_TIMEOUT=${NGINX_PROXY_SEND_TIMEOUT:-300}
- NGINX_PROXY_READ_TIMEOUT=${NGINX_PROXY_READ_TIMEOUT:-300}
labels:
- traefik.enable=true
# Chat service
- traefik.http.routers.onyx-router.rule=Host(`${FQDN}`)
- traefik.http.routers.onyx-router.service=onyx-service
- traefik.http.routers.onyx-router.entrypoints=web,websecure
- traefik.http.services.onyx-service.loadbalancer.server.port=80
expose:
- 3000
networks:
- onyx-network
- web
#ports:
# - "${HOST_PORT_80:-80}:80"
# - "${HOST_PORT:-3000}:80" # allow for localhost:3000 usage, since that is the norm
volumes:
# Mount templates read-only; the startup command copies them into
# the writable /etc/nginx/conf.d/ inside the container. This avoids
# "Permission denied" errors on Windows Docker bind mounts.
- ./data/nginx:/nginx-templates:ro
# PRODUCTION: Add SSL certificate volumes for HTTPS support:
# - ../data/certbot/conf:/etc/letsencrypt
# - ../data/certbot/www:/var/www/certbot
logging:
driver: json-file
options:
max-size: 50m
max-file: "6"
# The specified script waits for the api_server to start up.
# Without this we've seen issues where nginx shows no error logs but
# does not receive any traffic
# PRODUCTION: Change to app.conf.template.prod for production nginx config
command: >
/bin/sh -c "rm -f /etc/nginx/conf.d/default.conf && cp -a
/nginx-templates/. /etc/nginx/conf.d/ && sed 's/\r$//'
/etc/nginx/conf.d/run-nginx.sh > /tmp/run-nginx.sh && chmod +x
/tmp/run-nginx.sh && /tmp/run-nginx.sh app.conf.template"
healthcheck:
test:
- CMD
- wget
- --quiet
- --tries=1
- --spider
- http://127.0.0.1/nginx-health
interval: 30s
timeout: 10s
retries: 5
start_period: 30s
cache:
image: ${BASE_IMAGE_REGISTRY:-docker.io}/library/redis:7.4-alpine
restart: unless-stopped
# DEV: To expose ports, either:
# 1. Use docker-compose.dev.yml: docker compose -f docker-compose.yml -f docker-compose.dev.yml up -d --wait
# 2. Uncomment the ports below
# ports:
# - "6379:6379"
# docker silently mounts /data even without an explicit volume mount, which enables
# persistence. explicitly setting save and appendonly forces ephemeral behavior.
command: redis-server --save "" --appendonly no
networks:
- onyx-network
env_file:
- path: .env
required: false
# Use tmpfs to prevent creation of anonymous volumes for /data
tmpfs:
- /data
code-interpreter:
image: onyxdotapp/code-interpreter:${CODE_INTERPRETER_IMAGE_TAG:-latest}
command:
- bash
- ./entrypoint.sh
- code-interpreter-api
restart: unless-stopped
networks:
- onyx-network
env_file:
- path: .env
required: false
# Below is needed for the `docker-out-of-docker` execution mode
# For Linux rootless Docker, set DOCKER_SOCK_PATH=${XDG_RUNTIME_DIR}/docker.sock
user: root
volumes:
- ${DOCKER_SOCK_PATH:-/var/run/docker.sock}:/var/run/docker.sock
# uncomment below + comment out the above to use the `docker-in-docker` execution mode
# privileged: true
# PRODUCTION: Uncomment the following certbot service for SSL certificate management
# certbot:
# image: certbot/certbot
# restart: unless-stopped
# volumes:
# - ../data/certbot/conf:/etc/letsencrypt
# - ../data/certbot/www:/var/www/certbot
# logging:
# driver: json-file
# options:
# max-size: "50m"
# max-file: "6"
# entrypoint: "/bin/sh -c 'trap exit TERM; while :; do certbot renew; sleep 12h & wait $${!}; done;'"
volumes:
# Persistent data for OpenSearch.
opensearch-data: null
networks:
onyx-network:
driver: bridge
web:
name: web
external: true
attachable: true

9
setup.sh Normal file
View file

@ -0,0 +1,9 @@
# Install nodejs
cd ~
curl -sL https://deb.nodesource.com/setup_25.x -o nodesource_setup.sh
sudo bash nodesource_setup.sh
apt install make -y
mkdir /opt/stacks/onyx
cd /opt/stacks/onyx
wget XY
cp .env.template .env