MAS-AI-0000 commited on
Commit
1da3a1c
·
verified ·
1 Parent(s): 135e71f

Update dockerfile

Browse files
Files changed (1) hide show
  1. dockerfile +41 -34
dockerfile CHANGED
@@ -1,34 +1,41 @@
1
- # Use Python base image
2
- FROM python:3.12
3
-
4
- # Set working directory
5
- WORKDIR /app
6
-
7
- # Install system dependencies
8
- RUN apt-get update && apt-get install -y \
9
- git \
10
- libgl1 \
11
- libglib2.0-0 \
12
- libsm6 \
13
- libxext6 \
14
- libxrender1 \
15
- && rm -rf /var/lib/apt/lists/*
16
-
17
-
18
- # Copy requirements file
19
- COPY requirements.txt .
20
-
21
- # Install Python dependencies
22
- RUN pip install --no-cache-dir -r requirements.txt
23
-
24
- RUN python -c "import clip; clip.load('ViT-B/32', device = 'cpu', jit=False)"
25
-
26
- # Copy the application code and models
27
- COPY ./Apps ./Apps
28
- COPY ./Lib/Models ./Models
29
-
30
- # Expose the port
31
- EXPOSE 8000
32
-
33
- # Command to run the FastAPI application
34
- CMD ["uvicorn", "Apps.app:app", "--host", "0.0.0.0", "--port", "8000"]
 
 
 
 
 
 
 
 
1
+ # Use official Python base (slim to keep image small)
2
+ FROM python:3.12-slim
3
+
4
+
5
+ # Install system dependencies
6
+ RUN apt-get update && apt-get install -y \
7
+ git \
8
+ libgl1 \
9
+ libglib2.0-0 \
10
+ libsm6 \
11
+ libxext6 \
12
+ libxrender1 \
13
+ && rm -rf /var/lib/apt/lists/*
14
+
15
+
16
+ # Create and switch to a non-root user
17
+ RUN useradd -m -u 1000 user
18
+ USER user
19
+ ENV PATH="/home/user/.local/bin:$PATH"
20
+
21
+
22
+ # Set working directory
23
+ WORKDIR /app
24
+
25
+ # Copy requirements first (better cache)
26
+ COPY --chown=user ./requirements.txt requirements.txt
27
+
28
+ # Upgrade pip and install deps
29
+ RUN python -m pip install --no-cache-dir --upgrade pip \
30
+ && pip install --no-cache-dir -r requirements.txt
31
+
32
+ RUN python -c "import clip; clip.load('ViT-B/32', device = 'cpu', jit=False)"
33
+
34
+ # Copy app code
35
+ COPY --chown=user . /app
36
+
37
+ # Expose the default Spaces port
38
+ EXPOSE 7860
39
+
40
+ # Run FastAPI server (Spaces sets $PORT, default to 7860)
41
+ CMD ["bash", "-lc", "uvicorn app:app --host 0.0.0.0 --port ${PORT:-7860}"]