File size: 1,138 Bytes
abf702c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# Stage 1: Build the frontend
FROM node:20 as frontend-builder

WORKDIR /app/frontend
COPY frontend/package*.json ./
RUN npm install
COPY frontend/ ./
RUN npm run build

# Stage 2: Build the backend and serve everything
FROM python:3.11-slim

WORKDIR /app

# Copy backend code
COPY backend/ ./backend

# Corrected: Copy built frontend assets to backend/static (where main.py expects them)
COPY --from=frontend-builder /app/frontend/dist ./backend/static

# Install backend dependencies
# Install uv
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/

# Install backend dependencies using uv into a virtual environment
# We install from the /app/backend directory where pyproject.toml is located
WORKDIR /app/backend
RUN uv venv /app/.venv
RUN uv pip install .

# Reset workdir
WORKDIR /app

# Enable venv
ENV VIRTUAL_ENV=/app/.venv
ENV PATH="/app/.venv/bin:$PATH"

# Environment variables
ENV PORT=7860
ENV FRONTEND_URL=""
ENV PYTHONPATH="/app/backend"

# Expose the port
EXPOSE 7860

# Command to run the application
CMD ["sh", "-c", "uvicorn app.main:app --host 0.0.0.0 --port $PORT"]