broadfield-dev commited on
Commit
eef1dca
·
verified ·
1 Parent(s): e1903b4

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +19 -13
Dockerfile CHANGED
@@ -1,5 +1,5 @@
1
  # Use a compatible Python base image
2
- FROM python:3.9-slim-bullseye
3
 
4
  # Set the working directory inside the container
5
  WORKDIR /app
@@ -13,26 +13,32 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
13
  xfonts-75dpi \
14
  xfonts-base \
15
  libxrender1 \
16
- libssl1.1 \
17
  && apt-get clean \
18
  && rm -rf /var/lib/apt/lists/*
19
 
20
  # Download and install the wkhtmltox package
21
- RUN wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6.1-2/wkhtmltox_0.12.6.1-2.bullseye_amd64.deb && \
22
- dpkg -i wkhtmltox_0.12.6.1-2.bullseye_amd64.deb && \
23
- rm wkhtmltox_0.12.6.1-2.bullseye_amd64.deb
24
 
25
- # Copy your application files into the container
26
- COPY requirements.txt .
27
- COPY app.py .
28
 
29
- # Install the Python dependencies (including gunicorn)
 
30
  RUN pip install --no-cache-dir -r requirements.txt
31
 
32
- # Expose the port that Flask will run on
 
 
 
 
 
 
 
 
33
  EXPOSE 7860
34
 
35
- # --- THE CORRECTED FINAL LINE ---
36
- # Use gunicorn to run the app. It's a production server that integrates properly with the platform.
37
- # It looks for the 'app.py' file (module) and the 'app = Flask(...)' object (instance).
38
  CMD ["gunicorn", "--bind", "0.0.0.0:7860", "app:app"]
 
1
  # Use a compatible Python base image
2
+ FROM python:3.9-slim-bookworm
3
 
4
  # Set the working directory inside the container
5
  WORKDIR /app
 
13
  xfonts-75dpi \
14
  xfonts-base \
15
  libxrender1 \
16
+ libssl3 \
17
  && apt-get clean \
18
  && rm -rf /var/lib/apt/lists/*
19
 
20
  # Download and install the wkhtmltox package
21
+ RUN wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6.1-3/wkhtmltox_0.12.6.1-3.bookworm_amd64.deb && \
22
+ dpkg -i wkhtmltox_0.12.6.1-3.bookworm_amd64.deb && \
23
+ rm wkhtmltox_0.12.6.1-3.bookworm_amd64.deb
24
 
25
+ # Create non-root user as required by HF Spaces
26
+ RUN useradd -m -u 1000 user
 
27
 
28
+ # Copy application files (before switching user)
29
+ COPY requirements.txt .
30
  RUN pip install --no-cache-dir -r requirements.txt
31
 
32
+ # Switch to non-root user and set environment
33
+ USER user
34
+ ENV HOME=/home/user \
35
+ PATH=/home/user/.local/bin:$PATH
36
+
37
+ # Copy app code with proper ownership
38
+ COPY --chown=1000:1000 app.py .
39
+
40
+ # Expose the port
41
  EXPOSE 7860
42
 
43
+ # Run with gunicorn
 
 
44
  CMD ["gunicorn", "--bind", "0.0.0.0:7860", "app:app"]