Update Dockerfile
Browse files- Dockerfile +12 -11
Dockerfile
CHANGED
@@ -1,8 +1,7 @@
|
|
1 |
# Dockerfile
|
2 |
-
# Using the official Hugging Face template as a base
|
3 |
FROM python:3.10-slim
|
4 |
|
5 |
-
# Set up a non-root user for security
|
6 |
RUN useradd -m -u 1000 user
|
7 |
USER user
|
8 |
ENV PATH="/home/user/.local/bin:$PATH"
|
@@ -10,20 +9,22 @@ ENV HOME="/home/user"
|
|
10 |
|
11 |
WORKDIR /app
|
12 |
|
13 |
-
# Install system dependencies
|
14 |
-
# We switch back to root temporarily to do this
|
15 |
USER root
|
16 |
-
RUN apt-get update && apt-get install -y
|
17 |
-
|
|
|
18 |
USER user
|
19 |
|
20 |
-
# Copy
|
21 |
COPY --chown=user ./requirements.txt requirements.txt
|
22 |
RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
23 |
|
24 |
-
# Copy the
|
25 |
-
COPY --chown=user .
|
26 |
|
27 |
-
#
|
28 |
-
|
|
|
|
|
29 |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
1 |
# Dockerfile
|
|
|
2 |
FROM python:3.10-slim
|
3 |
|
4 |
+
# Set up a non-root user for security and compatibility with HF Spaces
|
5 |
RUN useradd -m -u 1000 user
|
6 |
USER user
|
7 |
ENV PATH="/home/user/.local/bin:$PATH"
|
|
|
9 |
|
10 |
WORKDIR /app
|
11 |
|
12 |
+
# Install system dependencies
|
|
|
13 |
USER root
|
14 |
+
RUN apt-get update && apt-get install -y --no-install-recommends \
|
15 |
+
tesseract-ocr \
|
16 |
+
&& rm -rf /var/lib/apt/lists/*
|
17 |
USER user
|
18 |
|
19 |
+
# Copy and install Python packages
|
20 |
COPY --chown=user ./requirements.txt requirements.txt
|
21 |
RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
22 |
|
23 |
+
# Copy the application code
|
24 |
+
COPY --chown=user . .
|
25 |
|
26 |
+
# Expose the port required by HF Spaces
|
27 |
+
EXPOSE 7860
|
28 |
+
|
29 |
+
# Run the FastAPI application using Uvicorn
|
30 |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|