saemstunes commited on
Commit
edb2757
·
verified ·
1 Parent(s): 5b940b3

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +24 -10
Dockerfile CHANGED
@@ -1,11 +1,21 @@
 
 
 
 
 
 
 
 
 
1
  FROM python:3.11-slim
2
 
3
  # Set environment variables
4
  ENV PYTHONUNBUFFERED=1
5
  ENV PYTHONPATH=/app
6
- ENV PORT=8000
7
  ENV MODEL_NAME=microsoft/Phi-3.5-mini-instruct
8
  ENV LOG_LEVEL=INFO
 
9
 
10
  # Install system dependencies
11
  RUN apt-get update && apt-get install -y \
@@ -19,14 +29,18 @@ WORKDIR /app
19
 
20
  # Copy requirements first for better caching
21
  COPY requirements.txt .
 
22
 
23
- # Install Python dependencies
24
- RUN pip install --upgrade pip
25
- RUN pip install -r requirements.txt
26
 
27
- # Copy application code
28
  COPY . .
29
 
 
 
 
30
  # Create necessary directories
31
  RUN mkdir -p models logs static
32
 
@@ -35,12 +49,12 @@ RUN useradd -m -u 1000 saemsai
35
  RUN chown -R saemsai:saemsai /app
36
  USER saemsai
37
 
38
- # Expose port
39
- EXPOSE 8000
40
 
41
- # Health check
42
  HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
43
- CMD curl -f http://localhost:8000/health || exit 1
44
 
45
  # Start application
46
- CMD ["python", "railway_app.py"]
 
1
+ # ---------- Frontend build ----------
2
+ FROM node:18 AS frontend-builder
3
+ WORKDIR /frontend
4
+ COPY frontend/package*.json ./
5
+ RUN npm ci
6
+ COPY frontend .
7
+ RUN npm run build
8
+
9
+ # ---------- Backend build ----------
10
  FROM python:3.11-slim
11
 
12
  # Set environment variables
13
  ENV PYTHONUNBUFFERED=1
14
  ENV PYTHONPATH=/app
15
+ ENV PORT=8080
16
  ENV MODEL_NAME=microsoft/Phi-3.5-mini-instruct
17
  ENV LOG_LEVEL=INFO
18
+ ENV RAILWAY_ENVIRONMENT=production
19
 
20
  # Install system dependencies
21
  RUN apt-get update && apt-get install -y \
 
29
 
30
  # Copy requirements first for better caching
31
  COPY requirements.txt .
32
+ RUN pip install --upgrade pip && pip install -r requirements.txt
33
 
34
+ # Copy scripts first (so model can download before code changes)
35
+ COPY scripts/download_model.py ./scripts/
36
+ RUN python scripts/download_model.py
37
 
38
+ # Copy all backend code
39
  COPY . .
40
 
41
+ # Copy built frontend assets from Node stage
42
+ COPY --from=frontend-builder /frontend/dist ./static
43
+
44
  # Create necessary directories
45
  RUN mkdir -p models logs static
46
 
 
49
  RUN chown -R saemsai:saemsai /app
50
  USER saemsai
51
 
52
+ # Expose port (MUST MATCH RAILWAY CONFIG)
53
+ EXPOSE 8080
54
 
55
+ # Health check (uses internal port)
56
  HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
57
+ CMD curl -f http://localhost:8080/api/health || exit 1
58
 
59
  # Start application
60
+ CMD ["python", "railway_app.py"]