Spanicin commited on
Commit
2589745
·
verified ·
1 Parent(s): e6802a0

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +44 -32
Dockerfile CHANGED
@@ -1,32 +1,44 @@
1
- # Stage 1: Build stage (installs docker)
2
- FROM python:3.9.13 AS builder
3
-
4
- RUN apt-get update && apt-get install -y docker-ce
5
-
6
- # Clear build cache
7
- RUN docker builder prune -f
8
-
9
- FROM python:3.9.13
10
-
11
- USER root
12
- RUN apt-get update && \
13
- apt-get install -y libgl1-mesa-glx ffmpeg
14
-
15
- RUN useradd -m -u 1000 user
16
- USER user
17
- ENV HOME=/home/user \
18
- PATH=/home/user/.local/bin:$PATH
19
-
20
- WORKDIR $HOME/app
21
-
22
- COPY --chown=user . $HOME/app
23
-
24
- RUN chmod +x scripts/download_models.sh
25
- RUN bash scripts/download_models.sh
26
- ENV NUMBA_CACHE_DIR=/tmp/numba_cache
27
- RUN pip install -r requirements.txt
28
-
29
- # CMD ["gunicorn", "-b", "0.0.0.0:7860","app:app"]
30
- CMD ["gunicorn", "-b", "0.0.0.0:7860", "--timeout", "180", "app:app"]
31
-
32
- #CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Stage 1: Build stage (installs docker)
2
+ FROM python:3.9.13 AS builder
3
+
4
+ RUN apt-get update && apt-get install -y \
5
+ docker-ce \
6
+ && apt-get clean \
7
+ && rm -rf /var/lib/apt/lists/*
8
+
9
+ # Clear build cache
10
+ RUN docker builder prune -f
11
+
12
+ # Stage 2: Final stage
13
+ FROM python:3.9.13
14
+
15
+ USER root
16
+ RUN apt-get update && \
17
+ apt-get install -y \
18
+ libgl1-mesa-glx \
19
+ ffmpeg \
20
+ git \
21
+ && apt-get clean \
22
+ && rm -rf /var/lib/apt/lists/*
23
+
24
+ RUN useradd -m -u 1000 user
25
+ USER user
26
+ ENV HOME=/home/user \
27
+ PATH=/home/user/.local/bin:$PATH \
28
+ NUMBA_CACHE_DIR=/tmp/numba_cache
29
+
30
+ WORKDIR $HOME/app
31
+
32
+ COPY --chown=user . $HOME/app
33
+
34
+ # Clone pretrained models
35
+ RUN git clone https://huggingface.co/fudan-generative-ai/hallo pretrained_models
36
+
37
+ # Install Python dependencies
38
+ RUN pip install --no-cache-dir -r requirements.txt
39
+
40
+ # Install the current package
41
+ RUN pip install .
42
+
43
+ # Set the command to run the application
44
+ CMD ["gunicorn", "-b", "0.0.0.0:7860", "--timeout", "300", "app_hallo:app"]