kltn20133118 commited on
Commit
c2ff1e7
·
verified ·
1 Parent(s): 599aa40

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +29 -9
Dockerfile CHANGED
@@ -1,14 +1,34 @@
1
- FROM python:3.11
 
 
 
2
  WORKDIR /code
3
 
4
- RUN apt-get update && apt-get install ffmpeg libsm6 libxext6 -y
5
- RUN apt-get update && apt-get install -y poppler-utils
6
- RUN mkdir -p /code
 
 
 
 
 
 
 
 
 
7
 
8
- USER root
9
- RUN chmod -R 777 /code
10
 
 
11
  COPY ./requirements.txt /code/requirements.txt
12
- RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
13
- COPY . .
14
- CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860", "--reload"]
 
 
 
 
 
 
 
 
1
+ # Sử dụng Python 3.11 làm base image
2
+ FROM python:3.11-slim
3
+
4
+ # Đặt thư mục làm việc là /code
5
  WORKDIR /code
6
 
7
+ # Cập nhật package list cài đặt các thư viện cần thiết
8
+ RUN apt-get update && apt-get install -y \
9
+ ffmpeg \
10
+ libsm6 \
11
+ libxext6 \
12
+ poppler-utils \
13
+ && apt-get clean \
14
+ && rm -rf /var/lib/apt/lists/*
15
+
16
+ # Thiết lập biến môi trường HOME
17
+ ENV HOME=/code
18
+ ENV XDG_CACHE_HOME=/code/.cache
19
 
20
+ # Tạo thư mục cache và đảm bảo quyền ghi
21
+ RUN mkdir -p /code/.cache && chmod -R 777 /code
22
 
23
+ # Copy tệp requirements.txt vào container
24
  COPY ./requirements.txt /code/requirements.txt
25
+
26
+ # Cài đặt các dependencies từ requirements.txt
27
+ RUN pip install --no-cache-dir --upgrade pip && \
28
+ pip install --no-cache-dir --upgrade -r /code/requirements.txt
29
+
30
+ # Copy toàn bộ mã nguồn vào container
31
+ COPY . .
32
+
33
+ # Lệnh để chạy ứng dụng với Uvicorn
34
+ CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860", "--reload"]