vumichien commited on
Commit
605edb2
·
1 Parent(s): fdc7ec8

Add application file

Browse files
Files changed (1) hide show
  1. Dockerfile +14 -15
Dockerfile CHANGED
@@ -2,21 +2,6 @@ FROM python:3.9-slim
2
 
3
  WORKDIR /app
4
 
5
- # Cài đặt các dependencies cần thiết
6
- RUN apt-get update && apt-get install -y \
7
- build-essential \
8
- git \
9
- && rm -rf /var/lib/apt/lists/*
10
-
11
- # Tạo các thư mục cần thiết và cấp quyền
12
- RUN mkdir -p /app/data /app/temp /tmp/huggingface-cache && \
13
- chmod -R 777 /app/data /app/temp /tmp/huggingface-cache && \
14
- chown -R 1000:1000 /app/data /app/temp /tmp/huggingface-cache
15
-
16
- ENV TRANSFORMERS_CACHE=/tmp/huggingface-cache
17
- ENV HF_HOME=/tmp/huggingface-cache
18
- ENV HF_DATASETS_CACHE=/tmp/huggingface-cache
19
-
20
  # Copy requirements first for better caching
21
  COPY requirements.txt .
22
 
@@ -26,6 +11,16 @@ RUN pip install --no-cache-dir -r requirements.txt
26
  # Copy the rest of the application
27
  COPY . .
28
 
 
 
 
 
 
 
 
 
 
 
29
  # Expose the port that the app will run on
30
  EXPOSE 7860
31
 
@@ -34,5 +29,9 @@ ENV PYTHONUNBUFFERED=1
34
  ENV HOST=0.0.0.0
35
  ENV PORT=7860
36
 
 
 
 
 
37
  # Command to run the application
38
  CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
 
2
 
3
  WORKDIR /app
4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  # Copy requirements first for better caching
6
  COPY requirements.txt .
7
 
 
11
  # Copy the rest of the application
12
  COPY . .
13
 
14
+ # Create necessary directories with proper permissions
15
+ RUN mkdir -p /app/data /app/temp /tmp/huggingface-cache && \
16
+ chmod -R 777 /app/data /app/temp /tmp/huggingface-cache && \
17
+ chown -R 1000:1000 /app/data /app/temp /tmp/huggingface-cache
18
+
19
+ # Set environment variables for cache locations
20
+ ENV TRANSFORMERS_CACHE=/tmp/huggingface-cache
21
+ ENV HF_HOME=/tmp/huggingface-cache
22
+ ENV SENTENCE_TRANSFORMERS_HOME=/tmp/huggingface-cache
23
+
24
  # Expose the port that the app will run on
25
  EXPOSE 7860
26
 
 
29
  ENV HOST=0.0.0.0
30
  ENV PORT=7860
31
 
32
+ # Switch to non-root user for better security
33
+ RUN useradd -m -u 1000 appuser
34
+ USER appuser
35
+
36
  # Command to run the application
37
  CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]