File size: 1,425 Bytes
ad8c65e
 
 
 
 
 
 
 
 
 
1d8ce4e
 
 
5330a03
ad8c65e
 
 
 
 
 
5330a03
ad8c65e
 
 
 
 
1d8ce4e
ad8c65e
 
 
 
 
 
ba14f83
 
ad8c65e
 
 
 
5330a03
ba14f83
1d8ce4e
 
5330a03
1d8ce4e
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# Use an official Python runtime as a parent image
FROM python:3.12-slim

# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
ENV PORT=7860
ENV RUN_MONOLITH=true
ENV USE_NGINX=true

# Disable Mem0 telemetry
ENV MEM0_TELEMETRY=false

# Install system dependencies (Graphviz for diagrams, Nginx for reverse proxy, Redis for caching)
RUN apt-get update && apt-get install -y \
    graphviz \
    libgraphviz-dev \
    pkg-config \
    build-essential \
    nginx \
    redis-server \
    && rm -rf /var/lib/apt/lists/*

# Set working directory
WORKDIR /app

# Copy requirements and install Python deps
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# Copy the rest of the application
COPY . .

# Create runtime directories and make everything writable for non-root user 1000 (Hugging Face requirement)
RUN mkdir -p logs storage && chmod -R 777 /app

# Expose the port Hugging Face expects (7860)
EXPOSE 7860

# Run uvicorn backend + nginx reverse proxy + redis server
# Streamlit frontend is launched as a sidecar by FastAPI startup event
CMD ["sh", "-c", "\
  mkdir -p /tmp/nginx_client_body /tmp/nginx_proxy /tmp/nginx_fastcgi /tmp/nginx_uwsgi /tmp/nginx_scgi && \
  redis-server --port 6379 --daemonize yes --protected-mode no --dir /app/storage & \
  python3 -m uvicorn backend.main:app --host 127.0.0.1 --port 8000 & \
  nginx -c /app/nginx.conf -g 'daemon off;'"]