-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
38 lines (32 loc) · 1.39 KB
/
Copy pathDockerfile
File metadata and controls
38 lines (32 loc) · 1.39 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
# FIX 1: Capitalize 'AS' to fix the linter warning
FROM python:3.11.9-slim AS builder
WORKDIR /usr/python/app/doc-analyzer
COPY requirements.txt ./
# FIX 2: Add 'build-essential' to install C/C++ compilers
# We also keep tesseract-ocr here in case a library needs to link against it
RUN apt-get update && \
apt-get install -y --no-install-recommends \
build-essential \
gcc \
tesseract-ocr \
libtesseract-dev && \
pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -r requirements.txt && \
rm -rf /var/lib/apt/lists/*
# --- Final Stage ---
FROM python:3.11.9-slim
WORKDIR /usr/python/app/doc-analyzer
# Tesseract is needed here for runtime execution
RUN apt-get update && apt-get install -y tesseract-ocr && \
rm -rf /var/lib/apt/lists/* && \
useradd -m appuser && chown -R appuser:appuser /usr/python/app/doc-analyzer
# Copy installed packages from the builder
COPY --from=builder /usr/local/lib/python3.11/site-packages /usr/local/lib/python3.11/site-packages
COPY --from=builder /usr/local/bin /usr/local/bin
COPY . .
RUN mkdir -p /usr/python/app/doc-analyzer/app/uploads && \
chown -R appuser:appuser /usr/python/app/doc-analyzer/app && \
chmod 755 /usr/python/app/doc-analyzer/app/uploads
USER appuser
EXPOSE 8000
CMD ["gunicorn", "app.main:app", "--bind", "0.0.0.0:8000", "--workers", "4", "--worker-class", "uvicorn.workers.UvicornWorker"]