script: update version management

This commit is contained in:
Acbox
2026-03-07 19:18:13 +08:00
parent 99114d2521
commit 0ca3d35fa0
4 changed files with 95 additions and 112 deletions
+10 -5
View File
@@ -48,11 +48,16 @@ cd Memoh
sudo docker compose up -d sudo docker compose up -d
``` ```
> If you experience slow image pulls, use the CN override: > **Install a specific version:**
```bash > ```bash
sudo docker compose -f docker-compose.yml -f docker/docker-compose.cn.yml up -d > MEMOH_VERSION=v1.0.0 curl -fsSL https://memoh.sh | sudo sh
``` > ```
>
> **Use CN mirror for slow image pulls:**
> ```bash
> USE_CN_MIRROR=true curl -fsSL https://memoh.sh | sudo sh
> ```
>
> On macOS or if your user is in the `docker` group, `sudo` is not required. > On macOS or if your user is in the `docker` group, `sudo` is not required.
Visit <http://localhost:8082> after startup. Default login: `admin` / `admin123` Visit <http://localhost:8082> after startup. Default login: `admin` / `admin123`
+10 -5
View File
@@ -48,11 +48,16 @@ cd Memoh
sudo docker compose up -d sudo docker compose up -d
``` ```
> 若镜像拉取较慢,可使用中国大陆镜像源配置: > **安装指定版本:**
```bash > ```bash
sudo docker compose -f docker-compose.yml -f docker/docker-compose.cn.yml up -d > MEMOH_VERSION=v1.0.0 curl -fsSL https://memoh.sh | sudo sh
``` > ```
>
> **使用中国大陆镜像加速:**
> ```bash
> USE_CN_MIRROR=true curl -fsSL https://memoh.sh | sudo sh
> ```
>
> macOS 或用户已在 `docker` 用户组中时,无需 `sudo`。 > macOS 或用户已在 `docker` 用户组中时,无需 `sudo`。
启动后访问 <http://localhost:8082>。默认登录:`admin` / `admin123` 启动后访问 <http://localhost:8082>。默认登录:`admin` / `admin123`
+8 -78
View File
@@ -22,8 +22,7 @@ The script will:
2. Prompt for configuration (workspace, data directory, admin credentials, JWT secret, Postgres password, China mirror) 2. Prompt for configuration (workspace, data directory, admin credentials, JWT secret, Postgres password, China mirror)
3. Clone the repository 3. Clone the repository
4. Generate `config.toml` from the Docker template with your settings 4. Generate `config.toml` from the Docker template with your settings
5. Write a `.env` file with `POSTGRES_PASSWORD` and `MEMOH_CONFIG` 5. Pull images and start all services
6. Pull images and start all services
**Silent install** (use all defaults, no prompts): **Silent install** (use all defaults, no prompts):
@@ -42,7 +41,7 @@ Defaults when running silently:
## Manual Install ## Manual Install
```bash ```bash
git clone --depth 1 https://github.com/memohai/Memoh.git git clone https://github.com/memohai/Memoh.git
cd Memoh cd Memoh
cp conf/app.docker.toml config.toml cp conf/app.docker.toml config.toml
``` ```
@@ -51,7 +50,7 @@ Edit `config.toml` — at minimum change:
- `admin.password` — Admin password - `admin.password` — Admin password
- `auth.jwt_secret` — Generate with `openssl rand -base64 32` - `auth.jwt_secret` — Generate with `openssl rand -base64 32`
- `postgres.password` — Database password (must match the `POSTGRES_PASSWORD` env var) - `postgres.password` — Database password (also set `POSTGRES_PASSWORD` env var to match)
Then start: Then start:
@@ -59,22 +58,9 @@ Then start:
sudo POSTGRES_PASSWORD=your-db-password docker compose up -d sudo POSTGRES_PASSWORD=your-db-password docker compose up -d
``` ```
Alternatively, create a `.env` file in the project root:
```env
POSTGRES_PASSWORD=your-db-password
MEMOH_CONFIG=./config.toml
```
Then simply run:
```bash
sudo docker compose up -d
```
> On macOS or if your user is in the `docker` group, `sudo` is not required. > On macOS or if your user is in the `docker` group, `sudo` is not required.
> **Important**: `docker-compose.yml` mounts `${MEMOH_CONFIG:-./config.toml}` into the containers. You must create this file before starting — running without it will fail. > **Important**: `docker-compose.yml` mounts `./config.toml` by default. You must create this file before starting — running without it will fail.
### China Mainland Mirror ### China Mainland Mirror
@@ -93,21 +79,6 @@ sudo docker compose -f docker-compose.yml -f docker/docker-compose.cn.yml up -d
The install script handles this automatically when you answer "yes" to the China mirror prompt. The install script handles this automatically when you answer "yes" to the China mirror prompt.
## Service Architecture
Docker Compose starts the following services:
| Service | Image | Description |
|------------|-----------------------------|-----------------------------------------------------------------------------|
| `postgres` | `postgres:18-alpine` | PostgreSQL database |
| `qdrant` | `qdrant/qdrant:latest` | Qdrant vector database for memory semantic search |
| `migrate` | `memohai/server:latest` | One-shot service — runs database migrations, then exits |
| `server` | `memohai/server:latest` | Main backend with embedded Containerd (privileged) |
| `agent` | `memohai/agent:latest` | Agent Gateway (Bun/Elysia) for AI chat, tool execution, and SSE streaming |
| `web` | `memohai/web:latest` | Web UI (Vue 3 + Nginx) |
Startup order: `postgres` and `qdrant` start first; once healthy, `migrate` runs database migrations; after migration completes, `server` starts; finally `agent` and `web` come up.
## Access Points ## Access Points
After startup: After startup:
@@ -122,24 +93,6 @@ Default login: `admin` / `admin123` (change this in `config.toml`).
First startup may take 12 minutes while images are pulled and services initialize. First startup may take 12 minutes while images are pulled and services initialize.
## Data Persistence
All persistent data is stored in Docker named volumes:
| Volume | Description |
|---------------------|------------------------------------------|
| `postgres_data` | PostgreSQL database files |
| `qdrant_data` | Qdrant vector storage |
| `containerd_data` | Containerd image store and snapshots |
| `memoh_data` | Bot container data (mounted at `/opt/memoh/data` inside the server) |
| `server_cni_state` | CNI network state for container networking |
These volumes survive `docker compose down`. To fully reset all data, run:
```bash
docker compose down -v
```
## Common Commands ## Common Commands
> Prefix with `sudo` on Linux if your user is not in the `docker` group. > Prefix with `sudo` on Linux if your user is not in the `docker` group.
@@ -148,51 +101,28 @@ docker compose down -v
docker compose up -d # Start docker compose up -d # Start
docker compose down # Stop docker compose down # Stop
docker compose logs -f # View logs docker compose logs -f # View logs
docker compose logs server # View a specific service's logs
docker compose ps # Status docker compose ps # Status
docker compose pull && docker compose up -d # Update to latest images docker compose pull && docker compose up -d # Update to latest images
``` ```
## Upgrading
To upgrade to the latest version:
```bash
cd /path/to/Memoh
git pull
docker compose pull
docker compose up -d
```
The `migrate` service runs automatically on every startup, applying any new database migrations.
## Environment Variables
| Variable | Default | Description |
|--------------------|------------------|----------------------------------------------|
| `POSTGRES_PASSWORD`| `memoh123` | PostgreSQL password (must match `postgres.password` in `config.toml`) |
| `MEMOH_CONFIG` | `./config.toml` | Path to the configuration file |
## Production Checklist ## Production Checklist
1. **Passwords** — Change all default passwords and secrets in `config.toml` 1. **Passwords** — Change all default passwords and secrets in `config.toml`
2. **HTTPS** — Configure SSL (e.g. via `docker-compose.override.yml` with certs or a reverse proxy) 2. **HTTPS** — Configure SSL (e.g. via `docker-compose.override.yml` with certs or a reverse proxy)
3. **Firewall** — Restrict access to necessary ports 3. **Firewall** — Restrict access to necessary ports
4. **Resource limits** — Set memory/CPU limits for containers 4. **Resource limits** — Set memory/CPU limits for containers
5. **Backups** — Regular backups of Postgres and Qdrant data volumes 5. **Backups** — Regular backups of Postgres and Qdrant data
## Troubleshooting ## Troubleshooting
```bash ```bash
docker compose logs server # View main service logs docker compose logs server # View main service logs
docker compose logs migrate # Check if migrations succeeded docker compose config # Validate configuration
docker compose config # Validate compose configuration docker compose build --no-cache && docker compose up -d # Full rebuild
docker compose down && docker compose up -d # Full restart
``` ```
## Security Warnings ## Security Warnings
- The main service runs with privileged container access (required for embedded Containerd) — only run in trusted environments - The main service runs with privileged container access — only run in trusted environments
- You must change all default passwords and secrets before production use - You must change all default passwords and secrets before production use
- Use HTTPS in production - Use HTTPS in production
+66 -23
View File
@@ -3,10 +3,12 @@ set -e
GREEN='\033[0;32m' GREEN='\033[0;32m'
YELLOW='\033[1;33m' YELLOW='\033[1;33m'
PURPLE='\033[0;35m'
RED='\033[0;31m' RED='\033[0;31m'
NC='\033[0m' NC='\033[0m'
REPO="https://github.com/memohai/Memoh.git" GITHUB_REPO="memohai/Memoh"
REPO="https://github.com/${GITHUB_REPO}.git"
DIR="Memoh" DIR="Memoh"
SILENT=false SILENT=false
@@ -22,10 +24,7 @@ if [ "$SILENT" = false ] && ! [ -e /dev/tty ]; then
SILENT=true SILENT=true
fi fi
echo "${GREEN}========================================${NC}" echo "${PURPLE}Memoh One-Click Install${NC}"
echo "${GREEN} Memoh One-Click Install${NC}"
echo "${GREEN}========================================${NC}"
echo ""
# Check Docker and determine if sudo is needed # Check Docker and determine if sudo is needed
DOCKER="docker" DOCKER="docker"
@@ -49,10 +48,38 @@ if ! $DOCKER compose version >/dev/null 2>&1; then
exit 1 exit 1
fi fi
echo "${GREEN}✓ Docker and Docker Compose detected${NC}" echo "${GREEN}✓ Docker and Docker Compose detected${NC}"
echo ""
echo "${GREEN}✓ Install mode: latest Docker images${NC}" # Resolve version: use MEMOH_VERSION env if set, otherwise fetch latest release
echo "" VERSION_USER_PROVIDED=false
if [ -n "$MEMOH_VERSION" ]; then
VERSION_USER_PROVIDED=true
echo "${GREEN}✓ Using specified version: ${MEMOH_VERSION}${NC}"
else
fetch_latest_version() {
if command -v curl >/dev/null 2>&1; then
curl -fsSL "https://api.github.com/repos/${GITHUB_REPO}/releases/latest" 2>/dev/null
elif command -v wget >/dev/null 2>&1; then
wget -qO- "https://api.github.com/repos/${GITHUB_REPO}/releases/latest" 2>/dev/null
else
echo "${RED}Error: curl or wget is required${NC}" >&2
exit 1
fi
}
MEMOH_VERSION=$(fetch_latest_version | grep '"tag_name"' | sed 's/.*"tag_name": *"\([^"]*\)".*/\1/')
if [ -n "$MEMOH_VERSION" ]; then
echo "${GREEN}✓ Latest release: ${MEMOH_VERSION}${NC}"
else
echo "${YELLOW}Warning: Failed to fetch latest release tag, falling back to main branch${NC}"
fi
fi
# Docker image tag: pin to version only when user explicitly specified MEMOH_VERSION
if [ "$VERSION_USER_PROVIDED" = true ]; then
MEMOH_DOCKER_VERSION=$(echo "$MEMOH_VERSION" | sed 's/^v//')
else
MEMOH_DOCKER_VERSION="latest"
fi
echo "${GREEN}✓ Docker image version: ${MEMOH_DOCKER_VERSION}${NC}"
# Generate random JWT secret # Generate random JWT secret
gen_secret() { gen_secret() {
@@ -129,21 +156,38 @@ fi
mkdir -p "$WORKSPACE" mkdir -p "$WORKSPACE"
cd "$WORKSPACE" cd "$WORKSPACE"
# Clone repository or update local checkout # Clone or update
if [ -d "$DIR" ]; then if [ -d "$DIR" ]; then
echo "Updating existing installation in $WORKSPACE..." echo "Updating existing installation in $WORKSPACE..."
cd "$DIR" cd "$DIR"
DEFAULT_BRANCH=$(git symbolic-ref --quiet --short refs/remotes/origin/HEAD 2>/dev/null | sed 's@^origin/@@') if [ -n "$MEMOH_VERSION" ]; then
[ -z "$DEFAULT_BRANCH" ] && DEFAULT_BRANCH="main" git fetch --depth 1 origin tag "$MEMOH_VERSION"
git fetch --depth 1 origin "$DEFAULT_BRANCH" 2>/dev/null || git fetch --depth 1 origin git checkout "$MEMOH_VERSION"
git checkout "$DEFAULT_BRANCH" 2>/dev/null || git checkout -b "$DEFAULT_BRANCH" --track "origin/$DEFAULT_BRANCH" else
git pull --ff-only origin "$DEFAULT_BRANCH" git fetch --depth 1 origin main
git checkout main 2>/dev/null || git checkout -b main --track origin/main
git reset --hard origin/main
fi
else else
echo "Cloning Memoh into $WORKSPACE..." echo "Cloning Memoh into $WORKSPACE..."
if [ -n "$MEMOH_VERSION" ]; then
git clone --depth 1 --branch "$MEMOH_VERSION" "$REPO" "$DIR"
else
git clone --depth 1 "$REPO" "$DIR" git clone --depth 1 "$REPO" "$DIR"
fi
cd "$DIR" cd "$DIR"
fi fi
# Pin Docker image versions in docker-compose.yml
if [ "$MEMOH_DOCKER_VERSION" != "latest" ]; then
sed -i.bak "s|memohai/server:latest|memohai/server:${MEMOH_DOCKER_VERSION}|g" docker-compose.yml
sed -i.bak "s|memohai/agent:latest|memohai/agent:${MEMOH_DOCKER_VERSION}|g" docker-compose.yml
sed -i.bak "s|memohai/web:latest|memohai/web:${MEMOH_DOCKER_VERSION}|g" docker-compose.yml
sed -i.bak "s|memohai/browser:latest|memohai/browser:${MEMOH_DOCKER_VERSION}|g" docker-compose.yml
rm -f docker-compose.yml.bak
echo "${GREEN}✓ Docker images pinned to ${MEMOH_DOCKER_VERSION}${NC}"
fi
# Generate config.toml from template # Generate config.toml from template
cp conf/app.docker.toml config.toml cp conf/app.docker.toml config.toml
sed -i.bak "s|username = \"admin\"|username = \"${ADMIN_USER}\"|" config.toml sed -i.bak "s|username = \"admin\"|username = \"${ADMIN_USER}\"|" config.toml
@@ -181,20 +225,19 @@ echo "${GREEN}Starting services (first startup may take a few minutes)...${NC}"
$DOCKER compose $COMPOSE_FILES up -d $DOCKER compose $COMPOSE_FILES up -d
echo "" echo ""
echo "${GREEN}========================================${NC}" echo "${GREEN}✅ Memoh is running!${NC}${NC}"
echo "${GREEN} Memoh is running!${NC}"
echo "${GREEN}========================================${NC}"
echo "" echo ""
echo " Web UI: http://localhost:8082" echo " 🌐 Web UI: http://localhost:8082"
echo " API: http://localhost:8080" echo " 🔌 API: http://localhost:8080"
echo " Agent Gateway: http://localhost:8081" echo " 🤖 Agent Gateway: http://localhost:8081"
echo " 🌍 Browser Gateway: http://localhost:8083"
echo "" echo ""
echo " Admin login: ${ADMIN_USER} / ${ADMIN_PASS}" echo " 🔑 Admin login: ${ADMIN_USER} / ${ADMIN_PASS}"
echo "" echo ""
COMPOSE_CMD="$DOCKER compose $COMPOSE_FILES" COMPOSE_CMD="$DOCKER compose $COMPOSE_FILES"
echo "Commands:" echo "📋 Commands:"
echo " cd ${INSTALL_DIR} && ${COMPOSE_CMD} ps # Status" echo " cd ${INSTALL_DIR} && ${COMPOSE_CMD} ps # Status"
echo " cd ${INSTALL_DIR} && ${COMPOSE_CMD} logs -f # Logs" echo " cd ${INSTALL_DIR} && ${COMPOSE_CMD} logs -f # Logs"
echo " cd ${INSTALL_DIR} && ${COMPOSE_CMD} down # Stop" echo " cd ${INSTALL_DIR} && ${COMPOSE_CMD} down # Stop"
echo "" echo ""
echo "${YELLOW}First startup may take 1-2 minutes, please be patient.${NC}" echo "${YELLOW}First startup may take 1-2 minutes, please be patient.${NC}"