Reduce Docker image size by switching to miniconda base image
Bring the image size down from ~3.12GB to ~1.83GB.
Explicitly install the gcc supplied by conda and ensure it is available
to the shell when building Python package dependencies.
-FROM continuumio/anaconda3:latest
+FROM continuumio/miniconda3:latest
ENV PATH="/opt/conda/bin:${PATH}"
RUN apt-get -y update && apt-get install -y nginx supervisor
+
+# conda has its own gcc. Install it so we can compile required packages.
+RUN conda install gcc_linux-64
+
RUN mkdir /app && \
conda install twisted python-Levenshtein
-# Add requiremments.txt first and install to maximize chances of hitting docker cache
+# Add requirements.txt first and install to maximize chances of hitting docker cache
ADD ./requirements.txt /app
-RUN python3 -m pip install -r /app/requirements.txt
+# When installing packages that need compilation, run pip in a bash shell with
+# the conda environment activated. This allows it to find the conda-installed gcc.
+RUN /bin/bash -c ". activate && python3 -m pip install -r /app/requirements.txt"
ADD . /app
WORKDIR /app
