sebastiansarasti commited on
Commit
d4b0223
·
1 Parent(s): aabfab4

solving root user

Browse files
Files changed (1) hide show
  1. Dockerfile +18 -1
Dockerfile CHANGED
@@ -1,16 +1,33 @@
1
  FROM python:3.11-slim
2
 
 
3
  WORKDIR /app
 
 
4
  COPY requirements.txt requirements.txt
5
  COPY src/ ./src
6
 
 
7
  RUN pip install uv
8
  RUN uv pip install --system -r requirements.txt
9
 
 
 
 
 
 
 
10
  ENV HF_HOME=/app/cache
 
 
 
 
11
 
 
12
  EXPOSE 8501
13
 
14
- HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
 
15
 
 
16
  ENTRYPOINT ["streamlit", "run", "src/app.py", "--server.port=8501", "--server.address=0.0.0.0"]
 
1
  FROM python:3.11-slim
2
 
3
+ # Set working directory
4
  WORKDIR /app
5
+
6
+ # Copy files
7
  COPY requirements.txt requirements.txt
8
  COPY src/ ./src
9
 
10
+ # Install uv and Python packages
11
  RUN pip install uv
12
  RUN uv pip install --system -r requirements.txt
13
 
14
+ # Create non-root user and give permissions
15
+ RUN useradd -m appuser && \
16
+ mkdir -p /app/cache /app/.streamlit && \
17
+ chown -R appuser:appuser /app
18
+
19
+ # Set environment variables for Hugging Face and Streamlit
20
  ENV HF_HOME=/app/cache
21
+ ENV STREAMLIT_CONFIG_DIR=/app/.streamlit
22
+
23
+ # Switch to non-root user
24
+ USER appuser
25
 
26
+ # Expose Streamlit port
27
  EXPOSE 8501
28
 
29
+ # Healthcheck
30
+ HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health || exit 1
31
 
32
+ # Run Streamlit app
33
  ENTRYPOINT ["streamlit", "run", "src/app.py", "--server.port=8501", "--server.address=0.0.0.0"]