chore: developer experience
This commit is contained in:
parent
e54604dd90
commit
2b9ef266b4
3 changed files with 91 additions and 115 deletions
194
Makefile
194
Makefile
|
|
@ -1,17 +1,26 @@
|
||||||
.PHONY: run check ruff database lint docker-build docker-build-dev docker-build-multi-test docker-build-multi-load docker-push docker-buildx-prepare docker-release api start-all stop-all status clean-cache docker-build-dev-clean docker-build-single-dev docker-build-single-multi-test docker-build-single docker-build-single-v1-latest docker-release-single docker-release-both docker-release-all-versions docker-update-v1-latest
|
.PHONY: run frontend check ruff database lint api start-all stop-all status clean-cache worker worker-start worker-stop worker-restart
|
||||||
|
.PHONY: docker-buildx-prepare docker-buildx-clean docker-buildx-reset
|
||||||
|
.PHONY: docker-push docker-push-latest docker-release tag
|
||||||
|
|
||||||
# Get version from pyproject.toml
|
# Get version from pyproject.toml
|
||||||
VERSION := $(shell grep -m1 version pyproject.toml | cut -d'"' -f2)
|
VERSION := $(shell grep -m1 version pyproject.toml | cut -d'"' -f2)
|
||||||
IMAGE_NAME := lfnovo/open_notebook
|
|
||||||
|
|
||||||
PLATFORMS=linux/amd64,linux/arm64
|
# Image names for both registries
|
||||||
|
DOCKERHUB_IMAGE := lfnovo/open_notebook
|
||||||
|
GHCR_IMAGE := ghcr.io/lfnovo/open-notebook
|
||||||
|
|
||||||
|
# Build platforms
|
||||||
|
PLATFORMS := linux/amd64,linux/arm64
|
||||||
|
|
||||||
database:
|
database:
|
||||||
docker compose up -d surrealdb
|
docker compose up -d surrealdb
|
||||||
|
|
||||||
run:
|
run:
|
||||||
@echo "⚠️ Warning: Starting UI only. For full functionality, use 'make start-all'"
|
@echo "⚠️ Warning: Starting frontend only. For full functionality, use 'make start-all'"
|
||||||
uv run --env-file .env streamlit run app_home.py
|
cd frontend && npm run dev
|
||||||
|
|
||||||
|
frontend:
|
||||||
|
cd frontend && npm run dev
|
||||||
|
|
||||||
lint:
|
lint:
|
||||||
uv run python -m mypy .
|
uv run python -m mypy .
|
||||||
|
|
@ -19,57 +28,82 @@ lint:
|
||||||
ruff:
|
ruff:
|
||||||
ruff check . --fix
|
ruff check . --fix
|
||||||
|
|
||||||
# buildx config for multi-platform
|
# === Docker Build Setup ===
|
||||||
docker-buildx-prepare:
|
docker-buildx-prepare:
|
||||||
@docker buildx inspect multi-platform-builder >/dev/null 2>&1 || \
|
@docker buildx inspect multi-platform-builder >/dev/null 2>&1 || \
|
||||||
docker buildx create --use --name multi-platform-builder --driver docker-container
|
docker buildx create --use --name multi-platform-builder --driver docker-container
|
||||||
@docker buildx use multi-platform-builder
|
@docker buildx use multi-platform-builder
|
||||||
|
|
||||||
# Single-platform build for development (much faster)
|
docker-buildx-clean:
|
||||||
docker-build-dev:
|
@echo "🧹 Cleaning up buildx builders..."
|
||||||
docker build \
|
@docker buildx rm multi-platform-builder 2>/dev/null || true
|
||||||
-t $(IMAGE_NAME):$(VERSION)-dev \
|
@docker ps -a | grep buildx_buildkit | awk '{print $$1}' | xargs -r docker rm -f 2>/dev/null || true
|
||||||
.
|
@echo "✅ Buildx cleanup complete!"
|
||||||
|
|
||||||
# Multi-platform build test (builds both platforms, doesn't load or push)
|
docker-buildx-reset: docker-buildx-clean docker-buildx-prepare
|
||||||
docker-build-multi-test: docker-buildx-prepare
|
@echo "✅ Buildx reset complete!"
|
||||||
|
|
||||||
|
# === Docker Build Targets ===
|
||||||
|
|
||||||
|
# Build and push version tags ONLY (no latest) for both regular and single images
|
||||||
|
docker-push: docker-buildx-prepare
|
||||||
|
@echo "📤 Building and pushing version $(VERSION) to both registries..."
|
||||||
|
@echo "🔨 Building regular image..."
|
||||||
docker buildx build --pull \
|
docker buildx build --pull \
|
||||||
--platform $(PLATFORMS) \
|
--platform $(PLATFORMS) \
|
||||||
-t $(IMAGE_NAME):$(VERSION)-multi \
|
-t $(DOCKERHUB_IMAGE):$(VERSION) \
|
||||||
.
|
-t $(GHCR_IMAGE):$(VERSION) \
|
||||||
|
|
||||||
# Load current platform only from multi-platform build
|
|
||||||
docker-build-multi-load: docker-buildx-prepare
|
|
||||||
docker buildx build --pull \
|
|
||||||
--platform linux/amd64 \
|
|
||||||
-t $(IMAGE_NAME):$(VERSION)-multi \
|
|
||||||
--load \
|
|
||||||
.
|
|
||||||
|
|
||||||
# multi-platform build with buildx (pushes to registry)
|
|
||||||
docker-build: docker-buildx-prepare
|
|
||||||
docker buildx build --pull \
|
|
||||||
--platform $(PLATFORMS) \
|
|
||||||
-t $(IMAGE_NAME):$(VERSION) \
|
|
||||||
--push \
|
--push \
|
||||||
.
|
.
|
||||||
|
@echo "🔨 Building single-container image..."
|
||||||
# Build and push combined
|
docker buildx build --pull \
|
||||||
docker-release: docker-build
|
|
||||||
|
|
||||||
# Check supported platforms
|
|
||||||
docker-check-platforms:
|
|
||||||
docker manifest inspect $(IMAGE_NAME):$(VERSION)
|
|
||||||
|
|
||||||
docker-update-v1-latest: docker-buildx-prepare
|
|
||||||
docker buildx build \
|
|
||||||
--platform $(PLATFORMS) \
|
--platform $(PLATFORMS) \
|
||||||
-t $(IMAGE_NAME):v1-latest \
|
-f Dockerfile.single \
|
||||||
|
-t $(DOCKERHUB_IMAGE):$(VERSION)-single \
|
||||||
|
-t $(GHCR_IMAGE):$(VERSION)-single \
|
||||||
--push \
|
--push \
|
||||||
.
|
.
|
||||||
|
@echo "✅ Pushed version $(VERSION) to both registries (latest NOT updated)"
|
||||||
|
@echo " 📦 Docker Hub:"
|
||||||
|
@echo " - $(DOCKERHUB_IMAGE):$(VERSION)"
|
||||||
|
@echo " - $(DOCKERHUB_IMAGE):$(VERSION)-single"
|
||||||
|
@echo " 📦 GHCR:"
|
||||||
|
@echo " - $(GHCR_IMAGE):$(VERSION)"
|
||||||
|
@echo " - $(GHCR_IMAGE):$(VERSION)-single"
|
||||||
|
|
||||||
# Release with v1-latest
|
# Update v1-latest tags to current version (both regular and single images)
|
||||||
docker-release-all: docker-release docker-update-v1-latest docker-build-single-v1-latest
|
docker-push-latest: docker-buildx-prepare
|
||||||
|
@echo "📤 Updating v1-latest tags to version $(VERSION)..."
|
||||||
|
@echo "🔨 Building regular image with latest tag..."
|
||||||
|
docker buildx build --pull \
|
||||||
|
--platform $(PLATFORMS) \
|
||||||
|
-t $(DOCKERHUB_IMAGE):$(VERSION) \
|
||||||
|
-t $(DOCKERHUB_IMAGE):v1-latest \
|
||||||
|
-t $(GHCR_IMAGE):$(VERSION) \
|
||||||
|
-t $(GHCR_IMAGE):v1-latest \
|
||||||
|
--push \
|
||||||
|
.
|
||||||
|
@echo "🔨 Building single-container image with latest tag..."
|
||||||
|
docker buildx build --pull \
|
||||||
|
--platform $(PLATFORMS) \
|
||||||
|
-f Dockerfile.single \
|
||||||
|
-t $(DOCKERHUB_IMAGE):$(VERSION)-single \
|
||||||
|
-t $(DOCKERHUB_IMAGE):v1-latest-single \
|
||||||
|
-t $(GHCR_IMAGE):$(VERSION)-single \
|
||||||
|
-t $(GHCR_IMAGE):v1-latest-single \
|
||||||
|
--push \
|
||||||
|
.
|
||||||
|
@echo "✅ Updated v1-latest to version $(VERSION)"
|
||||||
|
@echo " 📦 Docker Hub:"
|
||||||
|
@echo " - $(DOCKERHUB_IMAGE):$(VERSION) → v1-latest"
|
||||||
|
@echo " - $(DOCKERHUB_IMAGE):$(VERSION)-single → v1-latest-single"
|
||||||
|
@echo " 📦 GHCR:"
|
||||||
|
@echo " - $(GHCR_IMAGE):$(VERSION) → v1-latest"
|
||||||
|
@echo " - $(GHCR_IMAGE):$(VERSION)-single → v1-latest-single"
|
||||||
|
|
||||||
|
# Full release: push version AND update latest tags
|
||||||
|
docker-release: docker-push-latest
|
||||||
|
@echo "✅ Full release complete for version $(VERSION)"
|
||||||
|
|
||||||
tag:
|
tag:
|
||||||
@version=$$(grep '^version = ' pyproject.toml | sed 's/version = "\(.*\)"/\1/'); \
|
@version=$$(grep '^version = ' pyproject.toml | sed 's/version = "\(.*\)"/\1/'); \
|
||||||
|
|
@ -107,7 +141,7 @@ worker-restart: worker-stop
|
||||||
|
|
||||||
# === Service Management ===
|
# === Service Management ===
|
||||||
start-all:
|
start-all:
|
||||||
@echo "🚀 Starting Open Notebook (Database + API + Worker + UI)..."
|
@echo "🚀 Starting Open Notebook (Database + API + Worker + Frontend)..."
|
||||||
@echo "📊 Starting SurrealDB..."
|
@echo "📊 Starting SurrealDB..."
|
||||||
@docker compose up -d surrealdb
|
@docker compose up -d surrealdb
|
||||||
@sleep 3
|
@sleep 3
|
||||||
|
|
@ -117,16 +151,16 @@ start-all:
|
||||||
@echo "⚙️ Starting background worker..."
|
@echo "⚙️ Starting background worker..."
|
||||||
@uv run --env-file .env surreal-commands-worker --import-modules commands &
|
@uv run --env-file .env surreal-commands-worker --import-modules commands &
|
||||||
@sleep 2
|
@sleep 2
|
||||||
@echo "🌐 Starting Streamlit UI..."
|
@echo "🌐 Starting Next.js frontend..."
|
||||||
@echo "✅ All services started!"
|
@echo "✅ All services started!"
|
||||||
@echo "📱 UI: http://localhost:8502"
|
@echo "📱 Frontend: http://localhost:3000"
|
||||||
@echo "🔗 API: http://localhost:5055"
|
@echo "🔗 API: http://localhost:5055"
|
||||||
@echo "📚 API Docs: http://localhost:5055/docs"
|
@echo "📚 API Docs: http://localhost:5055/docs"
|
||||||
uv run --env-file .env streamlit run app_home.py
|
cd frontend && npm run dev
|
||||||
|
|
||||||
stop-all:
|
stop-all:
|
||||||
@echo "🛑 Stopping all Open Notebook services..."
|
@echo "🛑 Stopping all Open Notebook services..."
|
||||||
@pkill -f "streamlit run app_home.py" || true
|
@pkill -f "next dev" || true
|
||||||
@pkill -f "surreal-commands-worker" || true
|
@pkill -f "surreal-commands-worker" || true
|
||||||
@pkill -f "run_api.py" || true
|
@pkill -f "run_api.py" || true
|
||||||
@pkill -f "uvicorn api.main:app" || true
|
@pkill -f "uvicorn api.main:app" || true
|
||||||
|
|
@ -141,10 +175,10 @@ status:
|
||||||
@pgrep -f "run_api.py\|uvicorn api.main:app" >/dev/null && echo " ✅ Running" || echo " ❌ Not running"
|
@pgrep -f "run_api.py\|uvicorn api.main:app" >/dev/null && echo " ✅ Running" || echo " ❌ Not running"
|
||||||
@echo "Background Worker:"
|
@echo "Background Worker:"
|
||||||
@pgrep -f "surreal-commands-worker" >/dev/null && echo " ✅ Running" || echo " ❌ Not running"
|
@pgrep -f "surreal-commands-worker" >/dev/null && echo " ✅ Running" || echo " ❌ Not running"
|
||||||
@echo "Streamlit UI:"
|
@echo "Next.js Frontend:"
|
||||||
@pgrep -f "streamlit run app_home.py" >/dev/null && echo " ✅ Running" || echo " ❌ Not running"
|
@pgrep -f "next dev" >/dev/null && echo " ✅ Running" || echo " ❌ Not running"
|
||||||
|
|
||||||
# Clean up cache directories to reduce build context size
|
# === Cleanup ===
|
||||||
clean-cache:
|
clean-cache:
|
||||||
@echo "🧹 Cleaning cache directories..."
|
@echo "🧹 Cleaning cache directories..."
|
||||||
@find . -name "__pycache__" -type d -exec rm -rf {} + 2>/dev/null || true
|
@find . -name "__pycache__" -type d -exec rm -rf {} + 2>/dev/null || true
|
||||||
|
|
@ -154,62 +188,4 @@ clean-cache:
|
||||||
@find . -name "*.pyc" -type f -delete 2>/dev/null || true
|
@find . -name "*.pyc" -type f -delete 2>/dev/null || true
|
||||||
@find . -name "*.pyo" -type f -delete 2>/dev/null || true
|
@find . -name "*.pyo" -type f -delete 2>/dev/null || true
|
||||||
@find . -name "*.pyd" -type f -delete 2>/dev/null || true
|
@find . -name "*.pyd" -type f -delete 2>/dev/null || true
|
||||||
@echo "✅ Cache directories cleaned!"
|
@echo "✅ Cache directories cleaned!"
|
||||||
|
|
||||||
# Fast development build with cache cleanup
|
|
||||||
docker-build-dev-clean: clean-cache docker-build-dev
|
|
||||||
|
|
||||||
# === Single Container Builds ===
|
|
||||||
# Single-container build for development (much faster)
|
|
||||||
docker-build-single-dev:
|
|
||||||
docker build \
|
|
||||||
-f Dockerfile.single \
|
|
||||||
-t $(IMAGE_NAME):$(VERSION)-single-dev \
|
|
||||||
.
|
|
||||||
|
|
||||||
# Single-container multi-platform build test
|
|
||||||
docker-build-single-multi-test: docker-buildx-prepare
|
|
||||||
docker buildx build --pull \
|
|
||||||
--platform $(PLATFORMS) \
|
|
||||||
-f Dockerfile.single \
|
|
||||||
-t $(IMAGE_NAME):$(VERSION)-single-multi \
|
|
||||||
.
|
|
||||||
|
|
||||||
# Single-container multi-platform build with buildx (pushes to registry)
|
|
||||||
docker-build-single: docker-buildx-prepare
|
|
||||||
docker buildx build --pull \
|
|
||||||
--platform $(PLATFORMS) \
|
|
||||||
-f Dockerfile.single \
|
|
||||||
-t $(IMAGE_NAME):$(VERSION)-single \
|
|
||||||
--push \
|
|
||||||
.
|
|
||||||
|
|
||||||
# Single-container build and push with v1-latest tag
|
|
||||||
docker-build-single-v1-latest: docker-buildx-prepare
|
|
||||||
docker buildx build --pull \
|
|
||||||
--platform $(PLATFORMS) \
|
|
||||||
-f Dockerfile.single \
|
|
||||||
-t $(IMAGE_NAME):v1-latest-single \
|
|
||||||
--push \
|
|
||||||
.
|
|
||||||
|
|
||||||
# Single-container release (both versioned and v1-latest)
|
|
||||||
docker-release-single: docker-build-single docker-build-single-v1-latest
|
|
||||||
|
|
||||||
# Release both multi-container and single-container versions (versioned only)
|
|
||||||
docker-release-both: docker-release docker-build-single
|
|
||||||
|
|
||||||
# Release all versions (both multi and single with latest tags)
|
|
||||||
docker-release-all-versions: docker-release-all docker-release-single
|
|
||||||
|
|
||||||
# === Buildx Cleanup ===
|
|
||||||
.PHONY: docker-buildx-clean docker-buildx-reset
|
|
||||||
|
|
||||||
docker-buildx-clean:
|
|
||||||
@echo "🧹 Cleaning up buildx builders..."
|
|
||||||
@docker buildx rm multi-platform-builder 2>/dev/null || true
|
|
||||||
@docker ps -a | grep buildx_buildkit | awk '{print $$1}' | xargs -r docker rm -f 2>/dev/null || true
|
|
||||||
@echo "✅ Buildx cleanup complete!"
|
|
||||||
|
|
||||||
docker-buildx-reset: docker-buildx-clean docker-buildx-prepare
|
|
||||||
@echo "✅ Buildx reset complete!"
|
|
||||||
|
|
@ -34,7 +34,7 @@ make start-all
|
||||||
# Check that the API is running
|
# Check that the API is running
|
||||||
curl http://localhost:5055/health
|
curl http://localhost:5055/health
|
||||||
|
|
||||||
# Check that the UI is accessible
|
# Check that the frontend is accessible
|
||||||
open http://localhost:8502
|
open http://localhost:8502
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
@ -501,8 +501,8 @@ uv run python -m open_notebook.database.async_migrate
|
||||||
# Start the API server
|
# Start the API server
|
||||||
uv run python run_api.py
|
uv run python run_api.py
|
||||||
|
|
||||||
# Start the React frontend (in another terminal)
|
# Start the Next.js frontend (in another terminal)
|
||||||
uv run cd frontend && npm run dev --server.port 8502
|
cd frontend && npm run dev
|
||||||
```
|
```
|
||||||
|
|
||||||
### Development Tools
|
### Development Tools
|
||||||
|
|
@ -620,7 +620,7 @@ async def new_feature_graph(state: NewFeatureState):
|
||||||
|
|
||||||
We're actively looking for contributions in these areas:
|
We're actively looking for contributions in these areas:
|
||||||
|
|
||||||
1. **React Frontend**: Help build a modern React-based UI to replace Next.js
|
1. **Frontend Enhancement**: Help improve the Next.js/React UI with real-time updates and better UX
|
||||||
2. **Testing**: Expand test coverage across all components
|
2. **Testing**: Expand test coverage across all components
|
||||||
3. **Performance**: Async processing improvements and caching
|
3. **Performance**: Async processing improvements and caching
|
||||||
4. **Documentation**: API examples and user guides
|
4. **Documentation**: API examples and user guides
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ Open Notebook is built with a modern Python stack using:
|
||||||
| **Domain Models** | Core business logic | `open_notebook/domain/` |
|
| **Domain Models** | Core business logic | `open_notebook/domain/` |
|
||||||
| **Database** | SurrealDB repository pattern | `open_notebook/database/` |
|
| **Database** | SurrealDB repository pattern | `open_notebook/database/` |
|
||||||
| **AI Graphs** | LangChain processing workflows | `open_notebook/graphs/` |
|
| **AI Graphs** | LangChain processing workflows | `open_notebook/graphs/` |
|
||||||
| **React frontend** | Web interface | `pages/` |
|
| **Next.js Frontend** | Modern React-based web interface | `frontend/` |
|
||||||
| **Commands** | Background job processing | `commands/` |
|
| **Commands** | Background job processing | `commands/` |
|
||||||
|
|
||||||
## 🔧 Development Workflow
|
## 🔧 Development Workflow
|
||||||
|
|
@ -118,7 +118,7 @@ We welcome contributions! Here's how to get started:
|
||||||
|
|
||||||
### Current Development Priorities
|
### Current Development Priorities
|
||||||
|
|
||||||
- **React Frontend**: Replacing Next.js with modern React UI
|
- **Frontend Enhancement**: Improving the Next.js/React UI with real-time updates
|
||||||
- **Performance**: Async processing and caching improvements
|
- **Performance**: Async processing and caching improvements
|
||||||
- **Testing**: Expanded test coverage
|
- **Testing**: Expanded test coverage
|
||||||
- **Documentation**: API documentation and examples
|
- **Documentation**: API documentation and examples
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue