TensorGuy01 commited on
Commit
54cea74
·
verified ·
1 Parent(s): ff71fd7

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +15 -4
Dockerfile CHANGED
@@ -1,17 +1,28 @@
 
1
  FROM python:3.10-slim
2
 
 
3
  WORKDIR /app
4
 
5
  # Install system dependencies
6
  RUN apt-get update && \
7
- apt-get install -y gcc && \
8
  rm -rf /var/lib/apt/lists/*
9
 
 
 
 
 
 
10
 
11
- # Copy source code
12
- COPY app.py .
13
 
14
- # Expose port 7860 for Flask
 
 
 
15
  EXPOSE 7860
16
 
 
17
  CMD ["python", "app.py"]
 
1
+ # Use official lightweight Python image
2
  FROM python:3.10-slim
3
 
4
+ # Set a working directory with write permissions
5
  WORKDIR /app
6
 
7
  # Install system dependencies
8
  RUN apt-get update && \
9
+ apt-get install -y --no-install-recommends gcc libgl1 libglib2.0-0 && \
10
  rm -rf /var/lib/apt/lists/*
11
 
12
+ # Create a non-root user and switch to it
13
+ RUN adduser --disabled-password --gecos '' appuser
14
+ USER appuser
15
+ ENV HOME=/home/appuser
16
+ ENV PATH="${HOME}/.local/bin:${PATH}"
17
 
18
+ # Copy the app script (assumes app.py is in the same folder)
19
+ COPY --chown=appuser:appuser app.py .
20
 
21
+ # Install Python packages in user space
22
+ RUN python -m pip install --no-cache-dir python-telegram-bot==20.0 requests flask
23
+
24
+ # Expose Flask port required by Hugging Face Spaces
25
  EXPOSE 7860
26
 
27
+ # Run the app as non-root user
28
  CMD ["python", "app.py"]