Source deployment

Build from source, suitable for users who need to modify code or work in an offline environment.
Boundary: This is the source path for changing code or running offline. For the production architecture, database, and minimum specifications, see Architecture and deployment topologies.

This path is for users who need to change code, debug, or use custom dependencies. If you do not want to manage a Python environment, use Docker deployment.

Deployment flow

Step Goal Completion criterion
Step 1 Prepare Python, git, ports, and network access Version and port checks pass
Step 2 Clone the source, create a virtual environment, and install dependencies pip install succeeds and data/ exists
Step 3 Configure .env, an execution engine, and a login method .env exists and JWT_SECRET is not empty (production also requires GRAPE_ADMIN_PASSWORD)
Step 4 Start development or production mode The process keeps running and the port is listening
Step 5 Verify the health check, console, and pipeline conditions /api/health is normal and login is available

Step 1: Prepare the environment

Component Version Notes
Python 3.10+ (required) Versions below 3.10 print an explicit message and exit (_MIN_PYTHON in src/api/version_check.py)
Node.js Per the official opencode-ai installation instructions Required only when installing the Agent CLI with npm install -g opencode-ai; the platform itself does not depend on Node
Git Any reasonably recent version

Port requirements:

Mode Port Purpose
Development mode 3000 Single-process API, console, and hot reload
Production mode 3000 / 8080 Main API and webhook processes; exposed through an nginx reverse proxy

Check commands:

python3 --version
git --version
ss -lntp

Install at least one Agent CLI. Otherwise, the platform starts but the pipeline cannot execute:

npm install -g opencode-ai
# Or
pip install codearts-cli

Step 2: Clone the source and install dependencies

Linux / macOS

git clone https://gitcode.com/grape-dev/grape.git
cd grape

python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements-local.txt     # Minimal dependencies (without OBS, MySQL, or Feishu)
# pip install -r requirements.txt         # Full dependencies; recommended for production

cp .env.example .env
mkdir -p data

The primary address is GitCode. The GitHub mirror https://github.com/grape-dev/grape.git is equivalent, but it is often unreachable from mainland China; do not retry repeatedly if the connection fails.

Windows (PowerShell)

git clone https://gitcode.com/grape-dev/grape.git
cd grape
python -m venv .venv
.\.venv\Scripts\Activate.ps1
pip install -r requirements-local.txt
Copy-Item .env.example .env
New-Item -ItemType Directory -Force -Path data

The repository includes one-click scripts that create a virtual environment, install dependencies, copy .env, run self-checks, and start the service:
On Windows, use .\start.ps1 (add -Full for full dependencies and -SkipDoctor to skip self-checks).
On Linux/macOS, the development entry point is python start_server.py (src/api/main:app, port 3000, with reload).

Step 3: Configure runtime parameters

Step 2 copied .env from .env.example. This section configures the required values.

1. JWT_SECRET

Do not keep the example value for JWT_SECRET. Generate a random value first:

python3 -c "import secrets; print(secrets.token_urlsafe(48))"
# Write the output to the JWT_SECRET= line in .env at the repository root

The startup entry point src/api/run.py automatically reads .env from the repository root; no additional export is required.

2. Database and cookies

The default configuration is sufficient to start:

Configuration Development Production
DEVOPS_DB_BACKEND sqlite Change to MySQL as needed
OBS_ENABLED false Enable when object storage is required
COOKIE_SECURE false (HTTP) true (HTTPS)

To switch to MySQL, see Database backend and official synchronization.

3. Administrator initial password (before startup)

On first startup, grape-server creates the administrator admin when admin_accounts is empty. The password is read from GRAPE_ADMIN_PASSWORD in the environment of that startup process; if it is not set, the default is admin123 (_seed_admin_accounts() in src/api/db_setup.py). Seeding runs only once, while admin_accounts is empty. Changing the environment variable after startup does not alter the password already stored; sign in as admin and change the password in the admin console instead.

Scenario .env setting Notes
Development / trial Not set Sign in with admin / admin123 and change the password immediately after the first sign-in
Production GRAPE_ADMIN_PASSWORD=<strong-password> Must be written before Step 4 starts the service; .env.example does not contain this key, so append it to .env manually

4. Execution engine

The Agent CLI must be executable by the same user that starts the service:

which opencode
# Or
which codearts

If there is no output, reinstall the Agent CLI or confirm that its directory is on the service process PATH. You can also use AI Shell; for integration, see Installation and startup.

5. Login method

On the first local startup, you can register and sign in with a username and password directly; OAuth configuration is not required.

To use GitCode, GitHub, or another OAuth provider, configure it first:

cp configs/server-config.example.json configs/server-config.json

