-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
58 lines (41 loc) · 1.63 KB
/
Copy pathDockerfile
File metadata and controls
58 lines (41 loc) · 1.63 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
49
50
51
52
53
54
55
56
57
58
FROM node:18-alpine AS frontend-builder
WORKDIR /frontend
COPY frontend/package.json ./
RUN npm install
COPY frontend/ ./
RUN npm run build
FROM python:3.11-slim AS backend-builder
WORKDIR /app/backend
# Copy requirements first, then install build tools and dependencies
COPY backend/requirements.txt ./
RUN apt-get update && apt-get install -y --no-install-recommends \
tesseract-ocr \
poppler-utils \
gcc \
g++ \
&& pip install --no-cache-dir --upgrade pip \
&& pip install --no-cache-dir -r requirements.txt \
&& apt-get purge -y gcc g++ \
&& apt-get autoremove -y \
&& rm -rf /var/lib/apt/lists/*
RUN python -m spacy download en_core_web_sm
FROM python:3.11-slim
WORKDIR /app
# Only install runtime system packages in final image
RUN apt-get update && apt-get install -y --no-install-recommends \
tesseract-ocr \
poppler-utils \
&& apt-get autoremove -y \
&& rm -rf /var/lib/apt/lists/*
COPY --from=backend-builder /usr/local/lib/python3.11/site-packages /usr/local/lib/python3.11/site-packages
COPY --from=backend-builder /usr/local/bin /usr/local/bin
COPY backend/ ./backend/
COPY --from=frontend-builder /frontend/dist ./frontend/dist
RUN mkdir -p ./backend/uploads
ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1
ENV MALLOC_TRIM_THRESHOLD_=100000
EXPOSE 7860
HEALTHCHECK --interval=30s --timeout=5s --start-period=60s --retries=3 \
CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:7860/health')" || exit 1
CMD ["uvicorn", "backend.main:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "4", "--limit-concurrency", "10", "--timeout-keep-alive", "30"]