51 lines
1.5 KiB
Docker
51 lines
1.5 KiB
Docker
# Stage 1: compile LibreDWG (provides dwgread for DWG → DXF conversion)
|
|
FROM debian:bookworm-slim AS libredwg-builder
|
|
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
xz-utils \
|
|
build-essential \
|
|
autoconf \
|
|
automake \
|
|
libtool \
|
|
python3 \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
COPY libredwg-0.12.5.tar.xz .
|
|
RUN tar xf libredwg-0.12.5.tar.xz \
|
|
&& cd libredwg-0.12.5 \
|
|
&& ./configure --prefix=/opt/libredwg --disable-shared --disable-bindings \
|
|
&& make -j"$(nproc)" \
|
|
&& make install \
|
|
&& cd .. \
|
|
&& rm -rf libredwg-0.12.5 libredwg-0.12.5.tar.xz
|
|
|
|
# Stage 2: runtime — PyTorch CUDA base for GPU template matching
|
|
FROM pytorch/pytorch:2.11.0-cuda12.8-cudnn9-runtime
|
|
|
|
COPY --from=libredwg-builder /opt/libredwg/bin/dwgread /usr/local/bin/dwgread
|
|
|
|
# poppler-utils for pdf2image; cairo + pango for cairosvg; libgl1 for cv2
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
poppler-utils \
|
|
libgl1 \
|
|
libglib2.0-0 \
|
|
libcairo2 \
|
|
libpango-1.0-0 \
|
|
libpangocairo-1.0-0 \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
WORKDIR /app
|
|
|
|
# Install Python deps. The PyTorch base image already provides torch +
|
|
# numpy with CUDA 12.8 kernels — do NOT reinstall torch via requirements.
|
|
COPY requirements.txt .
|
|
RUN pip install --no-cache-dir --break-system-packages -r requirements.txt
|
|
|
|
COPY . .
|
|
|
|
RUN mkdir -p /tmp/dwg-counting
|
|
|
|
EXPOSE 8000
|
|
|
|
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
|