# Justfile for Maple Proxy
# Development commands for the OpenAI-compatible proxy server
# Load environment variables from .env file
set dotenv-load
# Set the container runtime (docker or podman)
container := env_var_or_default("CONTAINER_RUNTIME", "podman")
# Default command - show available commands
default:
@just --list
# Set up development environment
setup:
@echo "๐ง Setting up development environment..."
@bash setup-hooks.sh
@cargo check --all-features
@echo "โ
Development environment ready"
# Format code with rustfmt
format:
@echo "๐จ Formatting code..."
@cargo fmt
@echo "โ
Code formatted"
# Alias for format
fmt: format
# Run clippy lints
lint:
@echo "๐ Running clippy lints..."
@cargo clippy --all-targets --all-features -- -D warnings
@echo "โ
Lints passed"
# Alias for lint
clippy: lint
# Run all tests
test:
@echo "๐งช Running tests..."
@cargo test --all-features
@echo "โ
Tests passed"
# Run all checks (format, lint, test)
check: format lint test
@echo "โ
All checks passed"
# Run the development server
run:
@echo "๐ Starting Maple Proxy server..."
@echo "๐ Loading configuration from .env"
@cargo run
# Run with custom backend URL (preserves .env variables)
run-with-backend url:
@echo "๐ Starting Maple Proxy server..."
@echo "๐ Backend: {{url}}"
@echo "๐ Loading other configs from .env"
@bash -c 'set -a; source .env 2>/dev/null; set +a; MAPLE_BACKEND_URL={{url}} cargo run'
# Run pointing to local backend
run-local:
@just run-with-backend "http://localhost:3000"
# Run pointing to production backend
run-prod:
@just run-with-backend "https://enclave.trymaple.ai"
# Build debug binary
build:
@echo "๐จ Building debug binary..."
@cargo build
@echo "โ
Debug binary built at target/debug/maple-proxy"
# Build release binary
release:
@echo "๐ฆ Building release binary..."
@cargo build --release
@echo "โ
Release binary built at target/release/maple-proxy"
# Build for all targets (used in CI)
build-all:
@echo "๐ฆ Building for all targets..."
@cargo build --all-targets --all-features
@echo "โ
All targets built"
# Clean build artifacts
clean:
@echo "๐งน Cleaning build artifacts..."
@cargo clean
@echo "โ
Build artifacts cleaned"
# Update dependencies
update:
@echo "๐ฆ Updating dependencies..."
@cargo update
@echo "โ
Dependencies updated"
# Install to ~/.cargo/bin
install:
@echo "๐ฅ Installing maple-proxy..."
@cargo install --path .
@echo "โ
Installed to ~/.cargo/bin/maple-proxy"
# Uninstall from ~/.cargo/bin
uninstall:
@echo "๐ค Uninstalling maple-proxy..."
@cargo uninstall maple-proxy
@echo "โ
Uninstalled"
# Run with verbose logging
debug:
@echo "๐ Starting with debug logging..."
RUST_LOG=debug MAPLE_DEBUG=true cargo run
# Check for security vulnerabilities
audit:
@echo "๐ Running security audit..."
@cargo audit
@echo "โ
Security audit complete"
# Generate documentation
doc:
@echo "๐ Generating documentation..."
@cargo doc --no-deps --all-features --open
@echo "โ
Documentation generated"
# Show code coverage (requires cargo-tarpaulin)
coverage:
@echo "๐ Generating code coverage..."
@cargo tarpaulin --verbose --all-features --workspace --timeout 120 --out html
@echo "โ
Coverage report generated at tarpaulin-report.html"
# Watch for changes and run tests
watch:
@echo "๐๏ธ Watching for changes..."
@cargo watch -x test
# Create a new git commit with conventional commit message
commit message:
@git add -A
@git commit -m "{{message}}"
@echo "โ
Changes committed"
# Quick test with curl
test-curl:
@echo "๐งช Testing with curl..."
@curl -N http://localhost:8080/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{"model": "llama3-3-70b", "messages": [{"role": "user", "content": "Say hello"}], "stream": true}'
# Show environment info
env:
@echo "๐ Environment Info"
@echo "==================="
@echo "Rust version: $(rustc --version)"
@echo "Cargo version: $(cargo --version)"
@echo "Just version: $(just --version)"
@echo "Container runtime: {{container}} $({{container}} --version 2>/dev/null | head -1 || echo 'not installed')"
@echo ""
@echo "๐ Environment Variables:"
@echo "MAPLE_HOST: ${MAPLE_HOST:-127.0.0.1}"
@echo "MAPLE_PORT: ${MAPLE_PORT:-8080}"
@echo "MAPLE_BACKEND_URL: ${MAPLE_BACKEND_URL:-https://enclave.trymaple.ai}"
@echo "MAPLE_API_KEY: ${MAPLE_API_KEY:-[not set]}"
@echo "MAPLE_DEBUG: ${MAPLE_DEBUG:-false}"
@echo "MAPLE_ENABLE_CORS: ${MAPLE_ENABLE_CORS:-false}"
# Build Docker image
docker-build:
@echo "๐ณ Building Docker image with {{container}}..."
@{{container}} build -t maple-proxy:latest .
@echo "โ
Docker image built: maple-proxy:latest"
# Run Docker container
docker-run:
@echo "๐ Running Docker container with {{container}}..."
@{{container}} run --rm -it \
-p ${MAPLE_PORT:-8080}:8080 \
-e MAPLE_API_KEY=${MAPLE_API_KEY} \
-e MAPLE_BACKEND_URL=${MAPLE_BACKEND_URL:-https://enclave.trymaple.ai} \
-e MAPLE_DEBUG=${MAPLE_DEBUG:-false} \
-e MAPLE_ENABLE_CORS=${MAPLE_ENABLE_CORS:-true} \
maple-proxy:latest
# Run Docker container in detached mode
docker-run-detached:
@echo "๐ Running Docker container in background with {{container}}..."
@{{container}} run -d \
--name maple-proxy \
-p ${MAPLE_PORT:-8080}:8080 \
-e MAPLE_API_KEY=${MAPLE_API_KEY} \
-e MAPLE_BACKEND_URL=${MAPLE_BACKEND_URL:-https://enclave.trymaple.ai} \
-e MAPLE_DEBUG=${MAPLE_DEBUG:-false} \
-e MAPLE_ENABLE_CORS=${MAPLE_ENABLE_CORS:-true} \
maple-proxy:latest
@echo "โ
Container started. Use 'just docker-stop' to stop it."
# Stop Docker container
docker-stop:
@echo "๐ Stopping Docker container..."
@{{container}} stop maple-proxy 2>/dev/null || echo "Container not running"
@{{container}} rm maple-proxy 2>/dev/null || true
@echo "โ
Container stopped"
# View Docker logs
docker-logs:
@{{container}} logs -f maple-proxy 2>/dev/null || echo "Container not running"
# Run with docker-compose
compose-up:
@echo "๐ Starting services with docker-compose..."
@{{container}}-compose up -d
@echo "โ
Services started. Use 'just compose-down' to stop."
# Stop docker-compose services
compose-down:
@echo "๐ Stopping services..."
@{{container}}-compose down
@echo "โ
Services stopped"
# View docker-compose logs
compose-logs:
@{{container}}-compose logs -f
# Clean Docker images
docker-clean:
@echo "๐งน Cleaning Docker images..."
@{{container}} rmi maple-proxy:latest 2>/dev/null || true
@echo "โ
Docker images cleaned"
# Push to GitHub Container Registry
ghcr-push tag="latest":
@echo "๐ฆ Pushing to GitHub Container Registry..."
@{{container}} tag maple-proxy:latest ghcr.io/opensecretcloud/maple-proxy:{{tag}}
@{{container}} push ghcr.io/opensecretcloud/maple-proxy:{{tag}}
@echo "โ
Pushed to ghcr.io/opensecretcloud/maple-proxy:{{tag}}"
# Build and push to GHCR
ghcr-build-push tag="latest":
@echo "๐ณ Building and pushing to GHCR..."
@{{container}} build -t ghcr.io/opensecretcloud/maple-proxy:{{tag}} .
@{{container}} push ghcr.io/opensecretcloud/maple-proxy:{{tag}}
@echo "โ
Image available at ghcr.io/opensecretcloud/maple-proxy:{{tag}}"
# Login to GitHub Container Registry (requires PAT token)
ghcr-login:
@echo "๐ Logging in to GitHub Container Registry..."
@echo "Please ensure you have a GitHub Personal Access Token with 'write:packages' scope"
@echo "${GITHUB_TOKEN}" | {{container}} login ghcr.io -u ${GITHUB_USER} --password-stdin
@echo "โ
Logged in to ghcr.io"
# Pull from GitHub Container Registry
ghcr-pull tag="latest":
@echo "๐ฅ Pulling from GitHub Container Registry..."
@{{container}} pull ghcr.io/opensecretcloud/maple-proxy:{{tag}}
@echo "โ
Pulled ghcr.io/opensecretcloud/maple-proxy:{{tag}}"