Skip to content

Self-evolving Context Database for AI Agents. Unify Agent Memory, Knowledge RAG and Skills.

feat(docker): init (#238)

Simon Shie4fa1f05e547
diff --git a/.github/workflows/build-docker-image.yml b/.github/workflows/build-docker-image.yml
new file mode 100644
index 000000000..cbc956aae
--- /dev/null
+++ b/.github/workflows/build-docker-image.yml
@@ -0,0 +1,65 @@
+name: Build and Push Docker Image
+
+on:
+ workflow_dispatch:
+ inputs:
+ version:
+ description: "application version for OpenViking"
+ required: true
+ type: string
+ push:
+ branches: [ "main" ]
+ tags: [ "v*.*.*" ]
+ pull_request:
+ branches: [ "main" ]
+
+env:
+ REGISTRY: ghcr.io
+ IMAGE_NAME: ${{ github.repository }}
+
+jobs:
+ build-and-push-image:
+ runs-on: ubuntu-latest
+ permissions:
+ contents: read
+ packages: write
+ attestations: write
+ id-token: write
+
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v6
+ with:
+ submodules: recursive
+
+ - name: Log in to the Container registry
+ uses: docker/login-action@v3
+ with:
+ registry: ${{ env.REGISTRY }}
+ username: ${{ github.actor }}
+ password: ${{ secrets.GITHUB_TOKEN }}
+
+ - name: Extract metadata (tags, labels) for Docker
+ id: meta
+ uses: docker/metadata-action@v5
+ with:
+ images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
+
+ - name: Set up QEMU
+ uses: docker/setup-qemu-action@v3
+
+ - name: Set up Docker Buildx
+ uses: docker/setup-buildx-action@v3
+
+ - name: Build and push Docker image
+ id: push
+ uses: docker/build-push-action@v5
+ with:
+ context: .
+ platforms: linux/amd64,linux/arm64
+ push: ${{ github.ref_type == 'tag' || github.event_name == 'workflow_dispatch' }}
+ tags: ${{ steps.meta.outputs.tags }}
+ labels: ${{ steps.meta.outputs.labels }}
+ build-args: |
+ # fallback to 0.0.0 if no version is provided
+ OPENVIKING_VERSION=${{ (github.event_name == 'workflow_dispatch' && github.event.inputs.version) || (github.ref_type == 'tag' && github.ref_name) || '0.0.0' }}
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 000000000..89d375a4f
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,59 @@
+# syntax=docker/dockerfile:1.9
+
+# Stage 1: provide Go toolchain (required by setup.py -> build_agfs -> make build)
+FROM golang:1.26-trixie AS go-toolchain
+
+# Stage 2: build Python environment with uv (builds AGFS + C++ extension from source)
+FROM ghcr.io/astral-sh/uv:python3.13-trixie-slim AS py-builder
+
+# Reuse Go toolchain from stage 1 so setup.py can compile agfs-server in-place.
+COPY --from=go-toolchain /usr/local/go /usr/local/go
+ENV PATH="/usr/local/go/bin:${PATH}"
+ARG OPENVIKING_VERSION=0.0.0
+ENV SETUPTOOLS_SCM_PRETEND_VERSION_FOR_OPENVIKING=${OPENVIKING_VERSION}
+
+RUN apt-get update && apt-get install -y --no-install-recommends \
+ build-essential \
+ cmake \
+ git \
+ && rm -rf /var/lib/apt/lists/*
+
+ENV UV_COMPILE_BYTECODE=1
+ENV UV_LINK_MODE=copy
+ENV UV_NO_DEV=1
+WORKDIR /app
+
+# Copy source required for setup.py build_agfs() and CMake extension build.
+COPY pyproject.toml uv.lock setup.py README.md ./
+COPY openviking/ openviking/
+COPY openviking_cli/ openviking_cli/
+COPY src/ src/
+COPY third_party/ third_party/
+
+# Install project and dependencies (triggers setup.py build_agfs + build_extension).
+RUN --mount=type=cache,target=/root/.cache/uv \
+ uv sync --no-editable
+
+# Stage 3: runtime
+FROM python:3.13-slim-trixie
+
+RUN apt-get update && apt-get install -y --no-install-recommends \
+ ca-certificates \
+ curl \
+ libstdc++6 \
+ && rm -rf /var/lib/apt/lists/*
+
+WORKDIR /app
+
+COPY --from=py-builder /app/.venv /app/.venv
+ENV PATH="/app/.venv/bin:$PATH"
+ENV OPENVIKING_CONFIG_FILE="/app/ov.conf"
+
+EXPOSE 1933
+
+HEALTHCHECK --interval=30s --timeout=5s --start-period=30s --retries=3 \
+ CMD curl -fsS http://127.0.0.1:1933/health || exit 1
+
+# Default runs server; override command to run CLI, e.g.:
+# docker run --rm <image> -v "$HOME/.openviking/ovcli.conf:/root/.openviking/ovcli.conf" openviking --help
+CMD ["openviking-server"]
diff --git a/docker-compose.yml b/docker-compose.yml
new file mode 100644
index 000000000..03c979a65
--- /dev/null
+++ b/docker-compose.yml
@@ -0,0 +1,22 @@
+version: "3.8"
+
+services:
+ openviking:
+ image: ghcr.io/volcengine/openviking:main
+ container_name: openviking
+ ports:
+ - "1933:1933"
+ volumes:
+ # Mount the configuration and data directory to persist state
+ - /var/lib/openviking/ov.conf:/app/ov.conf
+ - /var/lib/openviking/data:/app/data
+ healthcheck:
+ test: ["CMD-SHELL", "curl -fsS http://127.0.0.1:1933/health || exit 1"]
+ interval: 30s
+ timeout: 5s
+ retries: 3
+ start_period: 30s
+ restart: unless-stopped
+ # If you need to override the default command (which runs openviking-server),
+ # you can do so here. For example, to run the CLI:
+ # command: ["openviking", "--help"]