Upload 3 files
Browse files- Dockerfile +9 -9
Dockerfile
CHANGED
|
@@ -1,12 +1,10 @@
|
|
| 1 |
# 1. Base Image: Use a stable, slim Python image
|
| 2 |
FROM python:3.10-slim
|
| 3 |
|
| 4 |
-
# Set the environment variable for Python
|
| 5 |
ENV PYTHONUNBUFFERED 1
|
| 6 |
|
| 7 |
-
# 2. System Dependencies: Install libraries required
|
| 8 |
-
# libgl1 and libgomp1 are critical for running TensorFlow/Keras headless (without a display)
|
| 9 |
-
# NOTE: Removed build-essential/cmake for speed, using minimal required libs
|
| 10 |
RUN apt-get update && \
|
| 11 |
apt-get install -y --no-install-recommends \
|
| 12 |
libgl1 \
|
|
@@ -21,15 +19,17 @@ WORKDIR /app
|
|
| 21 |
COPY requirements.txt .
|
| 22 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 23 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
# 3b. Copy the rest of your application code and models
|
| 25 |
COPY . .
|
| 26 |
|
| 27 |
-
# ๐ CRITICAL FIX: Grant write permission to the /app directory.
|
| 28 |
-
# This allows EasyOCR to create the 'easyocr_models' directory and save files without Permission Denied error.
|
| 29 |
-
RUN chmod -R 777 /app
|
| 30 |
-
|
| 31 |
# 4. Deployment Configuration
|
| 32 |
-
# Hugging Face Spaces runs on port 7860 by default
|
| 33 |
ENV PORT 7860
|
| 34 |
|
| 35 |
# Run the application using Gunicorn (the production web server)
|
|
|
|
| 1 |
# 1. Base Image: Use a stable, slim Python image
|
| 2 |
FROM python:3.10-slim
|
| 3 |
|
| 4 |
+
# Set the environment variable for Python
|
| 5 |
ENV PYTHONUNBUFFERED 1
|
| 6 |
|
| 7 |
+
# 2. System Dependencies: Install libraries required for image processing
|
|
|
|
|
|
|
| 8 |
RUN apt-get update && \
|
| 9 |
apt-get install -y --no-install-recommends \
|
| 10 |
libgl1 \
|
|
|
|
| 19 |
COPY requirements.txt .
|
| 20 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 21 |
|
| 22 |
+
# ๐ CRITICAL FIX FOR EASYOCR PERMISSION: ๐
|
| 23 |
+
# Create the necessary writable directory as root during the build process.
|
| 24 |
+
# This prevents the application from crashing at runtime when the non-root user tries to create it.
|
| 25 |
+
RUN mkdir -p /app/easyocr_models
|
| 26 |
+
RUN chmod -R 777 /app/easyocr_models
|
| 27 |
+
# NOTE: The chmod -R 777 /app fix you had is now replaced and refined by these two lines.
|
| 28 |
+
|
| 29 |
# 3b. Copy the rest of your application code and models
|
| 30 |
COPY . .
|
| 31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
# 4. Deployment Configuration
|
|
|
|
| 33 |
ENV PORT 7860
|
| 34 |
|
| 35 |
# Run the application using Gunicorn (the production web server)
|