HacksterT commited on
Commit
da21126
·
verified ·
1 Parent(s): e6e6445

Upload Dockerfile with huggingface_hub

Browse files
Files changed (1) hide show
  1. Dockerfile +38 -21
Dockerfile CHANGED
@@ -1,21 +1,38 @@
1
- FROM python:3.9-slim
2
-
3
- WORKDIR /app
4
-
5
- RUN apt-get update && apt-get install -y \
6
- build-essential \
7
- curl \
8
- software-properties-common \
9
- git \
10
- && rm -rf /var/lib/apt/lists/*
11
-
12
- COPY requirements.txt ./
13
- COPY src/ ./src/
14
-
15
- RUN pip3 install -r requirements.txt
16
-
17
- EXPOSE 8501
18
-
19
- HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
20
-
21
- ENTRYPOINT ["streamlit", "run", "src/streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Use a minimal base image with Python 3.9 installed
2
+ FROM python:3.9-slim
3
+
4
+ # Set the working directory inside the container to /app
5
+ WORKDIR /app
6
+
7
+ # Create a non-root user for security and permissions
8
+ RUN useradd --create-home --shell /bin/bash app_user
9
+
10
+ # Create .streamlit directory with proper permissions
11
+ RUN mkdir -p /home/app_user/.streamlit && \
12
+ chown -R app_user:app_user /home/app_user/.streamlit
13
+
14
+ # Copy all files from the current directory on the host to the container's /app directory
15
+ COPY . .
16
+
17
+ # Install Python dependencies listed in requirements.txt
18
+ RUN pip3 install -r requirements.txt
19
+
20
+ # Change ownership of app directory to app_user
21
+ RUN chown -R app_user:app_user /app
22
+
23
+ # Switch to non-root user
24
+ USER app_user
25
+
26
+ # Set HOME environment variable
27
+ ENV HOME=/home/app_user
28
+
29
+ # Create Streamlit config to disable usage stats and set proper permissions
30
+ RUN mkdir -p $HOME/.streamlit && \
31
+ echo "[browser]" > $HOME/.streamlit/config.toml && \
32
+ echo "gatherUsageStats = false" >> $HOME/.streamlit/config.toml && \
33
+ echo "[server]" >> $HOME/.streamlit/config.toml && \
34
+ echo "enableXsrfProtection = false" >> $HOME/.streamlit/config.toml && \
35
+ echo "enableCORS = false" >> $HOME/.streamlit/config.toml
36
+
37
+ # Define the command to run the Streamlit app on port 8501 and make it accessible externally
38
+ CMD ["streamlit", "run", "app.py", "--server.port=8501", "--server.address=0.0.0.0"]