-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
48 lines (39 loc) · 1.16 KB
/
Dockerfile
File metadata and controls
48 lines (39 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
FROM python:3.9-slim
WORKDIR /app
# Install system dependencies
RUN apt-get update && apt-get install -y \
build-essential \
gcc \
python3-dev \
cython3 \
libopenblas-dev \
liblapack-dev \
tesseract-ocr \
libtesseract-dev \
libleptonica-dev \
pkg-config \
zlib1g-dev \
&& rm -rf /var/lib/apt/lists/*
# Set environment variables
ENV CFLAGS="-Wno-error=implicit-function-declaration"
ENV PYTHONUNBUFFERED=1
ENV PIP_NO_CACHE_DIR=1
ENV PIP_PREFER_BINARY=1
ENV FLASK_RUN_HOST=0.0.0.0
ENV FLASK_RUN_PORT=5001
# Copy requirements first for better caching
COPY requirements.txt .
# Remove zlib from requirements.txt as it's a system package
RUN sed -i '/zlib==1.0/d' requirements.txt
# Install Python packages in specific order
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir numpy==1.22.1 && \
pip install --no-cache-dir scipy==1.7.3 && \
pip install --no-cache-dir scikit-learn==1.0.2 && \
pip install --no-cache-dir -r requirements.txt && \
python -m spacy download en_core_web_sm && \
python -m nltk.downloader punkt
COPY . .
# Expose the port
EXPOSE 5001
CMD ["python", "main.py"]