Skip to content

Instantly share code, notes, and snippets.

@JossWhittle
Created August 13, 2020 19:20
Show Gist options
  • Save JossWhittle/3e267d9f0c8a3056b51f9d8f52b1fc3f to your computer and use it in GitHub Desktop.
Save JossWhittle/3e267d9f0c8a3056b51f9d8f52b1fc3f to your computer and use it in GitHub Desktop.
FROM frolvlad/alpine-python3
# Build and install numpy
RUN apk add --no-cache \
--virtual=.build-dependencies \
g++ gfortran file binutils \
musl-dev python3-dev cython openblas-dev lapack-dev && \
apk add libstdc++ openblas lapack && \
\
pip install --disable-pip-version-check --no-build-isolation --no-cache-dir numpy==1.18.5 && \
\
find /usr/lib/python3.*/ -name 'tests' -exec rm -r '{}' + && \
find /usr/lib/python3.*/site-packages/ -name '*.so' -print -exec sh -c 'file "{}" | grep -q "not stripped" && strip -s "{}"' \; && \
\
apk del .build-dependencies
# Build and install h5py
RUN apk add --no-cache \
--virtual=.build-dependencies \
g++ gfortran file binutils \
musl-dev python3-dev cython hdf5-dev && \
apk add libstdc++ hdf5 && \
\
pip install --disable-pip-version-check --no-build-isolation --no-cache-dir h5py && \
\
find /usr/lib/python3.*/ -name 'tests' -exec rm -r '{}' + && \
find /usr/lib/python3.*/site-packages/ -name '*.so' -print -exec sh -c 'file "{}" | grep -q "not stripped" && strip -s "{}"' \; && \
\
apk del .build-dependencies
# Build and install scipy
COPY "scipy/scipy-1.4.1" "/tmp/scipy-1.4.1"
RUN apk add --no-cache \
--virtual=.build-dependencies \
g++ gfortran file binutils patch \
musl-dev python3-dev cython openblas-dev lapack-dev && \
apk add libstdc++ openblas lapack && \
\
ln -s locale.h /usr/include/xlocale.h && \
\
cd /tmp && \
SCIPY_VERSION=1.4.1 && \
#wget "https://github.com/scipy/scipy/releases/download/v$SCIPY_VERSION/scipy-$SCIPY_VERSION.tar.xz" && \
#tar -xJf "scipy-$SCIPY_VERSION.tar.xz" && \
#(cd "scipy-$SCIPY_VERSION" && wget https://patch-diff.githubusercontent.com/raw/scipy/scipy/pull/11320.patch -O - | patch -p1) && \
pip install --disable-pip-version-check --no-build-isolation "/tmp/scipy-$SCIPY_VERSION/" && \
rm -rf /tmp/* && \
\
rm -r /root/.cache && \
find /usr/lib/python3.*/ -name 'tests' -exec rm -r '{}' + && \
find /usr/lib/python3.*/site-packages/ -name '*.so' -print -exec sh -c 'file "{}" | grep -q "not stripped" && strip -s "{}"' \; && \
\
rm /usr/include/xlocale.h && \
\
apk del .build-dependencies
# Install python packages
RUN pip install --disable-pip-version-check --no-build-isolation --no-cache-dir mock pytest ruamel.yaml Jinja2 nbformat nbconvert && \
\
find /usr/lib/python3.*/ -name 'tests' -exec rm -r '{}' +
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment