chore: import upstream snapshot with attribution
This commit is contained in:
@@ -0,0 +1,82 @@
|
||||
# Docker Images for Memvid
|
||||
|
||||
This directory contains Docker configurations for Memvid components.
|
||||
|
||||
## Available Images
|
||||
|
||||
### Memvid Core (`core/`)
|
||||
|
||||
The Memvid Core Docker images provide containerized Rust development, testing, and build environments for the `memvid-core` library.
|
||||
|
||||
**Quick Start:**
|
||||
```bash
|
||||
# Development environment
|
||||
cd core
|
||||
docker-compose up -d dev
|
||||
docker-compose exec dev bash
|
||||
|
||||
# Run tests
|
||||
docker-compose run --rm test
|
||||
|
||||
# Build release
|
||||
docker-compose run --rm build
|
||||
```
|
||||
|
||||
For detailed usage, see [core/README.md](core/README.md).
|
||||
|
||||
### Memvid CLI (`cli/`)
|
||||
|
||||
The Memvid CLI Docker image provides a containerized version of the `memvid-cli` tool, allowing you to run Memvid commands without installing Node.js or dealing with platform-specific binaries.
|
||||
|
||||
**Quick Start:**
|
||||
|
||||
```bash
|
||||
# Pull the image
|
||||
docker pull memvid/cli
|
||||
|
||||
# Create a memory
|
||||
docker run --rm -v $(pwd):/data memvid/cli create my-memory.mv2
|
||||
|
||||
# Add documents
|
||||
docker run --rm -v $(pwd):/data memvid/cli put my-memory.mv2 --input doc.pdf
|
||||
|
||||
# Search
|
||||
docker run --rm -v $(pwd):/data memvid/cli find my-memory.mv2 --query "search"
|
||||
```
|
||||
|
||||
For detailed usage instructions, examples, and Docker Compose configurations, see [cli/README.md](cli/README.md).
|
||||
|
||||
## Building Images
|
||||
|
||||
### Build CLI Image Locally
|
||||
|
||||
```bash
|
||||
cd cli
|
||||
docker build -t memvid/cli:test .
|
||||
```
|
||||
|
||||
## Publishing
|
||||
|
||||
Docker images are automatically built and published to Docker Hub via GitHub Actions when tags are pushed. See `.github/workflows/docker-release.yml` for the CI/CD configuration.
|
||||
|
||||
**Image Registry:**
|
||||
- Docker Hub: `memvid/cli`
|
||||
- Tags: `latest`, `2.0.129`, and version-specific tags
|
||||
|
||||
## Architecture Support
|
||||
|
||||
The CLI image supports multi-architecture builds:
|
||||
- `linux/amd64`
|
||||
- `linux/arm64`
|
||||
|
||||
## Security
|
||||
|
||||
The CLI image runs as a non-root user (`memvid`) for improved security. When mounting volumes, ensure your host directories have appropriate permissions.
|
||||
|
||||
## Links
|
||||
|
||||
- [Core Documentation](core/README.md)
|
||||
- [CLI Documentation](cli/README.md)
|
||||
- [CLI Testing Guide](cli/TESTING.md)
|
||||
- [Main Project README](../README.md)
|
||||
- [Memvid Documentation](https://docs.memvid.com)
|
||||
@@ -0,0 +1,7 @@
|
||||
node_modules
|
||||
npm-debug.log
|
||||
.git
|
||||
.gitignore
|
||||
*.md
|
||||
.env
|
||||
.DS_Store
|
||||
@@ -0,0 +1,33 @@
|
||||
# Memvid CLI Docker Image
|
||||
FROM ubuntu:24.04
|
||||
|
||||
LABEL org.opencontainers.image.title="Memvid CLI"
|
||||
LABEL org.opencontainers.image.description="AI memory CLI with semantic search"
|
||||
LABEL org.opencontainers.image.url="https://memvid.com"
|
||||
LABEL org.opencontainers.image.source="https://github.com/memvid/memvid"
|
||||
LABEL org.opencontainers.image.vendor="Memvid"
|
||||
LABEL org.opencontainers.image.version="2.0.131"
|
||||
|
||||
# Install system deps + Node.js 24
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
ca-certificates \
|
||||
curl \
|
||||
libssl3 \
|
||||
&& curl -fsSL https://deb.nodesource.com/setup_24.x | bash - \
|
||||
&& apt-get install -y --no-install-recommends nodejs \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Install memvid CLI (pinned version)
|
||||
RUN npm install -g memvid-cli@latest \
|
||||
&& npm cache clean --force
|
||||
|
||||
# Create non-root user (recommended)
|
||||
RUN useradd -m memvid
|
||||
USER memvid
|
||||
|
||||
# Working directory for memory files
|
||||
WORKDIR /data
|
||||
|
||||
# Entrypoint
|
||||
ENTRYPOINT ["memvid"]
|
||||
CMD ["--help"]
|
||||
@@ -0,0 +1,101 @@
|
||||
# Memvid CLI Docker Image
|
||||
|
||||
AI memory CLI with crash-safe, single-file storage and semantic search.
|
||||
|
||||
## Quick Start
|
||||
|
||||
```bash
|
||||
# Pull the image
|
||||
docker pull memvid/cli
|
||||
|
||||
# Create a memory
|
||||
docker run --rm -v $(pwd):/data memvid/cli create my-memory.mv2
|
||||
|
||||
# Add documents
|
||||
docker run --rm -v $(pwd):/data memvid/cli put my-memory.mv2 --input doc.pdf
|
||||
|
||||
# Search
|
||||
docker run --rm -v $(pwd):/data memvid/cli find my-memory.mv2 --query "search"
|
||||
```
|
||||
|
||||
## Basic Commands
|
||||
|
||||
```bash
|
||||
# Show help
|
||||
docker run --rm memvid/cli
|
||||
|
||||
# Show version
|
||||
docker run --rm memvid/cli --version
|
||||
|
||||
# Create a memory file (mount local directory)
|
||||
docker run --rm -v $(pwd):/data memvid/cli create my-memory.mv2
|
||||
|
||||
# Ingest a document
|
||||
docker run --rm -v $(pwd):/data memvid/cli put my-memory.mv2 --input document.pdf
|
||||
|
||||
# Search the memory
|
||||
docker run --rm -v $(pwd):/data memvid/cli find my-memory.mv2 --query "search term"
|
||||
|
||||
# Ask questions (requires API key for LLM)
|
||||
docker run --rm -v $(pwd):/data \
|
||||
-e OPENAI_API_KEY="sk-..." \
|
||||
memvid/cli ask my-memory.mv2 "What is this about?" -m openai
|
||||
|
||||
# View stats
|
||||
docker run --rm -v $(pwd):/data memvid/cli stats my-memory.mv2
|
||||
```
|
||||
|
||||
## With API Keys
|
||||
|
||||
```bash
|
||||
# Pass Memvid API key for cloud features
|
||||
docker run --rm -v $(pwd):/data \
|
||||
-e MEMVID_API_KEY="mv2_..." \
|
||||
-e OPENAI_API_KEY="sk-..." \
|
||||
memvid/cli ask my-memory.mv2 "your question"
|
||||
```
|
||||
|
||||
## Shell Alias (Recommended)
|
||||
|
||||
Add to `~/.bashrc` or `~/.zshrc`:
|
||||
|
||||
```bash
|
||||
alias memvid='docker run --rm -v $(pwd):/data -e MEMVID_API_KEY -e OPENAI_API_KEY memvid/cli'
|
||||
```
|
||||
|
||||
Then use normally:
|
||||
|
||||
```bash
|
||||
memvid create my-memory.mv2
|
||||
memvid put my-memory.mv2 --input docs/
|
||||
memvid find my-memory.mv2 --query "hello"
|
||||
```
|
||||
|
||||
## Docker Compose Example
|
||||
|
||||
```yaml
|
||||
version: '3.8'
|
||||
services:
|
||||
memvid:
|
||||
image: memvid/cli:latest
|
||||
volumes:
|
||||
- ./data:/data
|
||||
environment:
|
||||
- MEMVID_API_KEY=${MEMVID_API_KEY}
|
||||
- OPENAI_API_KEY=${OPENAI_API_KEY}
|
||||
entrypoint: ["memvid"]
|
||||
command: ["stats", "my-memory.mv2"]
|
||||
```
|
||||
|
||||
## Features
|
||||
|
||||
- Single-file `.mv2` storage
|
||||
- Semantic + lexical search
|
||||
- RAG question answering
|
||||
- PDF, DOCX, images, audio support
|
||||
|
||||
## Links
|
||||
|
||||
- Website: https://memvid.com
|
||||
- Docs: https://docs.memvid.com
|
||||
- GitHub: https://github.com/memvid/memvid
|
||||
@@ -0,0 +1,108 @@
|
||||
# Testing Memvid CLI Docker Image
|
||||
|
||||
## Quick Test
|
||||
|
||||
### 1. Build the Image
|
||||
|
||||
```bash
|
||||
cd docker/cli
|
||||
docker build -t memvid/cli:test .
|
||||
```
|
||||
|
||||
### 2. Test Basic Commands
|
||||
|
||||
```bash
|
||||
# Test help command
|
||||
docker run --rm memvid/cli:test --help
|
||||
|
||||
# Test version (if available)
|
||||
docker run --rm memvid/cli:test --version
|
||||
```
|
||||
|
||||
### 3. Test with Volume Mount
|
||||
|
||||
```bash
|
||||
# Create a test directory
|
||||
mkdir -p /tmp/memvid-test
|
||||
cd /tmp/memvid-test
|
||||
|
||||
# Create a test document
|
||||
echo "This is a test document about AI and machine learning." > test.txt
|
||||
|
||||
# Create a memory file
|
||||
docker run --rm \
|
||||
-v $(pwd):/data \
|
||||
memvid/cli:test create test-memory.mv2
|
||||
|
||||
# Add the document
|
||||
docker run --rm \
|
||||
-v $(pwd):/data \
|
||||
memvid/cli:test put test-memory.mv2 --input test.txt
|
||||
|
||||
# Search the memory
|
||||
docker run --rm \
|
||||
-v $(pwd):/data \
|
||||
memvid/cli:test find test-memory.mv2 --query "AI"
|
||||
|
||||
# View stats
|
||||
docker run --rm \
|
||||
-v $(pwd):/data \
|
||||
memvid/cli:test stats test-memory.mv2
|
||||
```
|
||||
|
||||
### 4. Test with API Keys (if needed)
|
||||
|
||||
```bash
|
||||
docker run --rm \
|
||||
-v $(pwd):/data \
|
||||
-e OPENAI_API_KEY="sk-..." \
|
||||
memvid/cli:test ask test-memory.mv2 "What is this about?" -m openai
|
||||
```
|
||||
|
||||
## Automated Testing
|
||||
|
||||
Run the test script:
|
||||
|
||||
```bash
|
||||
cd docker/cli
|
||||
./test.sh
|
||||
```
|
||||
|
||||
## Multi-Architecture Testing
|
||||
|
||||
To test multi-arch builds locally (requires buildx):
|
||||
|
||||
```bash
|
||||
# Create builder
|
||||
docker buildx create --name memvid-builder --use
|
||||
|
||||
# Build for specific platform
|
||||
docker buildx build \
|
||||
--platform linux/amd64 \
|
||||
--tag memvid/cli:test-amd64 \
|
||||
--load \
|
||||
.
|
||||
|
||||
# Test the amd64 image
|
||||
docker run --rm memvid/cli:test-amd64 --help
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Image not found
|
||||
Make sure you've built the image:
|
||||
```bash
|
||||
docker build -t memvid/cli:test docker/cli
|
||||
```
|
||||
|
||||
### Permission errors
|
||||
Ensure Docker has permission to access the mounted directory:
|
||||
```bash
|
||||
chmod 755 /path/to/your/directory
|
||||
```
|
||||
|
||||
### CLI not found
|
||||
Verify the npm package exists:
|
||||
```bash
|
||||
docker run --rm memvid/cli:test which memvid
|
||||
```
|
||||
Executable
+44
@@ -0,0 +1,44 @@
|
||||
#!/bin/bash
|
||||
# Test script for Memvid CLI Docker image
|
||||
|
||||
set -e
|
||||
|
||||
IMAGE_NAME="memvid/cli:test"
|
||||
DOCKERFILE_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
|
||||
echo "🐳 Building Docker image..."
|
||||
docker build -t "$IMAGE_NAME" "$DOCKERFILE_DIR"
|
||||
|
||||
echo ""
|
||||
echo "✅ Build complete! Testing basic commands..."
|
||||
echo ""
|
||||
|
||||
echo "1️⃣ Testing help command..."
|
||||
docker run --rm "$IMAGE_NAME" --help | head -5
|
||||
|
||||
echo ""
|
||||
echo "2️⃣ Testing version command..."
|
||||
docker run --rm "$IMAGE_NAME" --version || echo "Version command not available"
|
||||
|
||||
echo ""
|
||||
echo "3️⃣ Testing with volume mount (create test memory)..."
|
||||
TEST_DIR=$(mktemp -d)
|
||||
cd "$TEST_DIR"
|
||||
|
||||
# Create a test document
|
||||
echo "This is a test document about artificial intelligence and machine learning." > test.txt
|
||||
|
||||
docker run --rm \
|
||||
-v "$TEST_DIR":/data \
|
||||
"$IMAGE_NAME" create test-memory.mv2 || echo "Create command may require additional setup"
|
||||
|
||||
echo ""
|
||||
echo "🧹 Cleaning up test directory..."
|
||||
rm -rf "$TEST_DIR"
|
||||
|
||||
echo ""
|
||||
echo "✅ Basic tests complete!"
|
||||
echo ""
|
||||
echo "To test manually, run:"
|
||||
echo " docker run --rm $IMAGE_NAME --help"
|
||||
echo " docker run --rm -v \$(pwd):/data $IMAGE_NAME create my-memory.mv2"
|
||||
@@ -0,0 +1,215 @@
|
||||
# Docker Setup for Memvid Core
|
||||
|
||||
This document describes how to use Docker with the Memvid Core Rust library.
|
||||
|
||||
## Quick Start
|
||||
|
||||
### Development Environment
|
||||
|
||||
```bash
|
||||
# From project root or docker/core directory
|
||||
cd docker/core
|
||||
docker-compose up -d dev
|
||||
|
||||
# Enter the container
|
||||
docker-compose exec dev bash
|
||||
|
||||
# Inside container, you can run:
|
||||
cargo build
|
||||
cargo test
|
||||
cargo run --example basic_usage
|
||||
```
|
||||
|
||||
### Run Tests
|
||||
|
||||
```bash
|
||||
# Run all tests
|
||||
cd docker/core
|
||||
docker-compose run --rm test
|
||||
|
||||
# Or build test image manually (from project root)
|
||||
docker build -f docker/core/Dockerfile.test -t memvid-test .
|
||||
docker run --rm memvid-test
|
||||
```
|
||||
|
||||
### Build Release
|
||||
|
||||
```bash
|
||||
# Build release version
|
||||
cd docker/core
|
||||
docker-compose run --rm build
|
||||
|
||||
# Or build manually (from project root)
|
||||
docker build -f docker/core/Dockerfile -t memvid-core:latest .
|
||||
```
|
||||
|
||||
## Docker Images
|
||||
|
||||
### 1. Development Image (`Dockerfile.dev`)
|
||||
|
||||
Full development environment with all tools:
|
||||
|
||||
```bash
|
||||
# From project root
|
||||
docker build -f docker/core/Dockerfile.dev -t memvid-dev .
|
||||
docker run -it --rm -v $(pwd):/app memvid-dev bash
|
||||
```
|
||||
|
||||
**Features:**
|
||||
- Rust toolchain 1.92
|
||||
- All build dependencies
|
||||
- Cargo watch (optional)
|
||||
- Volume mounting for live development
|
||||
|
||||
### 2. Test Image (`Dockerfile.test`)
|
||||
|
||||
Optimized for running tests:
|
||||
|
||||
```bash
|
||||
# From project root
|
||||
docker build -f docker/core/Dockerfile.test -t memvid-test .
|
||||
docker run --rm memvid-test
|
||||
```
|
||||
|
||||
**Features:**
|
||||
- Rust toolchain 1.92
|
||||
- Test dependencies
|
||||
- Runs tests automatically
|
||||
|
||||
### 3. Production Build (`Dockerfile`)
|
||||
|
||||
Multi-stage build for optimized production image:
|
||||
|
||||
```bash
|
||||
# From project root
|
||||
docker build -f docker/core/Dockerfile -t memvid-core:latest .
|
||||
```
|
||||
|
||||
**Features:**
|
||||
- Multi-stage build (smaller final image)
|
||||
- Only runtime dependencies
|
||||
- Optimized release build
|
||||
|
||||
## Docker Compose
|
||||
|
||||
### Services
|
||||
|
||||
- **`dev`** - Development environment with live code mounting
|
||||
- **`test`** - Test runner
|
||||
- **`build`** - Release builder
|
||||
|
||||
### Usage
|
||||
|
||||
```bash
|
||||
# Start development environment
|
||||
docker-compose up -d dev
|
||||
|
||||
# Run tests
|
||||
docker-compose run --rm test
|
||||
|
||||
# Build release
|
||||
docker-compose run --rm build
|
||||
|
||||
# Stop all services
|
||||
docker-compose down
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
### Run Examples in Docker
|
||||
|
||||
```bash
|
||||
# Development container
|
||||
docker-compose exec dev cargo run --example basic_usage
|
||||
|
||||
# With features
|
||||
docker-compose exec dev cargo run --example pdf_ingestion --features lex,pdf_extract
|
||||
```
|
||||
|
||||
### Memory-Constrained Testing
|
||||
|
||||
Test OOM prevention with memory limits:
|
||||
|
||||
```bash
|
||||
# Test with memory limit (for OOM testing)
|
||||
docker run --rm --memory=150m --memory-swap=150m \
|
||||
-v $(pwd):/app \
|
||||
memvid-test cargo test --features encryption --test encryption_capsule
|
||||
```
|
||||
|
||||
### Build with Specific Features
|
||||
|
||||
```bash
|
||||
# Build with all features
|
||||
docker-compose exec dev cargo build --release --all-features
|
||||
|
||||
# Build with specific features
|
||||
docker-compose exec dev cargo build --release --features lex,vec,encryption
|
||||
```
|
||||
|
||||
## Volume Mounts
|
||||
|
||||
The docker-compose setup uses volumes for:
|
||||
- **Source code** - Live mounting for development
|
||||
- **Cargo cache** - Speeds up builds
|
||||
- **Target cache** - Preserves build artifacts
|
||||
|
||||
## CI/CD Integration
|
||||
|
||||
### GitHub Actions Example
|
||||
|
||||
```yaml
|
||||
name: Docker Build
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Build Docker image
|
||||
run: docker build -t memvid-core:test .
|
||||
- name: Run tests
|
||||
run: docker run --rm memvid-core:test cargo test
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Build Fails
|
||||
|
||||
```bash
|
||||
# Clean build
|
||||
docker-compose down -v
|
||||
docker-compose build --no-cache
|
||||
```
|
||||
|
||||
### Permission Issues
|
||||
|
||||
```bash
|
||||
# Fix permissions
|
||||
sudo chown -R $USER:$USER .
|
||||
```
|
||||
|
||||
### Out of Memory
|
||||
|
||||
```bash
|
||||
# Increase Docker memory limit in Docker Desktop settings
|
||||
# Or use memory limits in docker run:
|
||||
docker run --memory=2g --memory-swap=2g ...
|
||||
```
|
||||
|
||||
## Best Practices
|
||||
|
||||
1. **Use docker-compose** for development
|
||||
2. **Cache volumes** for faster builds
|
||||
3. **Multi-stage builds** for production
|
||||
4. **Test in containers** to match CI/CD environment
|
||||
5. **Use .dockerignore** to exclude unnecessary files
|
||||
|
||||
## Related
|
||||
|
||||
- [CLI Docker Setup](../cli/README.md)
|
||||
- [Docker Overview](../README.md)
|
||||
- [Main Project README](../../README.md)
|
||||
- [Contributing Guide](../../CONTRIBUTING.md)
|
||||
@@ -0,0 +1,53 @@
|
||||
# Multi-stage Dockerfile for Memvid Core (Rust Library)
|
||||
# Build stage
|
||||
FROM rust:1.92-slim-trixie AS builder
|
||||
|
||||
# Install build dependencies
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
pkg-config \
|
||||
libssl-dev \
|
||||
ca-certificates \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy dependency files first for better caching
|
||||
COPY Cargo.toml Cargo.lock ./
|
||||
COPY rust-toolchain.toml ./
|
||||
|
||||
# Create a dummy src/lib.rs to build dependencies
|
||||
RUN mkdir -p src && \
|
||||
echo "// Dummy file for dependency building" > src/lib.rs && \
|
||||
cargo build --release --features lex,pdf_extract && \
|
||||
rm -rf src
|
||||
|
||||
# Copy source code
|
||||
COPY src ./src
|
||||
COPY examples ./examples
|
||||
COPY tests ./tests
|
||||
|
||||
# Build the library with default features
|
||||
RUN cargo build --release --features lex,pdf_extract
|
||||
|
||||
# Runtime stage - minimal image for running examples/tests
|
||||
FROM debian:trixie-slim AS runtime
|
||||
|
||||
# Install runtime dependencies
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
ca-certificates \
|
||||
libssl3 \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy the built artifacts from builder
|
||||
COPY --from=builder /app/target/release/examples ./examples
|
||||
COPY --from=builder /app/target/release/deps ./deps
|
||||
COPY --from=builder /app/target/release/libmemvid_core*.rlib ./lib/
|
||||
|
||||
# Set environment variables
|
||||
ENV RUST_LOG=info
|
||||
ENV PATH="/app/examples:${PATH}"
|
||||
|
||||
# Default command
|
||||
CMD ["/bin/bash"]
|
||||
@@ -0,0 +1,31 @@
|
||||
# Development Dockerfile for Memvid Core
|
||||
FROM rust:1.92-slim-trixie AS builder
|
||||
|
||||
# Install development dependencies
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
pkg-config \
|
||||
libssl-dev \
|
||||
ca-certificates \
|
||||
git \
|
||||
curl \
|
||||
build-essential \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy dependency files
|
||||
COPY Cargo.toml Cargo.lock ./
|
||||
COPY rust-toolchain.toml ./
|
||||
|
||||
# Install cargo-watch for development (optional)
|
||||
RUN cargo install cargo-watch --locked || true
|
||||
|
||||
# Copy source code
|
||||
COPY . .
|
||||
|
||||
# Set environment variables
|
||||
ENV RUST_LOG=debug
|
||||
ENV CARGO_TARGET_DIR=/app/target
|
||||
|
||||
# Default command (can be overridden)
|
||||
CMD ["/bin/bash"]
|
||||
@@ -0,0 +1,23 @@
|
||||
# Test Dockerfile for Memvid Core
|
||||
FROM rust:1.92-slim-trixie AS builder
|
||||
|
||||
# Install test dependencies
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
pkg-config \
|
||||
libssl-dev \
|
||||
ca-certificates \
|
||||
git \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy everything
|
||||
COPY . .
|
||||
|
||||
# Set environment variables for testing
|
||||
ENV RUST_BACKTRACE=1
|
||||
ENV RUST_LOG=info
|
||||
ENV CARGO_TARGET_DIR=/app/target
|
||||
|
||||
# Run tests with default features
|
||||
CMD ["cargo", "test", "--features", "lex,pdf_extract", "--", "--nocapture"]
|
||||
@@ -0,0 +1,215 @@
|
||||
# Docker Setup for Memvid Core
|
||||
|
||||
This document describes how to use Docker with the Memvid Core Rust library.
|
||||
|
||||
## Quick Start
|
||||
|
||||
### Development Environment
|
||||
|
||||
```bash
|
||||
# From project root or docker/core directory
|
||||
cd docker/core
|
||||
docker-compose up -d dev
|
||||
|
||||
# Enter the container
|
||||
docker-compose exec dev bash
|
||||
|
||||
# Inside container, you can run:
|
||||
cargo build
|
||||
cargo test
|
||||
cargo run --example basic_usage
|
||||
```
|
||||
|
||||
### Run Tests
|
||||
|
||||
```bash
|
||||
# Run all tests
|
||||
cd docker/core
|
||||
docker-compose run --rm test
|
||||
|
||||
# Or build test image manually (from project root)
|
||||
docker build -f docker/core/Dockerfile.test -t memvid-test .
|
||||
docker run --rm memvid-test
|
||||
```
|
||||
|
||||
### Build Release
|
||||
|
||||
```bash
|
||||
# Build release version
|
||||
cd docker/core
|
||||
docker-compose run --rm build
|
||||
|
||||
# Or build manually (from project root)
|
||||
docker build -f docker/core/Dockerfile -t memvid-core:latest .
|
||||
```
|
||||
|
||||
## Docker Images
|
||||
|
||||
### 1. Development Image (`Dockerfile.dev`)
|
||||
|
||||
Full development environment with all tools:
|
||||
|
||||
```bash
|
||||
# From project root
|
||||
docker build -f docker/core/Dockerfile.dev -t memvid-dev .
|
||||
docker run -it --rm -v $(pwd):/app memvid-dev bash
|
||||
```
|
||||
|
||||
**Features:**
|
||||
- Rust toolchain 1.92
|
||||
- All build dependencies
|
||||
- Cargo watch (optional)
|
||||
- Volume mounting for live development
|
||||
|
||||
### 2. Test Image (`Dockerfile.test`)
|
||||
|
||||
Optimized for running tests:
|
||||
|
||||
```bash
|
||||
# From project root
|
||||
docker build -f docker/core/Dockerfile.test -t memvid-test .
|
||||
docker run --rm memvid-test
|
||||
```
|
||||
|
||||
**Features:**
|
||||
- Rust toolchain 1.92
|
||||
- Test dependencies
|
||||
- Runs tests automatically
|
||||
|
||||
### 3. Production Build (`Dockerfile`)
|
||||
|
||||
Multi-stage build for optimized production image:
|
||||
|
||||
```bash
|
||||
# From project root
|
||||
docker build -f docker/core/Dockerfile -t memvid-core:latest .
|
||||
```
|
||||
|
||||
**Features:**
|
||||
- Multi-stage build (smaller final image)
|
||||
- Only runtime dependencies
|
||||
- Optimized release build
|
||||
|
||||
## Docker Compose
|
||||
|
||||
### Services
|
||||
|
||||
- **`dev`** - Development environment with live code mounting
|
||||
- **`test`** - Test runner
|
||||
- **`build`** - Release builder
|
||||
|
||||
### Usage
|
||||
|
||||
```bash
|
||||
# Start development environment
|
||||
docker-compose up -d dev
|
||||
|
||||
# Run tests
|
||||
docker-compose run --rm test
|
||||
|
||||
# Build release
|
||||
docker-compose run --rm build
|
||||
|
||||
# Stop all services
|
||||
docker-compose down
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
### Run Examples in Docker
|
||||
|
||||
```bash
|
||||
# Development container
|
||||
docker-compose exec dev cargo run --example basic_usage
|
||||
|
||||
# With features
|
||||
docker-compose exec dev cargo run --example pdf_ingestion --features lex,pdf_extract
|
||||
```
|
||||
|
||||
### Memory-Constrained Testing
|
||||
|
||||
Test OOM prevention with memory limits:
|
||||
|
||||
```bash
|
||||
# Test with memory limit (for OOM testing)
|
||||
docker run --rm --memory=150m --memory-swap=150m \
|
||||
-v $(pwd):/app \
|
||||
memvid-test cargo test --features encryption --test encryption_capsule
|
||||
```
|
||||
|
||||
### Build with Specific Features
|
||||
|
||||
```bash
|
||||
# Build with all features
|
||||
docker-compose exec dev cargo build --release --all-features
|
||||
|
||||
# Build with specific features
|
||||
docker-compose exec dev cargo build --release --features lex,vec,encryption
|
||||
```
|
||||
|
||||
## Volume Mounts
|
||||
|
||||
The docker-compose setup uses volumes for:
|
||||
- **Source code** - Live mounting for development
|
||||
- **Cargo cache** - Speeds up builds
|
||||
- **Target cache** - Preserves build artifacts
|
||||
|
||||
## CI/CD Integration
|
||||
|
||||
### GitHub Actions Example
|
||||
|
||||
```yaml
|
||||
name: Docker Build
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Build Docker image
|
||||
run: docker build -t memvid-core:test .
|
||||
- name: Run tests
|
||||
run: docker run --rm memvid-core:test cargo test
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Build Fails
|
||||
|
||||
```bash
|
||||
# Clean build
|
||||
docker-compose down -v
|
||||
docker-compose build --no-cache
|
||||
```
|
||||
|
||||
### Permission Issues
|
||||
|
||||
```bash
|
||||
# Fix permissions
|
||||
sudo chown -R $USER:$USER .
|
||||
```
|
||||
|
||||
### Out of Memory
|
||||
|
||||
```bash
|
||||
# Increase Docker memory limit in Docker Desktop settings
|
||||
# Or use memory limits in docker run:
|
||||
docker run --memory=2g --memory-swap=2g ...
|
||||
```
|
||||
|
||||
## Best Practices
|
||||
|
||||
1. **Use docker-compose** for development
|
||||
2. **Cache volumes** for faster builds
|
||||
3. **Multi-stage builds** for production
|
||||
4. **Test in containers** to match CI/CD environment
|
||||
5. **Use .dockerignore** to exclude unnecessary files
|
||||
|
||||
## Related
|
||||
|
||||
- [CLI Docker Setup](../cli/README.md)
|
||||
- [Docker Overview](../README.md)
|
||||
- [Main Project README](../../README.md)
|
||||
- [Contributing Guide](../../CONTRIBUTING.md)
|
||||
@@ -0,0 +1,46 @@
|
||||
services:
|
||||
# Development environment
|
||||
dev:
|
||||
build:
|
||||
context: ../..
|
||||
dockerfile: docker/core/Dockerfile.dev
|
||||
volumes:
|
||||
- ../../:/app
|
||||
- cargo-cache:/usr/local/cargo/registry
|
||||
- target-cache:/app/target
|
||||
environment:
|
||||
- RUST_LOG=debug
|
||||
- CARGO_TARGET_DIR=/app/target
|
||||
stdin_open: true
|
||||
tty: true
|
||||
command: /bin/bash
|
||||
|
||||
# Test runner
|
||||
test:
|
||||
build:
|
||||
context: ../..
|
||||
dockerfile: docker/core/Dockerfile.test
|
||||
volumes:
|
||||
- ../../:/app
|
||||
- cargo-cache:/usr/local/cargo/registry
|
||||
- target-cache:/app/target
|
||||
environment:
|
||||
- RUST_BACKTRACE=1
|
||||
- RUST_LOG=info
|
||||
command: cargo test --features lex,pdf_extract -- --nocapture
|
||||
|
||||
# Build release
|
||||
build:
|
||||
build:
|
||||
context: ../..
|
||||
dockerfile: docker/core/Dockerfile
|
||||
target: builder
|
||||
volumes:
|
||||
- ../../:/app
|
||||
- cargo-cache:/usr/local/cargo/registry
|
||||
- target-cache:/app/target
|
||||
command: cargo build --release --features lex,pdf_extract
|
||||
|
||||
volumes:
|
||||
cargo-cache:
|
||||
target-cache:
|
||||
Reference in New Issue
Block a user