tuan243 commited on
Commit
98b4fb6
·
verified ·
1 Parent(s): 0611a82

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +12 -4
Dockerfile CHANGED
@@ -1,10 +1,18 @@
1
  FROM python:3.9
2
 
 
 
 
 
 
3
  WORKDIR /app
4
 
5
- COPY requirements.txt /app/
6
- RUN pip install --no-cache-dir -r requirements.txt
 
7
 
8
- COPY . /app/
 
9
 
10
- CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
 
 
1
  FROM python:3.9
2
 
3
+ # Tạo user không root để tăng tính bảo mật
4
+ RUN useradd -m -u 1000 user
5
+ USER user
6
+
7
+ # Cài đặt thư mục làm việc
8
  WORKDIR /app
9
 
10
+ # Cài đặt các dependencies
11
+ COPY --chown=user ./requirements.txt requirements.txt
12
+ RUN pip install --no-cache-dir --upgrade -r requirements.txt
13
 
14
+ # Copy toàn bộ mã nguồn vào container
15
+ COPY --chown=user . /app
16
 
17
+ # Chạy ứng dụng FastAPI trên cổng 7860
18
+ CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]