Files
lovdata-chat/Makefile
Torbjørn Lindahl 5a89f46e3d fix: replace per-path proxy with cookie-based catch-all routing
The /session/{id} URL prefix collided with OpenCode's internal
/session/{slug} SPA routes, causing a blank page. Now /c/{id} is
a thin entry point that sets a session cookie and redirects to /,
where the SPA loads at root with its router working correctly.

This also replaces ~50 individual per-path proxy route handlers
with a single /{path:path} catch-all, and simplifies the Caddyfile
from ~180 lines to ~17.
2026-02-16 10:40:17 +01:00

59 lines
1.8 KiB
Makefile

.PHONY: build run clean up down session try logs
IMAGE_NAME := opencode
IMAGE_TAG := latest
MCP_SERVER := http://localhost:8080
build:
docker build --build-arg MCP_SERVER=$(MCP_SERVER) -t $(IMAGE_NAME):$(IMAGE_TAG) .
run:
docker run -it --rm $(IMAGE_NAME):$(IMAGE_TAG) bash
clean:
docker rmi $(IMAGE_NAME):$(IMAGE_TAG) || true
# Start the full stack (session-manager, docker-daemon, caddy)
up:
docker-compose up -d --build
@echo "Stack started. Create a session with: make session"
# Stop the stack
down:
docker-compose down
# View logs
logs:
docker-compose logs -f session-manager
# Create a new session and display its info
session:
@echo "Creating new session..."
@curl -s -X POST http://localhost:8080/api/sessions | jq .
# Try the web interface - starts stack, creates a session and opens it
try: up
@echo "Waiting for services to be ready (Docker daemon can take ~30s)..."
@for i in $$(seq 1 60); do \
STATUS=$$(curl -sf http://localhost:8080/api/health 2>/dev/null | jq -r '.docker // false') && \
[ "$$STATUS" = "true" ] && break; \
printf '.'; \
sleep 1; \
done
@echo ""
@echo "Creating session..."
@SESSION_ID=$$(curl -s -X POST http://localhost:8080/api/sessions | jq -r '.session_id') && \
echo "Session $$SESSION_ID created, waiting for container to start..." && \
for i in $$(seq 1 30); do \
S=$$(curl -sf http://localhost:8080/api/sessions/$$SESSION_ID 2>/dev/null | jq -r '.status // "unknown"') && \
[ "$$S" = "running" ] && break; \
[ "$$S" = "error" ] && echo "Container failed to start" && exit 1; \
printf '.'; \
sleep 1; \
done && \
echo "" && \
echo "Opening http://localhost:8080/c/$$SESSION_ID" && \
(xdg-open "http://localhost:8080/c/$$SESSION_ID" 2>/dev/null || \
open "http://localhost:8080/c/$$SESSION_ID" 2>/dev/null || \
echo "Visit: http://localhost:8080/c/$$SESSION_ID")