File size: 1,165 Bytes
edb2757
9c7e96a
 
 
 
 
edb2757
6d909e0
 
edb2757
9c7e96a
 
 
 
 
6d909e0
9c7e96a
 
 
 
 
 
 
edb2757
9c7e96a
edb2757
 
 
9c7e96a
edb2757
9c7e96a
 
6d909e0
 
 
9c7e96a
 
 
 
 
edb2757
 
9c7e96a
edb2757
9c7e96a
edb2757
9c7e96a
 
edb2757
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

FROM python:3.11-slim

# Set environment variables
ENV PYTHONUNBUFFERED=1
ENV PYTHONPATH=/app
ENV PORT=8080
ENV MODEL_NAME=microsoft/Phi-3.5-mini-instruct
ENV LOG_LEVEL=INFO
ENV RAILWAY_ENVIRONMENT=production

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

# Create application directory
WORKDIR /app

# Copy requirements first for better caching
COPY requirements.txt .
RUN pip install --upgrade pip && pip install -r requirements.txt

# Copy scripts first (so model can download before code changes)
COPY scripts/download_model.py ./scripts/
RUN python scripts/download_model.py

# Copy all backend code
COPY . .

# Create necessary directories
RUN mkdir -p models logs static

# Create non-root user
RUN useradd -m -u 1000 saemsai
RUN chown -R saemsai:saemsai /app
USER saemsai

# Expose port (MUST MATCH RAILWAY CONFIG)
EXPOSE 8080

# Health check (uses internal port)
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
    CMD curl -f http://localhost:8080/api/health || exit 1

# Start application
CMD ["python", "railway_app.py"]