yukee1992 commited on
Commit
a012ae4
·
verified ·
1 Parent(s): 628eb7f

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +25 -4
Dockerfile CHANGED
@@ -1,6 +1,6 @@
1
- FROM python:3.10-slim
2
 
3
- # Minimal system dependencies
4
  RUN apt-get update && apt-get install -y \
5
  git \
6
  git-lfs \
@@ -10,11 +10,32 @@ RUN apt-get update && apt-get install -y \
10
  WORKDIR /app
11
  COPY . .
12
 
13
- # Install Python dependencies with memory optimizations
 
14
  RUN pip install --no-cache-dir \
15
- torch==2.2.0 \
16
  transformers==4.40.0 \
17
  gradio==4.24.0 \
18
  accelerate==0.29.0
19
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  CMD ["python", "app.py"]
 
1
+ FROM python:3.10-slim as builder
2
 
3
+ # System dependencies
4
  RUN apt-get update && apt-get install -y \
5
  git \
6
  git-lfs \
 
10
  WORKDIR /app
11
  COPY . .
12
 
13
+ # Install with separate layers for better caching
14
+ RUN pip install --no-cache-dir torch==2.2.0 --index-url https://download.pytorch.org/whl/cpu
15
  RUN pip install --no-cache-dir \
 
16
  transformers==4.40.0 \
17
  gradio==4.24.0 \
18
  accelerate==0.29.0
19
 
20
+ # Runtime image
21
+ FROM python:3.10-slim
22
+ WORKDIR /app
23
+
24
+ # Copy only necessary files
25
+ COPY --from=builder /usr/local/lib/python3.10/site-packages /usr/local/lib/python3.10/site-packages
26
+ COPY --from=builder /usr/local/bin/git-lfs /usr/local/bin/
27
+ COPY --from=builder /app/app.py .
28
+
29
+ # Environment variables
30
+ ENV PYTHONUNBUFFERED=1 \
31
+ GRADIO_SERVER_NAME=0.0.0.0 \
32
+ GRADIO_SERVER_PORT=7860 \
33
+ HF_TOKEN="" \
34
+ DEVICE="cpu"
35
+
36
+ # Health check
37
+ HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
38
+ CMD curl -f http://localhost:7860 || exit 1
39
+
40
+ EXPOSE 7860
41
  CMD ["python", "app.py"]