Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -243,3 +243,76 @@ GRAPH_STORE_MAX_HOPS=3
# GRAPH_STORE_CUSTOM_EXTRACT_RELATIONS_PROMPT=
# GRAPH_STORE_CUSTOM_UPDATE_GRAPH_PROMPT=
# GRAPH_STORE_CUSTOM_DELETE_RELATIONS_PROMPT=

# =============================================================================
# 12. PowerMem HTTP API Server Configuration
# =============================================================================
# Configuration for the PowerMem HTTP API Server
# =============================================================================

# -----------------------------------------------------------------------------
# Server Settings
# -----------------------------------------------------------------------------
# Server host address (0.0.0.0 to listen on all interfaces)
POWERMEM_SERVER_HOST=0.0.0.0

# Server port number
POWERMEM_SERVER_PORT=8000

# Number of worker processes (only used when reload=false)
POWERMEM_SERVER_WORKERS=4

# Enable auto-reload for development (true/false)
POWERMEM_SERVER_RELOAD=false

# -----------------------------------------------------------------------------
# Authentication Settings
# -----------------------------------------------------------------------------
# Enable API key authentication (true/false)
POWERMEM_SERVER_AUTH_ENABLED=false

# API keys (comma-separated list)
# Example: POWERMEM_SERVER_API_KEYS=key1,key2,key3
POWERMEM_SERVER_API_KEYS=

# -----------------------------------------------------------------------------
# Rate Limiting Settings
# -----------------------------------------------------------------------------
# Enable rate limiting (true/false)
POWERMEM_SERVER_RATE_LIMIT_ENABLED=true

# Rate limit per minute per IP address
POWERMEM_SERVER_RATE_LIMIT_PER_MINUTE=100

# -----------------------------------------------------------------------------
# Logging Settings
# -----------------------------------------------------------------------------
POWERMEM_SERVER_LOG_FILE=server.log

# Log level: DEBUG, INFO, WARNING, ERROR, CRITICAL
POWERMEM_SERVER_LOG_LEVEL=INFO

# Log format: json or text
POWERMEM_SERVER_LOG_FORMAT=text

# -----------------------------------------------------------------------------
# API Settings
# -----------------------------------------------------------------------------
# API title (shown in Swagger UI)
POWERMEM_SERVER_API_TITLE=PowerMem API

# API version
POWERMEM_SERVER_API_VERSION=v1

# API description (shown in Swagger UI)
POWERMEM_SERVER_API_DESCRIPTION=PowerMem HTTP API Server - Intelligent Memory System

# -----------------------------------------------------------------------------
# CORS Settings
# -----------------------------------------------------------------------------
# Enable CORS (true/false)
POWERMEM_SERVER_CORS_ENABLED=true

# CORS allowed origins (comma-separated, use * for all origins)
# Example: POWERMEM_SERVER_CORS_ORIGINS=http://localhost:3000,https://example.com
POWERMEM_SERVER_CORS_ORIGINS=*
140 changes: 140 additions & 0 deletions .github/workflows/build_docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
name: build powermem-server docker

on:
push:
branches: [main, develop]
tags:
- 'v*'
pull_request:
branches: [main, develop]

jobs:
build-docker:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Get SDK version
id: sdk-version
run: |
# Extract version from version.py file
VERSION=$(grep -E '^__version__\s*=' src/powermem/version.py | sed -E "s/^__version__\s*=\s*['\"](.*)['\"]/\1/")
echo "SDK version: $VERSION"
echo "sdk-version=$VERSION" >> $GITHUB_OUTPUT
echo "image-tag=$VERSION" >> $GITHUB_OUTPUT
echo "Using SDK version ($VERSION) as Docker image tag"

- name: Determine if should push
id: should-push
run: |
EVENT_NAME="${{ github.event_name }}"
REF="${{ github.ref }}"

echo "Event name: $EVENT_NAME"
echo "Ref: $REF"

# Only push when it's a push event and the ref starts with refs/tags/v
if [[ "$EVENT_NAME" == "push" ]] && [[ "$REF" == refs/tags/v* ]]; then
echo "should-push=true" >> $GITHUB_OUTPUT
echo "Will push to remote repository"
else
echo "should-push=false" >> $GITHUB_OUTPUT
echo "Will save as artifacts"
fi

# Debug: verify the output
echo "Output should-push value:"
grep should-push $GITHUB_OUTPUT || echo "No should-push found in output"

- name: Log in to Docker hub (for tag push only)
if: steps.should-push.outputs.should-push == 'true'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build and push Docker image (for tags)
if: steps.should-push.outputs.should-push == 'true'
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64
file: docker/Dockerfile
push: true
tags: |
${{ vars.DOCKER_PUSH_BASE }}/powermem-server:latest
${{ vars.DOCKER_PUSH_BASE }}/powermem-server:${{ steps.sdk-version.outputs.image-tag }}

- name: Debug should-push output
run: |
echo "should-push output value: '${{ steps.should-push.outputs.should-push }}'"
echo "Condition check: should-push == 'false'"
if [ "${{ steps.should-push.outputs.should-push }}" == "false" ]; then
echo "✓ Condition is true, will execute build step"
else
echo "✗ Condition is false, step will be skipped"
fi

- name: Build and save Docker images (for PR and branches)
if: steps.should-push.outputs.should-push != 'true'
run: |
mkdir -p docker-images

IMAGE_NAME="powermem-server"
SDK_VERSION="${{ steps.sdk-version.outputs.sdk-version }}"
IMAGE_VERSION="${{ steps.sdk-version.outputs.image-tag }}"

echo "SDK version: $SDK_VERSION"
echo "Image version tag: $IMAGE_VERSION"

# Build and save for each platform
for platform in linux/amd64 linux/arm64; do
platform_suffix=$(echo $platform | tr '/' '-')
image_tag="${IMAGE_NAME}:${IMAGE_VERSION}"
output_file="docker-images/${IMAGE_NAME}-${IMAGE_VERSION}-${platform_suffix}.tar"

echo "Building image for platform: $platform"

# Build the image for the specific platform and load it
docker buildx build \
. \
--file docker/Dockerfile \
--platform $platform \
--load \
--tag ${image_tag}

# Save the image as tar file
echo "Saving image to: ${output_file}"
docker save ${image_tag} -o ${output_file}

# Verify the file was created
if [ -f "${output_file}" ]; then
echo "✓ Successfully saved: ${output_file} ($(du -h ${output_file} | cut -f1))"
else
echo "✗ Failed to save: ${output_file}"
exit 1
fi
done

# List all saved files
echo ""
echo "All saved Docker images:"
ls -lh docker-images/
echo ""
echo "To load these images, use: docker load -i <tar-file>"

- name: Upload Docker image artifacts (for PR and branches)
if: steps.should-push.outputs.should-push != 'true'
uses: actions/upload-artifact@v4
with:
name: powermem-server-docker-images
path: docker-images/*.tar
retention-days: 30
if-no-files-found: error
20 changes: 20 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -198,3 +198,23 @@ performance_logs/

# Docker
.dockerignore

# PowerMem API Server
.server.pid
server.log
*.pid
server_*.log
api_server.log

# Server runtime files
.pid
*.pid.lock

# Server data directories (if any)
server_data/
api_data/

# Server backups
server_backup/
*.backup

Loading
Loading