File size: 977 Bytes
4fd7030
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b9c42f6
4fd7030
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# Use an official Python runtime as the base image
FROM python:3.9-slim

# Set working directory
WORKDIR /app

# Install system dependencies
RUN apt-get update && apt-get install -y \
    build-essential \
    curl \
    && rm -rf /var/lib/apt/lists/*

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

# Install Python dependencies
RUN pip install --no-cache-dir -r requirements.txt

# Copy the application files
COPY . .

# Create necessary directories and ensure proper permissions
RUN mkdir -p data/ scripts/training/models \
    && chmod -R 755 static \
    && chmod -R 755 templates \
    && chown -R nobody:nogroup static templates

# Make port 8000 available (FastAPI default port)
EXPOSE 8000

# Set environment variable for FastAPI to listen on 0.0.0.0
ENV HOST=0.0.0.0
ENV PORT=8000

# Switch to non-root user
USER nobody

# Command to run the application using uvicorn
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000"]