feat: Docker support for L1 server
- Dockerfile for L1 server/worker - docker-compose.yml with Redis - Environment variables for Redis URL and cache dir 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
18
Dockerfile
Normal file
18
Dockerfile
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
FROM python:3.11-slim
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Install dependencies
|
||||||
|
COPY requirements.txt .
|
||||||
|
RUN pip install --no-cache-dir -r requirements.txt
|
||||||
|
|
||||||
|
# Copy application
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
# Create cache directory
|
||||||
|
RUN mkdir -p /data/cache
|
||||||
|
|
||||||
|
ENV PYTHONUNBUFFERED=1
|
||||||
|
|
||||||
|
# Default command runs the server
|
||||||
|
CMD ["python", "server.py"]
|
||||||
@@ -5,12 +5,15 @@ Distributed rendering for the Art DAG system.
|
|||||||
Uses the foundational artdag language from GitHub.
|
Uses the foundational artdag language from GitHub.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import os
|
||||||
from celery import Celery
|
from celery import Celery
|
||||||
|
|
||||||
|
REDIS_URL = os.environ.get('REDIS_URL', 'redis://localhost:6379/5')
|
||||||
|
|
||||||
app = Celery(
|
app = Celery(
|
||||||
'art_celery',
|
'art_celery',
|
||||||
broker='redis://localhost:6379/5',
|
broker=REDIS_URL,
|
||||||
backend='redis://localhost:6379/5',
|
backend=REDIS_URL,
|
||||||
include=['tasks']
|
include=['tasks']
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
58
docker-compose.yml
Normal file
58
docker-compose.yml
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
version: "3.8"
|
||||||
|
|
||||||
|
services:
|
||||||
|
redis:
|
||||||
|
image: redis:7-alpine
|
||||||
|
volumes:
|
||||||
|
- redis_data:/data
|
||||||
|
networks:
|
||||||
|
- artdag
|
||||||
|
deploy:
|
||||||
|
replicas: 1
|
||||||
|
restart_policy:
|
||||||
|
condition: on-failure
|
||||||
|
|
||||||
|
l1-server:
|
||||||
|
build: .
|
||||||
|
image: git.rose-ash.com/art-dag/l1-server:latest
|
||||||
|
ports:
|
||||||
|
- "8100:8100"
|
||||||
|
environment:
|
||||||
|
- REDIS_URL=redis://redis:6379/5
|
||||||
|
volumes:
|
||||||
|
- l1_cache:/data/cache
|
||||||
|
depends_on:
|
||||||
|
- redis
|
||||||
|
networks:
|
||||||
|
- artdag
|
||||||
|
deploy:
|
||||||
|
replicas: 1
|
||||||
|
restart_policy:
|
||||||
|
condition: on-failure
|
||||||
|
|
||||||
|
l1-worker:
|
||||||
|
build: .
|
||||||
|
image: git.rose-ash.com/art-dag/l1-server:latest
|
||||||
|
command: celery -A celery_app worker --loglevel=info
|
||||||
|
environment:
|
||||||
|
- REDIS_URL=redis://redis:6379/5
|
||||||
|
volumes:
|
||||||
|
- l1_cache:/data/cache
|
||||||
|
- effects:/app/effects
|
||||||
|
depends_on:
|
||||||
|
- redis
|
||||||
|
networks:
|
||||||
|
- artdag
|
||||||
|
deploy:
|
||||||
|
replicas: 2
|
||||||
|
restart_policy:
|
||||||
|
condition: on-failure
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
redis_data:
|
||||||
|
l1_cache:
|
||||||
|
effects:
|
||||||
|
|
||||||
|
networks:
|
||||||
|
artdag:
|
||||||
|
driver: overlay
|
||||||
13
server.py
13
server.py
@@ -21,16 +21,23 @@ from fastapi.responses import FileResponse
|
|||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
|
||||||
import redis
|
import redis
|
||||||
|
from urllib.parse import urlparse
|
||||||
|
|
||||||
from celery_app import app as celery_app
|
from celery_app import app as celery_app
|
||||||
from tasks import render_effect
|
from tasks import render_effect
|
||||||
|
|
||||||
# Cache directory
|
# Cache directory (use /data/cache in Docker, ~/.artdag/cache locally)
|
||||||
CACHE_DIR = Path.home() / ".artdag" / "cache"
|
CACHE_DIR = Path(os.environ.get("CACHE_DIR", str(Path.home() / ".artdag" / "cache")))
|
||||||
CACHE_DIR.mkdir(parents=True, exist_ok=True)
|
CACHE_DIR.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
# Redis for persistent run storage
|
# Redis for persistent run storage
|
||||||
redis_client = redis.Redis(host='localhost', port=6379, db=5)
|
REDIS_URL = os.environ.get('REDIS_URL', 'redis://localhost:6379/5')
|
||||||
|
parsed = urlparse(REDIS_URL)
|
||||||
|
redis_client = redis.Redis(
|
||||||
|
host=parsed.hostname or 'localhost',
|
||||||
|
port=parsed.port or 6379,
|
||||||
|
db=int(parsed.path.lstrip('/') or 0)
|
||||||
|
)
|
||||||
RUNS_KEY_PREFIX = "artdag:run:"
|
RUNS_KEY_PREFIX = "artdag:run:"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user