forked from anibali/docker-pytorch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile.template
112 lines (93 loc) · 3.28 KB
/
Dockerfile.template
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
FROM $BASE
# Install some basic utilities
RUN apt-get update && apt-get install -y \
vim \
curl \
ca-certificates \
sudo \
git \
bzip2 \
libx11-6 \
&& rm -rf /var/lib/apt/lists/*
# Create a working directory
RUN mkdir /app
WORKDIR /app
# Create a non-root user and switch to it
RUN adduser --disabled-password --gecos '' --shell /bin/bash user \
&& chown -R user:user /app
RUN echo "user ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/90-user
USER user
# All users can use /home/user as their home directory
ENV HOME=/home/user
RUN chmod 777 /home/user
# Install Miniconda
RUN curl -so ~/miniconda.sh https://repo.continuum.io/miniconda/Miniconda3-4.4.10-Linux-x86_64.sh \
&& chmod +x ~/miniconda.sh \
&& ~/miniconda.sh -b -p ~/miniconda \
&& rm ~/miniconda.sh
ENV PATH=/home/user/miniconda/bin:$PATH
# Create a Python 3.6 environment
RUN /home/user/miniconda/bin/conda install conda-build \
&& /home/user/miniconda/bin/conda create -y --name py36 python=3.6.4 \
&& /home/user/miniconda/bin/conda clean -ya
ENV CONDA_DEFAULT_ENV=py36
ENV CONDA_PREFIX=/home/user/miniconda/envs/$CONDA_DEFAULT_ENV
ENV PATH=$CONDA_PREFIX/bin:$PATH
# Ensure conda version is at least 4.4.11
# (because of this issue: https://github.com/conda/conda/issues/6811)
ENV CONDA_AUTO_UPDATE_CONDA=false
RUN conda install -y "conda>=4.4.11" && conda clean -ya
$ADDITIONAL_STEPS
# Install HDF5 Python bindings
RUN conda install -y \
h5py \
&& conda clean -ya
RUN pip install h5py-cache
# Install Torchnet, a high-level framework for PyTorch
RUN pip install git+https://github.com/pytorch/tnt.git@master
# Install Requests, a Python library for making HTTP requests
RUN conda install -y requests && conda clean -ya
# Install Graphviz
RUN conda install -y graphviz=2.38.0 \
&& conda clean -ya
RUN pip install graphviz
# Install OpenCV3 Python bindings
RUN sudo apt-get update && sudo apt-get install -y --no-install-recommends \
libgtk2.0-0 \
libcanberra-gtk-module \
&& sudo rm -rf /var/lib/apt/lists/*
RUN conda install -y -c menpo opencv3 \
&& conda clean -ya
# Install Jupyter
RUN conda install -y jupyter \
&& conda clean -ya
# Install robosat
RUN sudo apt-get update && sudo apt-get install -y \
build-essential \
libboost-python-dev \
libexpat1-dev \
zlib1g-dev \
libbz2-dev \
libspatialindex-dev \
libsm6 \
libxext6 \
&& sudo rm -rf /var/lib/apt/lists/*
RUN cd /app && git clone https://github.com/mapbox/robosat.git
RUN cd /app/robosat && pip install -r deps/requirements-lock.txt
# Ugly patching of osmium, see https://github.com/osmcode/pyosmium/issues/52#issuecomment-401524007
RUN python3 -m pip uninstall --y osmium \
&& rm -rf ~/.cache/pip/wheels/ \
&& sudo rm /usr/lib/x86_64-linux-gnu/libboost_python.so \
&& sudo ln -s /usr/lib/x86_64-linux-gnu/libboost_python-py35.so /usr/lib/x86_64-linux-gnu/libboost_python.so \
&& python3 -m pip install osmium
# Add TernausNetV2
RUN git clone https://github.com/jjmata/TernausNetV2 \
&& pip install scikit-image tifffile \
&& cd /app/TernausNetV2/modules; chmod +x build.sh \
&& /app/TernausNetV2/modules/build.sh \
&& python3 /app/TernausNetV2/modules/build.py
# Create a datasets directory
RUN sudo mkdir /datasets && sudo chown -R user:user /datasets
VOLUME /datasets
# Set the default command to python3
CMD ["python3"]