File size: 1,117 Bytes
a02272f
 
 
 
 
 
 
 
 
 
 
 
 
 
8c90fa7
a02272f
8c90fa7
b4375d4
8c90fa7
 
 
a02272f
 
 
8c90fa7
a02272f
 
8c90fa7
a02272f
 
 
 
 
 
 
 
8c90fa7
 
 
a02272f
 
ba8a3d1
 
 
a02272f
 
 
 
 
 
 
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
48
49
50
51
52
# Use Python 3.11 as base
FROM python:3.11-slim

# Install system dependencies
RUN apt-get update && apt-get install -y \
    curl \
    gnupg \
    && curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
    && apt-get install -y nodejs \
    && rm -rf /var/lib/apt/lists/*

# Set working directory
WORKDIR /app

# 1. Copy project structure first
COPY pyproject.toml .
COPY brain ./brain
COPY scripts ./scripts
COPY README.md .

# 2. Install the package so 'import brain' works
RUN pip install .
RUN pip install fastapi uvicorn

# 3. Copy backend
COPY web/backend ./web/backend

# 4. Copy frontend and build it
COPY web/frontend ./web/frontend
WORKDIR /app/web/frontend
RUN npm install
RUN npm run build

# Back to root
WORKDIR /app

# Copy the built binary (if present)
COPY dist ./dist

# Create a shell script to start both services
RUN echo '#!/bin/bash\n\
    uvicorn web.backend.main:app --host 0.0.0.0 --port 8000 &\n\
    cd web/frontend && npm run start -- -p 7860\n\
    ' > start.sh
RUN chmod +x start.sh

# Expose the port Hugging Face expects
EXPOSE 7860

# Start the services
CMD ["./start.sh"]