Skip to content

Commit 74847cc

Browse files
phernandezclaude
andauthored
feat: implement Docker CI workflow for automated image publishing (#159)
Co-authored-by: Claude <noreply@anthropic.com>
1 parent d3b6c85 commit 74847cc

5 files changed

Lines changed: 263 additions & 27 deletions

File tree

.dockerignore

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Git files
2+
.git/
3+
.gitignore
4+
.gitattributes
5+
6+
# Development files
7+
.vscode/
8+
.idea/
9+
*.swp
10+
*.swo
11+
*~
12+
13+
# Testing files
14+
tests/
15+
test-int/
16+
.pytest_cache/
17+
.coverage
18+
htmlcov/
19+
20+
# Build artifacts
21+
build/
22+
dist/
23+
*.egg-info/
24+
__pycache__/
25+
*.pyc
26+
*.pyo
27+
*.pyd
28+
.Python
29+
30+
# Virtual environments (uv creates these during build)
31+
.venv/
32+
venv/
33+
.env
34+
35+
# CI/CD files
36+
.github/
37+
38+
# Documentation (keep README.md and pyproject.toml)
39+
docs/
40+
CHANGELOG.md
41+
CLAUDE.md
42+
CONTRIBUTING.md
43+
44+
# Example files not needed for runtime
45+
examples/
46+
47+
# Local development files
48+
.basic-memory/
49+
*.db
50+
*.sqlite3
51+
52+
# OS files
53+
.DS_Store
54+
Thumbs.db
55+
56+
# Temporary files
57+
tmp/
58+
temp/
59+
*.tmp
60+
*.log

.github/workflows/docker.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: Docker Image CI
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*' # Trigger on version tags like v1.0.0, v0.13.0, etc.
7+
workflow_dispatch: # Allow manual triggering for testing
8+
9+
env:
10+
REGISTRY: docker.io
11+
IMAGE_NAME: basicmachines/basic-memory
12+
13+
jobs:
14+
docker:
15+
runs-on: ubuntu-latest
16+
permissions:
17+
contents: read
18+
packages: write
19+
20+
steps:
21+
- name: Checkout repository
22+
uses: actions/checkout@v4
23+
with:
24+
fetch-depth: 0
25+
26+
- name: Set up Docker Buildx
27+
uses: docker/setup-buildx-action@v3
28+
with:
29+
platforms: linux/amd64,linux/arm64
30+
31+
- name: Log in to Docker Hub
32+
uses: docker/login-action@v3
33+
with:
34+
registry: ${{ env.REGISTRY }}
35+
username: ${{ secrets.DOCKER_USERNAME }}
36+
password: ${{ secrets.DOCKER_PASSWORD }}
37+
38+
- name: Extract metadata
39+
id: meta
40+
uses: docker/metadata-action@v5
41+
with:
42+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
43+
tags: |
44+
type=ref,event=branch
45+
type=ref,event=pr
46+
type=semver,pattern={{version}}
47+
type=semver,pattern={{major}}.{{minor}}
48+
type=raw,value=latest,enable={{is_default_branch}}
49+
50+
- name: Build and push Docker image
51+
uses: docker/build-push-action@v5
52+
with:
53+
context: .
54+
file: ./Dockerfile
55+
platforms: linux/amd64,linux/arm64
56+
push: true
57+
tags: ${{ steps.meta.outputs.tags }}
58+
labels: ${{ steps.meta.outputs.labels }}
59+
cache-from: type=gha
60+
cache-to: type=gha,mode=max
61+
62+
- name: Update Docker Hub description
63+
uses: peter-evans/dockerhub-description@v4
64+
with:
65+
username: ${{ secrets.DOCKER_USERNAME }}
66+
password: ${{ secrets.DOCKER_PASSWORD }}
67+
repository: ${{ env.IMAGE_NAME }}
68+
readme-filepath: ./docs/Docker.md

Dockerfile

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,32 @@
1-
FROM python:3.12-slim
1+
FROM python:3.12-slim-bookworm
22

3+
# Copy uv from official image
4+
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
5+
6+
# Set environment variables
7+
ENV PYTHONUNBUFFERED=1 \
8+
PYTHONDONTWRITEBYTECODE=1
9+
10+
# Copy the project into the image
11+
ADD . /app
12+
13+
# Sync the project into a new environment, asserting the lockfile is up to date
314
WORKDIR /app
15+
RUN uv sync --locked
16+
17+
# Create data directory
18+
RUN mkdir -p /app/data
19+
20+
# Set default data directory and add venv to PATH
21+
ENV BASIC_MEMORY_HOME=/app/data \
22+
PATH="/app/.venv/bin:$PATH"
423

5-
# Copy the project files
6-
COPY . .
24+
# Expose port
25+
EXPOSE 8000
726

8-
# Install pip and build dependencies
9-
RUN pip install --upgrade pip \
10-
&& pip install . --no-cache-dir --ignore-installed
27+
# Health check
28+
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
29+
CMD basic-memory --version || exit 1
1130

1231
# Use the basic-memory entrypoint to run the MCP server with default SSE transport
1332
CMD ["basic-memory", "mcp", "--transport", "sse", "--host", "0.0.0.0", "--port", "8000"]

docker-compose.yml

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@ version: '3.8'
55

66
services:
77
basic-memory:
8-
build: .
8+
# Use pre-built image (recommended for most users)
9+
image: basicmachines/basic-memory:latest
10+
11+
# Uncomment to build locally instead:
12+
# build: .
13+
914
container_name: basic-memory-server
1015

1116
# Volume mounts for knowledge directories and persistent data
@@ -14,14 +19,16 @@ services:
1419
# Persistent storage for configuration and database
1520
- basic-memory-config:/root/.basic-memory:rw
1621

17-
# The default project will be at /root/basic-memory
22+
# Mount your knowledge directory (required)
23+
# Change './knowledge' to your actual Obsidian vault or knowledge directory
24+
- ./knowledge:/app/data:rw
1825

1926
# OPTIONAL: Mount additional knowledge directories for multiple projects
20-
# - ./work-notes:/data/projects/work:rw
21-
# - ./personal-notes:/data/projects/personal:rw
27+
# - ./work-notes:/app/data/work:rw
28+
# - ./personal-notes:/app/data/personal:rw
2229

23-
# You can edit the project config manually in
24-
# /root/.basic-memory/config.json
30+
# You can edit the project config manually in the mounted config volume
31+
# The default project will be configured to use /app/data
2532
environment:
2633
# Project configuration
2734
- BASIC_MEMORY_DEFAULT_PROJECT=main

0 commit comments

Comments
 (0)