-
-
Notifications
You must be signed in to change notification settings - Fork 984
/
Copy pathDockerfile
56 lines (47 loc) · 1.68 KB
/
Dockerfile
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
# Copyright Contributors to the Pyro project.
#
# SPDX-License-Identifier: Apache-2.0
ARG base_img=ubuntu:18.04
FROM ${base_img}
# Optional args
ARG cuda=0
ARG python_version=3
ARG pyro_branch=release
ARG pytorch_branch=release
ARG uid=1000
ARG gid=1000
ARG ostype=Linux
ARG pyro_git_url=https://github.com/pyro-ppl/pyro.git
# Configurable settings
ENV USER_NAME pyromancer
ENV CONDA_DIR /opt/conda
ENV WORK_DIR /home/${USER_NAME}/workspace
ENV PATH ${CONDA_DIR}/bin:${PATH}
# Install linux utils
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
cmake \
git \
wget \
ca-certificates && \
rm -rf /var/lib/apt/lists/*
# Change to default user
RUN bash -c 'if [ ${ostype} == Linux ]; then groupadd -r --gid ${gid} ${USER_NAME}; fi && \
useradd -r --create-home --shell /bin/bash --uid ${uid} --gid ${gid} ${USER_NAME}' && \
mkdir -p ${CONDA_DIR} ${WORK_DIR} && chown ${USER_NAME} ${CONDA_DIR} ${WORK_DIR}
USER ${USER_NAME}
# Install conda
RUN wget -O ~/miniconda.sh \
https://repo.continuum.io/miniconda/Miniconda${python_version%%.*}-latest-Linux-x86_64.sh && \
bash ~/miniconda.sh -f -b -p ${CONDA_DIR} && \
rm ~/miniconda.sh && \
conda install python=${python_version}
# Move to home directory; and copy the install script
WORKDIR ${WORK_DIR}
COPY install.sh ${WORK_DIR}/install.sh
# Install python 2/3, PyTorch and Pyro
RUN cd ${WORK_DIR} && conda update -n base conda -c defaults && bash install.sh
# Run Jupyter notebook
# (Ref: http://jupyter-notebook.readthedocs.io/en/latest/public_server.html#docker-cmd)
EXPOSE 8888
CMD ["jupyter", "notebook", "--port=8888", "--no-browser", "--ip=0.0.0.0"]