File size: 1,091 Bytes
0e0cc3e
 
 
 
 
 
 
 
 
 
 
 
 
06bdaca
 
 
 
0e0cc3e
 
190dbf0
0e0cc3e
 
 
 
 
 
 
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
# Build PWA and serve static (ONNX models pre-built in frontend/public/models)

FROM node:20-alpine AS frontend-build
WORKDIR /frontend
COPY frontend/package.json frontend/package-lock.json* ./
RUN npm ci
COPY frontend/ .
RUN npm run build

FROM python:3.10-slim
LABEL maintainer="NPI Pipe Count"
ENV PYTHONUNBUFFERED=1
WORKDIR /app
# Native libs required by onnxruntime (libgomp1) and opencv-python-headless (libglib2.0-0)
RUN apt-get update \
    && apt-get install -y --no-install-recommends libgomp1 libglib2.0-0 \
    && rm -rf /var/lib/apt/lists/*
COPY requirements-server.txt .
RUN pip install --no-cache-dir -r requirements-server.txt
COPY main.py detect.py detect_limiter.py postprocess.py ./
COPY --from=frontend-build /frontend/dist ./static
RUN useradd -m appuser && chown -R appuser:appuser /app
USER appuser
EXPOSE 7860
HEALTHCHECK --interval=30s --timeout=10s --start-period=20s --retries=3 \
    CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:7860/health')"
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1"]