Upload Dockerfile
Browse files- Dockerfile +15 -16
Dockerfile
CHANGED
|
@@ -1,10 +1,11 @@
|
|
| 1 |
-
# 1. Base Image
|
| 2 |
FROM python:3.10-slim
|
| 3 |
|
| 4 |
-
#
|
| 5 |
ENV PYTHONUNBUFFERED 1
|
|
|
|
| 6 |
|
| 7 |
-
#
|
| 8 |
RUN apt-get update && \
|
| 9 |
apt-get install -y --no-install-recommends \
|
| 10 |
libgl1 \
|
|
@@ -12,26 +13,24 @@ RUN apt-get update && \
|
|
| 12 |
libsm6 libxext6 \
|
| 13 |
&& apt-get clean && rm -rf /var/lib/apt/lists/*
|
| 14 |
|
| 15 |
-
#
|
| 16 |
WORKDIR /app
|
| 17 |
|
| 18 |
-
#
|
| 19 |
COPY requirements.txt .
|
| 20 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 21 |
|
| 22 |
-
#
|
| 23 |
-
|
| 24 |
-
RUN mkdir -p /app/
|
| 25 |
-
# Uploads folder
|
| 26 |
RUN mkdir -p /app/uploads
|
| 27 |
-
|
| 28 |
-
RUN chmod -R 777 /app/easyocr_models /app/uploads
|
| 29 |
|
| 30 |
-
#
|
| 31 |
-
COPY . .
|
| 32 |
|
| 33 |
-
#
|
| 34 |
-
|
| 35 |
|
| 36 |
-
#
|
| 37 |
CMD exec gunicorn --bind 0.0.0.0:$PORT --workers 1 --threads 8 app:app
|
|
|
|
| 1 |
+
# 1. Base Image
|
| 2 |
FROM python:3.10-slim
|
| 3 |
|
| 4 |
+
# 2. Environment variable
|
| 5 |
ENV PYTHONUNBUFFERED 1
|
| 6 |
+
ENV PORT 7860
|
| 7 |
|
| 8 |
+
# 3. System Dependencies (for image processing & OCR)
|
| 9 |
RUN apt-get update && \
|
| 10 |
apt-get install -y --no-install-recommends \
|
| 11 |
libgl1 \
|
|
|
|
| 13 |
libsm6 libxext6 \
|
| 14 |
&& apt-get clean && rm -rf /var/lib/apt/lists/*
|
| 15 |
|
| 16 |
+
# 4. Working directory
|
| 17 |
WORKDIR /app
|
| 18 |
|
| 19 |
+
# 5. Copy & install Python dependencies
|
| 20 |
COPY requirements.txt .
|
| 21 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 22 |
|
| 23 |
+
# 6. Create writable directories
|
| 24 |
+
RUN mkdir -p /app/easyocr_models
|
| 25 |
+
RUN mkdir -p /app/models
|
|
|
|
| 26 |
RUN mkdir -p /app/uploads
|
| 27 |
+
RUN chmod -R 777 /app/easyocr_models /app/models /app/uploads
|
|
|
|
| 28 |
|
| 29 |
+
# 7. Copy CNN model
|
| 30 |
+
COPY cnn_model.h5 /app/models/cnn_model.h5
|
| 31 |
|
| 32 |
+
# 8. Copy rest of your application
|
| 33 |
+
COPY . .
|
| 34 |
|
| 35 |
+
# 9. Run the application using Gunicorn
|
| 36 |
CMD exec gunicorn --bind 0.0.0.0:$PORT --workers 1 --threads 8 app:app
|