ghost1112 commited on
Commit
a42df39
·
verified ·
1 Parent(s): 2fc9665

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +58 -42
Dockerfile CHANGED
@@ -1,42 +1,58 @@
1
- # Use the official Python image from the Docker Hub
2
- FROM python:3.10-slim
3
-
4
- # Set up a new user named "user" with user ID 1000
5
- RUN useradd -m -u 1000 user
6
-
7
- # Set environment variables for the cache directory (use a writable directory)
8
- ENV TRANSFORMERS_CACHE=/home/user/.cache/huggingface
9
-
10
- # Create and set the cache directory so the user can write to it
11
- RUN mkdir -p /home/user/.cache/huggingface && chown -R user:user /home/user/.cache
12
-
13
- # Switch to the "user" user
14
- USER user
15
-
16
- # Set home to the user's home directory
17
- ENV HOME=/home/user \
18
- PATH=/home/user/.local/bin:$PATH
19
-
20
- # Set the working directory to the user's home directory
21
- WORKDIR $HOME/app
22
-
23
- # Upgrade pip to the latest version to avoid issues with outdated pip
24
- RUN pip install --no-cache-dir --upgrade pip
25
-
26
- # Copy the current directory contents into the container at $HOME/app setting the owner to the user
27
- COPY --chown=user . $HOME/app
28
-
29
- # Install dependencies
30
- RUN pip install --no-cache-dir -r requirements.txt
31
-
32
- # Download any necessary assets
33
- RUN mkdir content
34
- ADD --chown=user https://huggingface.co/datasets/manhteky123/LawVietnamese/resolve/main/data.csv content/data.csv
35
- ADD --chown=user https://huggingface.co/datasets/manhteky123/LawVietnamese/resolve/main/faiss_index.bin content/faiss_index.bin
36
- ADD --chown=user https://huggingface.co/datasets/manhteky123/LawVietnamese/resolve/main/vectors.npy content/vectors.npy
37
-
38
- # Expose the port the app runs on
39
- EXPOSE 5000
40
-
41
- # Define the command to run the application
42
- CMD ["python", "app.py"]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Use the official Python image from the Docker Hub
2
+ FROM python:3.10-slim
3
+
4
+ # Set up a new user named "user" with user ID 1000
5
+ RUN useradd -m -u 1000 user
6
+
7
+ # Install system dependencies
8
+ RUN apt-get update && apt-get install -y \
9
+ build-essential \
10
+ curl \
11
+ software-properties-common \
12
+ git \
13
+ && rm -rf /var/lib/apt/lists/*
14
+
15
+ # Set environment variables for the cache directory (use a writable directory)
16
+ ENV TRANSFORMERS_CACHE=/home/user/.cache/huggingface
17
+ ENV STREAMLIT_SERVER_PORT=7860
18
+ ENV STREAMLIT_SERVER_ADDRESS=0.0.0.0
19
+
20
+ # Create and set the cache directory so the user can write to it
21
+ RUN mkdir -p /home/user/.cache/huggingface && chown -R user:user /home/user/.cache
22
+
23
+ # Switch to the "user" user
24
+ USER user
25
+
26
+ # Set home to the user's home directory
27
+ ENV HOME=/home/user \
28
+ PATH=/home/user/.local/bin:$PATH
29
+
30
+ # Set the working directory to the user's home directory
31
+ WORKDIR $HOME/app
32
+
33
+ # Upgrade pip to the latest version to avoid issues with outdated pip
34
+ RUN pip install --no-cache-dir --upgrade pip
35
+
36
+ # Copy the current directory contents into the container at $HOME/app setting the owner to the user
37
+ COPY --chown=user . $HOME/app
38
+
39
+ # Install dependencies
40
+ RUN pip install --no-cache-dir -r requirements.txt
41
+
42
+ # Download any necessary assets
43
+ RUN mkdir -p content
44
+ ADD --chown=user https://huggingface.co/datasets/manhteky123/LawVietnamese/resolve/main/data.csv content/data.csv
45
+ ADD --chown=user https://huggingface.co/datasets/manhteky123/LawVietnamese/resolve/main/faiss_index.bin content/faiss_index.bin
46
+ ADD --chown=user https://huggingface.co/datasets/manhteky123/LawVietnamese/resolve/main/vectors.npy content/vectors.npy
47
+
48
+ # Create .streamlit directory and config
49
+ RUN mkdir -p .streamlit
50
+
51
+ # Health check for Streamlit
52
+ HEALTHCHECK CMD curl --fail http://localhost:7860/_stcore/health || exit 1
53
+
54
+ # Expose the port the app runs on (change from 5000 to 7860 for Streamlit)
55
+ EXPOSE 7860
56
+
57
+ # Define the command to run the Streamlit application
58
+ CMD ["streamlit", "run", "app.py", "--server.port=7860", "--server.address=0.0.0.0", "--server.headless=true", "--server.enableCORS=false", "--server.enableXsrfProtection=false"]