Repository navigation
Expand file tree
/
Copy pathtemplate_Dockerfile
More file actions
74 lines (59 loc) · 2.33 KB
/
Copy pathtemplate_Dockerfile
File metadata and controls
74 lines (59 loc) · 2.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# ~+~+~+~+~+~+~+~+~+~+~+~+~+~+~+~+~+~+~+~+~+~+~+~+~+~+~+~+~+~+~+~+~+~+~+ #
FROM python:${PYTHON_VERSION}-alpine${ALPINE_VERSION} as base
MAINTAINER Kacper Sokol <[email protected]>
RUN rm -fr /usr/local/lib/python3.*/config-3.*m-x86_64-linux-gnu
# ~+~+~+~+~+~+~+~+~+~+~+~+~+~+~+~+~+~+~+~+~+~+~+~+~+~+~+~+~+~+~+~+~+~+~+ #
FROM base as builder
ARG PYTHON_BASE
RUN mkdir /install
# RUN apk --no-cache --update-cache add gcc wget python python-dev py-pip
# RUN echo "http://dl-8.alpinelinux.org/alpine/v3.8/community" >> \
# /etc/apk/repositories
# RUN apk --no-cache --update-cache add py-numpy@community py-scipy@community
# RUN ln -s /usr/include/locale.h /usr/include/xlocale.h
RUN apk --no-cache --update-cache add \
# numpy & scipy
gfortran build-base openblas-dev \
# matplotlib
freetype-dev libpng-dev \
# file & strip
file binutils
ENV PYTHONPATH="/install/lib/python${PYTHON_BASE}/site-packages:${PYTHONPATH}"
ENV PATH="/install/bin:${PATH}"
COPY requirements*.txt /
# --target="/install"
RUN touch /requirements-dev.txt && \
pip install --no-cache-dir \
--install-option="--prefix=/install" \
-r /requirements.txt \
-r /requirements-aux.txt \
-r /requirements-dev.txt
RUN find /install/lib/python3.*/site-packages/ \( -name '__pycache__' -o -name 'test' -o -name 'tests' \) -type d -print0 | xargs -0 rm -rf -- && \
find /install/share/jupyter/lab/static/ -name '*.map' -print -exec rm "{}" \; && \
rm -rf /root/.cache && \
rm -rf /tmp/* && \
find /install/lib/python3.*/site-packages/ -name '*.so' -print -exec /bin/sh -c 'file "{}" | grep -q "not stripped" && strip -s "{}"' \;
# ~+~+~+~+~+~+~+~+~+~+~+~+~+~+~+~+~+~+~+~+~+~+~+~+~+~+~+~+~+~+~+~+~+~+~+ #
FROM base as scientific-python
RUN apk --no-cache add \
# numpy & scipy
openblas \
# pyzmq (jupyter lab)
libstdc++ \
# matplotlib
freetype libpng && \
rm -rf /root/.cache && \
rm -rf /tmp/*
COPY --from=builder /install /usr/local
ENV A_USER=jovian \
A_UID=1000 \
A_HOME=/jovian \
A_SHELL=/bin/sh
RUN mkdir ${A_HOME} && \
adduser -D -s ${A_SHELL} -u ${A_UID} -h ${A_HOME} ${A_USER} && \
chown ${A_USER} ${A_HOME}
WORKDIR ${A_HOME}
USER ${A_USER}
RUN jupyter serverextension enable --py jupyterlab
EXPOSE 8888
CMD ["jupyter", "lab", "--ip=0.0.0.0", "--port=8888", "--no-browser"]