Proff12 commited on
Commit
985928b
·
verified ·
1 Parent(s): 1328d81

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +6 -9
Dockerfile CHANGED
@@ -12,7 +12,6 @@ RUN npm install --frozen-lockfile
12
  COPY frontend/ ./
13
  RUN npm run build
14
 
15
- # --- Stage 2: GPU-enabled Python backend ---
16
  # --- Stage 2: GPU-enabled Python backend ---
17
  FROM nvidia/cuda:12.1.1-cudnn8-runtime-ubuntu22.04 AS backend
18
 
@@ -23,7 +22,7 @@ ENV DEBIAN_FRONTEND=noninteractive \
23
  PIP_NO_CACHE_DIR=1 \
24
  HF_HOME=/app/.cache/huggingface
25
 
26
- # Install Python and system dependencies BEFORE switching user
27
  RUN apt-get update && apt-get install -y --no-install-recommends \
28
  python3 python3-pip python3-venv git curl && \
29
  rm -rf /var/lib/apt/lists/*
@@ -31,17 +30,16 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
31
  # Create non-root user
32
  RUN useradd -m appuser
33
 
34
- # Create cache directory and set permissions
35
- RUN mkdir -p /app/.cache/huggingface && \
36
- chown -R appuser:appuser /app/.cache
 
37
 
38
  # Switch to non-root user
39
  USER appuser
40
 
41
  WORKDIR /app
42
 
43
- # Continue with pip installs and app setup...
44
-
45
  # Upgrade pip and install CUDA-enabled PyTorch
46
  RUN python3 -m pip install --upgrade pip && \
47
  python3 -m pip install --index-url https://download.pytorch.org/whl/cu121 torch==2.4.1+cu121
@@ -54,7 +52,6 @@ RUN python3 -m pip install -r /app/backend/requirements.txt
54
  COPY backend/ /app/backend/
55
 
56
  # Copy frontend build to static directory
57
- RUN mkdir -p /app/static
58
  COPY --from=frontend /app/frontend/dist/ /app/static/
59
 
60
  # App-specific environment variables
@@ -70,4 +67,4 @@ HEALTHCHECK --interval=30s --timeout=10s --start-period=10s --retries=3 \
70
  EXPOSE 8000
71
 
72
  # Start FastAPI app
73
- CMD ["uvicorn", "app.main:app", "--app-dir", "/app/backend", "--host", "0.0.0.0", "--port", "8000"]
 
12
  COPY frontend/ ./
13
  RUN npm run build
14
 
 
15
  # --- Stage 2: GPU-enabled Python backend ---
16
  FROM nvidia/cuda:12.1.1-cudnn8-runtime-ubuntu22.04 AS backend
17
 
 
22
  PIP_NO_CACHE_DIR=1 \
23
  HF_HOME=/app/.cache/huggingface
24
 
25
+ # Install system dependencies BEFORE switching user
26
  RUN apt-get update && apt-get install -y --no-install-recommends \
27
  python3 python3-pip python3-venv git curl && \
28
  rm -rf /var/lib/apt/lists/*
 
30
  # Create non-root user
31
  RUN useradd -m appuser
32
 
33
+ # Create necessary directories and set permissions
34
+ RUN mkdir -p /app/.cache/huggingface \
35
+ && mkdir -p /app/static \
36
+ && chown -R appuser:appuser /app
37
 
38
  # Switch to non-root user
39
  USER appuser
40
 
41
  WORKDIR /app
42
 
 
 
43
  # Upgrade pip and install CUDA-enabled PyTorch
44
  RUN python3 -m pip install --upgrade pip && \
45
  python3 -m pip install --index-url https://download.pytorch.org/whl/cu121 torch==2.4.1+cu121
 
52
  COPY backend/ /app/backend/
53
 
54
  # Copy frontend build to static directory
 
55
  COPY --from=frontend /app/frontend/dist/ /app/static/
56
 
57
  # App-specific environment variables
 
67
  EXPOSE 8000
68
 
69
  # Start FastAPI app
70
+ CMD ["uvicorn", "app.main:app", "--app-dir", "/app/backend", "--host", "0.0.0.0", "--port", "8000"]