Rolaficus commited on
Commit
35322c5
·
verified ·
1 Parent(s): 7e25f4a

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +12 -19
Dockerfile CHANGED
@@ -1,40 +1,33 @@
1
- # Use the slim version of Python 3.9 (Debian Bullseye)
2
- # This is often more stable for networking in restricted environments
3
- FROM python:3.9-slim-bullseye
4
 
5
- # Set environment variables to prevent Python from writing .pyc files
6
  ENV PYTHONDONTWRITEBYTECODE=1 \
7
  PYTHONUNBUFFERED=1
8
 
9
  # Set working directory
10
  WORKDIR /code
11
 
12
- # Install system dependencies (needed for some networking libraries)
13
- # We install ca-certificates explicitly to ensure HTTPS works
14
- RUN apt-get update \
15
- && apt-get install -y --no-install-recommends \
16
- ca-certificates \
17
- netbase \
18
  && rm -rf /var/lib/apt/lists/*
19
 
20
- # Create a non-root user (required by HF Spaces)
21
  RUN useradd -m -u 1000 user
22
 
23
- # Copy requirements first (for caching)
24
  COPY ./requirements.txt /code/requirements.txt
25
  RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
26
 
27
- # Copy the app files AND change ownership to the 'user'
28
- # This is critical: standard COPY makes files owned by root, which can cause permission errors
29
  COPY --chown=user . /code
30
 
31
- # Switch to the non-root user
32
  USER user
33
-
34
- # Set home environment
35
  ENV HOME=/home/user \
36
  PATH=/home/user/.local/bin:$PATH
37
 
38
- # Run the app
39
- # Using 0.0.0.0 is required for Docker networking
40
  CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
 
1
+ # Use full Python 3.10 (Debian based, includes all standard libs)
2
+ FROM python:3.10
 
3
 
4
+ # Set environment variables
5
  ENV PYTHONDONTWRITEBYTECODE=1 \
6
  PYTHONUNBUFFERED=1
7
 
8
  # Set working directory
9
  WORKDIR /code
10
 
11
+ # Install specific networking tools for debugging (optional but helpful)
12
+ RUN apt-get update && apt-get install -y --no-install-recommends \
13
+ dnsutils \
14
+ iputils-ping \
 
 
15
  && rm -rf /var/lib/apt/lists/*
16
 
17
+ # Create user
18
  RUN useradd -m -u 1000 user
19
 
20
+ # Copy and install requirements
21
  COPY ./requirements.txt /code/requirements.txt
22
  RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
23
 
24
+ # Copy application files with ownership
 
25
  COPY --chown=user . /code
26
 
27
+ # Switch user
28
  USER user
 
 
29
  ENV HOME=/home/user \
30
  PATH=/home/user/.local/bin:$PATH
31
 
32
+ # Run app
 
33
  CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]