Skip to content

Instantly share code, notes, and snippets.

@efops
Last active May 20, 2020 09:21
Show Gist options
  • Save efops/67b18522646f6796323121f4e28d0c2c to your computer and use it in GitHub Desktop.
Save efops/67b18522646f6796323121f4e28d0c2c to your computer and use it in GitHub Desktop.
Opencv flask face-recognition python Dockerfile
FROM python:3.7-slim AS compile-image
LABEL maintainer="info@efkan-isazade.com"
WORKDIR /app
COPY ./requirements.txt .
ENV BUILD_DEPS="build-essential cmake"
RUN python -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
RUN apt-get update \
&& apt-get install -y ${BUILD_DEPS} --no-install-recommends \
&& pip install -r requirements.txt \
&& rm -rf /var/lib/apt/lists/* \
&& rm -rf /usr/share/doc && rm -rf /usr/share/man \
&& apt-get purge -y --auto-remove ${BUILD_DEPS} \
&& apt-get clean
FROM python:3.7-slim
ENV RELEASE_DEPS="libsm6 libxext6 libxrender-dev libglib2.0-0"
RUN apt-get update \
&& apt-get install -y ${RELEASE_DEPS} --no-install-recommends \
&& rm -rf /var/cache/apt/* /var/lib/apt/lists/* \
&& rm -rf /usr/share/doc && rm -rf /usr/share/man \
&& apt-get purge -y --auto-remove \
&& apt-get clean
COPY --from=compile-image /opt/venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
WORKDIR /app
COPY . /app
ENTRYPOINT ["python"]
CMD ["app.py"]

Example python project will be here soon. Current requirements.txt is coming from real project and used here as an example.

Flask
requests
opencv-python
face-recognition
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment