akashraut commited on
Commit
6ffd709
·
verified ·
1 Parent(s): 1b8dbab

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +19 -21
Dockerfile CHANGED
@@ -1,36 +1,34 @@
 
1
  FROM python:3.10-slim
2
 
 
3
  WORKDIR /app
4
 
5
- # Copy and install your Python deps
6
- COPY requirements.txt /app/requirements.txt
 
 
7
  RUN pip install --no-cache-dir -r requirements.txt
8
 
9
- # Copy in your Streamlit source
10
- COPY src/ /app/src/
11
 
12
- # Expose the port Streamlit will run on
13
  EXPOSE 8501
14
 
15
- # 1️⃣ Create a non-root user
16
  RUN useradd -m -u 1000 user
17
 
18
- # 2️⃣ Create writable cache directories and change ownership
19
- RUN mkdir -p /tmp/.cache/transformers \
20
- /tmp/.cache/huggingface \
21
- /tmp/.cache/xdg \
22
- /tmp/.streamlit && \
23
- chown -R user:user /tmp/.cache
24
 
25
- # 3️⃣ Switch to the non-root user
26
  USER user
27
 
28
- # 4️⃣ Point all caches and Streamlit config into /tmp
29
- ENV TRANSFORMERS_CACHE=/tmp/.cache/transformers \
30
- HF_HOME=/tmp/.cache/huggingface \
31
- XDG_CACHE_HOME=/tmp/.cache/xdg \
32
- STREAMLIT_CONFIG_DIR=/tmp/.streamlit
33
 
34
- # 5️⃣ Launch your app
35
- ENTRYPOINT ["streamlit", "run", "src/streamlit_app.py", \
36
- "--server.port=8501", "--server.address=0.0.0.0"]
 
1
+ # Use the official Python 3.10 slim image as a base
2
  FROM python:3.10-slim
3
 
4
+ # Set the working directory inside the container
5
  WORKDIR /app
6
 
7
+ # Copy the requirements file into the container
8
+ COPY requirements.txt ./requirements.txt
9
+
10
+ # Install the Python dependencies
11
  RUN pip install --no-cache-dir -r requirements.txt
12
 
13
+ # Copy your Streamlit application file into the container
14
+ COPY streamlit_app.py ./streamlit_app.py
15
 
16
+ # Expose the port that Streamlit will run on
17
  EXPOSE 8501
18
 
19
+ # Create a non-root user for security
20
  RUN useradd -m -u 1000 user
21
 
22
+ # Set up writable cache directories and give the new user ownership
23
+ RUN mkdir -p /home/user/.cache && \
24
+ chown -R user:user /home/user/.cache
 
 
 
25
 
26
+ # Switch to the non-root user
27
  USER user
28
 
29
+ # Set environment variables to point to the new cache directories
30
+ ENV TRANSFORMERS_CACHE=/home/user/.cache/transformers \
31
+ HF_HOME=/home/user/.cache/huggingface
 
 
32
 
33
+ # The command to run your Streamlit application when the container starts
34
+ ENTRYPOINT ["streamlit", "run", "streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]