Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reduce docker image size by almost half #28

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 21 additions & 13 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,30 +1,38 @@
FROM debian:stable
ARG DEBIAN_FRONTEND=noninteractive
FROM python:3.6 as builder

LABEL maintainer "Manuel Muñoz <manuel.munoz@crg.eu>" \
version "1.0" \
description "Docker image for PyHIST"

# Install necessary tools
RUN export DEBIAN_FRONTEND=noninteractive && \
apt-get update --fix-missing -qq && \
RUN apt-get update -qq && \
apt-get install -y -q \
build-essential \
libgl1-mesa-glx \
python3.6 \
python3-pip \
openslide-tools \
python3-openslide && \
pip3 install pandas opencv-python
openslide-tools

# Copy PyHIST to container
WORKDIR /pyhist
COPY pyhist* /pyhist/
ADD src /pyhist/src
WORKDIR /opt/pyhist
RUN python -m venv venv \
&& ./venv/bin/python -m pip install --no-cache-dir -U pip setuptools wheel \
&& ./venv/bin/python -m pip install --no-cache-dir pandas opencv-python openslide-python
ENV PATH="/opt/pyhist/venv/bin:$PATH"
COPY pyhist* .
COPY src src

# Compile segmentation algorithm
RUN cd src/graph_segmentation/ && \
make && \
chmod 755 segment

# Entrypoing
# Build final, slim image.
FROM python:3.6-slim
RUN apt-get update -qq \
&& apt-get install -y -q \
libgl1-mesa-glx \
libopenslide0 \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /opt/pyhist
COPY --from=builder /opt/pyhist .
ENV PATH="/opt/pyhist/venv/bin:$PATH"
ENTRYPOINT ["python3", "pyhist.py"]