OpenCV compiled image in Alpine prepared to multi-stage.
Example of use in other python app:
FROM python:3.8.6-alpine3.12 as base
# Setup env
ENV LANG C.UTF-8
ENV LC_ALL C.UTF-8
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONFAULTHANDLER 1
ENV PATH=/root/.local/bin:$PATH
RUN python -m pip install --upgrade pip
# Set local timezone
ENV TZ Europe/Madrid
RUN apk add --no-cache tzdata
FROM base as build-deps
# Install system dependencies for build requirements.txt
RUN apk add --no-cache --update gcc g++ build-base linux-headers clang clang-dev make cmake ninja \
python3-dev libc-dev libffi-dev libressl-dev openssl-dev \
freetype-dev openblas-dev libxml2-dev libxslt-dev \
&& echo "[global]\nextra-index-url=https://www.piwheels.org/simple" > /etc/pip.conf
FROM build-deps AS python-deps
# Install python dependencies
COPY requirements.txt .
RUN pip install --user --no-cache-dir --disable-pip-version-check -r requirements.txt
FROM base as runtime-image
# Install runtime dependencies for final image
RUN apk add --no-cache --update \
# Pillow dependencies
libwebp libwebp-tools libpng libjpeg-turbo \
# OpenCV libs
openblas ffmpeg-libs
# Copy python dependencies
COPY --from=python-deps /root/.local /root/.local
# Copy opencv dependencies
COPY --from=dmmop/opencv:latest /opencv /root/.local
ENV LD_LIBRARY_PATH=/root/.local/lib64:$LD_LIBRARY_PATH
# COPY src src/
# CMD []
Content type
Image
Digest
Size
610.2 MB
Last updated
over 5 years ago
docker pull dmmop/opencv