Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +33 -7
Dockerfile
CHANGED
@@ -1,17 +1,43 @@
|
|
|
|
1 |
FROM python:3.10-slim
|
2 |
|
3 |
-
# Install
|
4 |
RUN apt-get update && apt-get install -y \
|
5 |
-
|
|
|
|
|
6 |
&& rm -rf /var/lib/apt/lists/*
|
7 |
|
|
|
|
|
|
|
|
|
8 |
WORKDIR /app
|
|
|
|
|
9 |
COPY requirements.txt .
|
10 |
RUN pip install --no-cache-dir -r requirements.txt
|
11 |
-
COPY . .
|
12 |
|
13 |
-
#
|
14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
|
16 |
-
|
17 |
-
|
|
|
|
1 |
+
# Use an official Python runtime as a parent image
|
2 |
FROM python:3.10-slim
|
3 |
|
4 |
+
# Install system dependencies (poppler-utils and tesseract-ocr)
|
5 |
RUN apt-get update && apt-get install -y \
|
6 |
+
poppler-utils \
|
7 |
+
tesseract-ocr \
|
8 |
+
libtesseract-dev \
|
9 |
&& rm -rf /var/lib/apt/lists/*
|
10 |
|
11 |
+
# Create a non-root user
|
12 |
+
RUN useradd -m appuser
|
13 |
+
|
14 |
+
# Set working directory
|
15 |
WORKDIR /app
|
16 |
+
|
17 |
+
# Copy requirements.txt and install Python dependencies
|
18 |
COPY requirements.txt .
|
19 |
RUN pip install --no-cache-dir -r requirements.txt
|
|
|
20 |
|
21 |
+
# Copy the app code and templates
|
22 |
+
COPY app.py .
|
23 |
+
COPY templates /app/templates/
|
24 |
+
# If you add a static folder in the future for CSS/JS:
|
25 |
+
# COPY static /app/static/
|
26 |
+
|
27 |
+
# Switch to non-root user
|
28 |
+
USER appuser
|
29 |
+
|
30 |
+
# Expose the port the app runs on (for documentation, HF handles actual mapping)
|
31 |
+
# Gunicorn will bind to this port. Hugging Face Spaces typically expect apps on 7860.
|
32 |
+
EXPOSE 7860
|
33 |
+
|
34 |
+
# Set environment variables
|
35 |
+
ENV PYTHONUNBUFFERED=1
|
36 |
+
ENV FLASK_APP=app.py
|
37 |
+
# Recommended: Set FLASK_ENV to production for real deployments,
|
38 |
+
# but gunicorn handles this role better than Flask dev server.
|
39 |
+
# ENV FLASK_ENV=production
|
40 |
|
41 |
+
# Run the Flask app with Gunicorn
|
42 |
+
# The 'app:app' means Gunicorn should look for an object named 'app' in a file named 'app.py'.
|
43 |
+
CMD ["gunicorn", "--bind", "0.0.0.0:7860", "--workers", "2", "--timeout", "120", "app:app"]
|