diff --git a/docker/README.md b/docker/README.md index c056cbd..087e4bd 100644 --- a/docker/README.md +++ b/docker/README.md @@ -5,7 +5,7 @@ This directory contains all Docker-related files for PowerMem Server. ## Files - `Dockerfile` - Multi-stage Docker build file for PowerMem Server -- `docker-compose.yml` - Docker Compose configuration file +- `docker-compose.yml` - Docker Compose configuration file with seekdb support - `docker-entrypoint.sh` - Container entrypoint script - `.dockerignore` - Files to exclude from Docker build context - `DOCKER.md` - Complete Docker deployment documentation @@ -20,11 +20,19 @@ From the project root directory: docker build -t oceanbase/powermem-server:latest -f docker/Dockerfile . ``` -### Run with Docker Compose +### Run with Docker Compose (with seekdb) From the project root directory: ```bash +# Without password (default) +docker-compose -f docker/docker-compose.yml up -d + +# With password (set via command line) +SEEKDB_ROOT_PASSWORD=your_password docker-compose -f docker/docker-compose.yml up -d + +# Alternatively, export the variable first +export SEEKDB_ROOT_PASSWORD=your_password docker-compose -f docker/docker-compose.yml up -d ``` @@ -41,6 +49,58 @@ docker run -d \ oceanbase/powermem-server:latest ``` +## Services + +### PowerMem Server +- Port: 8000 +- Health check: `http://localhost:8000/api/v1/system/health` +- Database: Connected to seekdb without password + +### seekdb Database +- MySQL Port: 2881 +- seekdb Web Dashboard: 2886 +- Data persistence: Docker volume `seekdb_data` +- Default database: `powermem` +- Password: Controlled by `SEEKDB_ROOT_PASSWORD` environment variable + - Not set (default): No password + - Set via command line: Use specified password + +## Connecting to seekdb + +### Without password (default) +```bash +mysql -h 127.0.0.1 -P 2881 -u root +``` + +### With password (if SEEKDB_ROOT_PASSWORD is set) +```bash +mysql -h 127.0.0.1 -P 2881 -u root -p +# Enter the password when prompted +``` + +### seekdb Web Dashboard +Open browser to: `http://localhost:2886` +- Username: `root` +- Password: Same as `SEEKDB_ROOT_PASSWORD` environment variable (not set by default) + +## Default Configuration + +The `docker-compose.yml` file includes default configuration values: + +**PowerMem Server:** +- Host: `0.0.0.0` +- Port: `8000` +- Workers: `4` +- Authentication: Disabled +- CORS: Enabled for all origins + +**seekdb:** +- Password: Controlled by `SEEKDB_ROOT_PASSWORD` environment variable (not set by default) +- CPU: 4 cores +- Memory: 4GB +- Database: `powermem` +- Data persistence: Docker volume + ## Documentation For detailed documentation, see [DOCKER.md](./DOCKER.md). @@ -50,4 +110,9 @@ For detailed documentation, see [DOCKER.md](./DOCKER.md). - All Docker commands should be run from the **project root directory**, not from the `docker/` directory - The build context is the project root, so paths in Dockerfile are relative to the project root - The `.env` file should be in the project root directory and will be mounted into the container - +- seekdb data is persisted in a Docker volume named `seekdb_data` +- On macOS with Docker version > 4.9.0, there are known issues with seekdb. Consider using an older Docker version if needed. +- **Password Management**: + - Default: No password (`SEEKDB_ROOT_PASSWORD` not set) + - To set a password: Use command line: `SEEKDB_ROOT_PASSWORD=your_password docker-compose -f docker/docker-compose.yml up -d` + - Password change: Stop services, set new password via command line, restart services \ No newline at end of file diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index a747772..67c6a69 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -1,5 +1,10 @@ version: '3.8' +networks: + powermem-network: + driver: bridge + name: powermem-network + services: powermem-server: build: @@ -22,12 +27,19 @@ services: - POWERMEM_SERVER_CORS_ENABLED=${POWERMEM_SERVER_CORS_ENABLED:-true} - POWERMEM_SERVER_CORS_ORIGINS=${POWERMEM_SERVER_CORS_ORIGINS:-*} - POWERMEM_DATABASE_URL=${POWERMEM_DATABASE_URL:-} + # Database configuration for connecting to seekdb + # Use SEEKDB_ROOT_PASSWORD variable for unified password management + - DATABASE_PROVIDER=oceanbase + - OCEANBASE_HOST=seekdb + - OCEANBASE_PORT=2881 + - OCEANBASE_USER=root@sys + - OCEANBASE_PASSWORD=${SEEKDB_ROOT_PASSWORD:-} + - OCEANBASE_DATABASE=powermem + - OCEANBASE_COLLECTION=memories env_file: - .env volumes: - ./logs:/app/logs - # Mount .env file so both SDK and Server can use the same configuration - - ./.env:/app/.env:ro restart: unless-stopped healthcheck: test: ["CMD", "curl", "-f", "http://localhost:8000/api/v1/system/health"] @@ -40,4 +52,46 @@ services: options: max-size: "10m" max-file: "3" + depends_on: + - seekdb + networks: + - powermem-network + + seekdb: + image: oceanbase/seekdb:latest + container_name: powermem-seekdb + ports: + - "2881:2881" + - "2886:2886" + environment: + # Unified password variable for both seekdb and PowerMem Server + - ROOT_PASSWORD=${SEEKDB_ROOT_PASSWORD:-} + - CPU_COUNT=4 + - MEMORY_LIMIT=4G + - LOG_DISK_SIZE=2G + - DATAFILE_SIZE=2G + - DATAFILE_NEXT=2G + - DATAFILE_MAXSIZE=50G + - SEEKDB_DATABASE=powermem + volumes: + - seekdb_data:/var/lib/oceanbase + # Mount init.sql for database initialization (optional) + # - ./init.sql:/docker-entrypoint-initdb.d/init.sql:ro + restart: unless-stopped + healthcheck: + test: ["CMD-SHELL", "if [ -z \"${SEEKDB_ROOT_PASSWORD}\" ]; then mysqladmin ping -h localhost -P 2881 -u root; else mysqladmin ping -h localhost -P 2881 -u root -p${SEEKDB_ROOT_PASSWORD}; fi"] + interval: 30s + timeout: 10s + retries: 5 + start_period: 60s + logging: + driver: "json-file" + options: + max-size: "10m" + max-file: "3" + networks: + - powermem-network + +volumes: + seekdb_data: