File size: 1,405 Bytes
68f9b9e
 
 
 
 
 
 
a41986a
68f9b9e
 
 
 
 
 
5bd1fb0
68f9b9e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
341da73
68f9b9e
 
 
 
5729ee7
 
68f9b9e
341da73
 
 
 
68f9b9e
341da73
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
# Use an official Python runtime as a parent image
FROM python:3.11-slim

# Set environment variables
ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONPATH=/app/backend
ENV KERAS_BACKEND=torch

# Set the working directory in the container
WORKDIR /app

# Install system dependencies for OpenCV and other libraries
RUN apt-get update && apt-get install -y --no-install-recommends \
    libgl1 \
    libglib2.0-0 \
    libsm6 \
    libxext6 \
    libxrender-dev \
    gcc \
    python3-dev \
    && rm -rf /var/lib/apt/lists/*

# Copy only the requirements first to leverage Docker cache
COPY backend/requirements.txt .

# Install dependencies
# Note: This will install CPU versions of torch to keep the image size manageable
# since most standard cloud servers don't have GPUs.
RUN pip install --no-cache-dir -r requirements.txt

# Copy the backend and frontend directories into the container
COPY backend /app/backend
COPY frontend /app/frontend

# Create necessary directories for runtime data
RUN mkdir -p /app/backend/data/uploads/emotions \
    /app/backend/data/uploads/diary \
    /app/backend/data/reports

# Expose the port (Hugging Face uses 7860 by default)
EXPOSE 7860

# Set working directory to backend for runtime
WORKDIR /app/backend
ENV PYTHONPATH=/app/backend

# Run the application using uvicorn
CMD ["sh", "-c", "uvicorn app.main:app --host 0.0.0.0 --port ${PORT:-7860}"]