A local account can sign in directly. To enable GitCode, GitHub, or Gitee login, change server_base_url to an address that browsers can reach, and enter client_id and client_secret in Login channels in the admin console. For complete steps, see Configure third-party login.

Step 4: Start the service

The administrator is seeded only on the first startup, and only when admin_accounts is empty. To set a custom initial password, complete "Administrator initial password" in Step 3 before running the commands below.

Development mode

python -m src.api.run --dev
  • The startup entry point is src.api.main:app.
  • A single process listens on 3000.
  • Hot reload is enabled; code changes restart the process automatically.

Wait until the startup log shows Uvicorn running on http://0.0.0.0:3000 and Application startup complete before verifying the deployment.

Production mode

python -m src.api.run

Production mode starts two processes:

Process Port Purpose
Main API 3000 User-facing API and frontend hosting
webhook 8080 GitCode and GitHub event entry point

Do not expose 3000 or 8080 directly to the public internet in production. Put an nginx reverse proxy in front of them. For systemd management and the production topology, see Architecture and deployment topologies.

Equivalent startup entry points

Entry point Purpose
python -m src.api.run --dev Linux/macOS development mode
python -m src.api.run Linux/macOS production dual-process mode
python start_server.py Development mode; a simple wrapper around uvicorn --reload
.\start.ps1 Windows one-click script that creates a virtual environment, installs dependencies, runs self-checks, and starts the service

About the one-click scripts

The repository also provides quickstart.py, which creates a virtual environment, installs dependencies, prepares .env, runs self-checks, and starts the service. It is suitable for getting started quickly. This page keeps the manual steps so that each step can be checked and troubleshot independently.

Step 5: Verify the deployment

curl -f http://localhost:3000/api/health

The response is JSON such as {"server": "ok", "server_base_url": "...", ...} (see src/domains/insight/routes/health.py). HTTP 200 with server set to ok means the service is online. Open http://localhost:3000/ in a browser to see the console. The first startup automatically creates the administrator account admin; the default password and the production requirement are described in "Administrator initial password" in Step 3. Change the password immediately after the first sign-in.
Configure third-party login only if needed (see Configure third-party login); local accounts can skip this step.

Acceptance criteria

Check Command / location Pass criterion
Process pgrep -af src.api.run Development mode has one process; production mode has a parent process and two child processes, main and webhook
Port ss -lntp Development mode listens on 3000; production mode listens on 3000 and 8080
Service health curl -fs http://localhost:3000/api/health HTTP 200 with server set to ok
Console Open http://localhost:3000/ in a browser The page loads normally
Login entry Console login page The default credentials admin / admin123 work when GRAPE_ADMIN_PASSWORD is unset, and the password is changed right after signing in (production should set a strong password in Step 3 first); otherwise configured OAuth is available
Execution environment Runtime → Engines At least one engine is online; otherwise connect a Worker or install an Agent CLI

Success criteria: the process keeps running, /api/health returns 200 with server set to ok, the page opens, and at least one execution engine is online.

Common failures

Symptom Cause Action
Startup exits immediately with a Python version message Python is below 3.10 Recreate the virtual environment with a 3.10+ interpreter
pip install times out PyPI is slow pip install -r requirements-local.txt -i https://mirrors.aliyun.com/pypi/simple/
git clone cannot connect or times out GitHub is often unreachable from mainland China Use the primary address https://gitcode.com/grape-dev/grape.git, or configure a Git proxy and retry
Port 3000 is unreachable after startup The port is occupied or blocked by a firewall ss -lntp \&#124; grep 3000; allow the port in the cloud security group
The pipeline never runs No Agent CLI is installed, or it is not on the service process PATH Install opencode-ai (command opencode) or codearts-cli; run which opencode as the same user that starts the service
OAuth callback fails server_base_url is not configured, so the callback goes to localhost cp configs/server-config.example.json configs/server-config.json (the real file is not committed), then set server_base_url to a browser-reachable address in the file or admin console

Update to a new version

git pull
source .venv/bin/activate
pip install -r requirements-local.txt   # When dependencies change

Single-host SQLite mode: restart the process; migrations run at startup.

Domain databases / MySQL multi-database mode: do not restart directly. Follow the order "migrate → repair views → verify → restart" and first run
bash scripts/deploy-after-migrate.sh (do not restart if it exits nonzero). For details, see deploy/README.md.

When using systemd, the repository's deploy/systemd/ directory provides four application units (grape-server, grape-event-server,
grape-worker-server, and grape-insight-server) plus drain/reconcile units and timers for inspections.
The installation script is scripts/install-grape-systemd.sh; restart the units that are actually enabled.

Back up before upgrading; see Upgrade, backup, and rollback.