forked from HopkinsIDD/COVIDScenarioPipeline
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
130 lines (114 loc) · 3.62 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
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
FROM ubuntu:18.04
USER root
ENV TERM linux
# set locale info
RUN apt-get update && apt-get install -y locales && locale-gen en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
# set noninteractive installation
ENV DEBIAN_FRONTEND noninteractive
ENV R_VERSION 3.6.3-1bionic
# see https://www.digitalocean.com/community/tutorials/how-to-install-r-on-ubuntu-18-04
# https://cran.r-project.org/bin/linux/debian/
# https://cran.r-project.org/bin/linux/ubuntu/README.html
RUN set -e \
&& apt-get -y install --no-install-recommends --no-install-suggests \
gnupg2 gnupg1 ca-certificates software-properties-common \
&& apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9 \
&& add-apt-repository 'deb https://cloud.r-project.org/bin/linux/ubuntu bionic-cran35/' \
&& add-apt-repository ppa:git-core/ppa
RUN apt-get update && \
apt-get install -y --no-install-recommends \
# needed packages
tzdata \
sudo \
less \
build-essential \
git-core \
git-lfs \
curl \
pandoc \
pandoc-citeproc \
postgresql-client \
libpq-dev \
libssl-dev \
openssl \
libgdal-dev \
libyaml-dev \
libjpeg-dev \
libxml2-dev \
libxslt1-dev \
libffi-dev \
libblas-dev \
liblapack-dev \
libatlas-base-dev \
libxml2-dev \
libcurl4-openssl-dev \
libfontconfig1-dev \
libcairo2-dev \
libudunits2-dev \
gfortran \
unzip \
zip \
pbzip2 \
vim-nox \
nano \
libbz2-dev \
libsqlite3-dev \
sqlite3 \
openssh-server \
libsnappy-dev \
libncurses-dev \
libreadline-dev \
supervisor \
awscli \
r-base-dev=$R_VERSION \
# make sure we have up-to-date CA certs or curling some https endpoints (like python.org) may fail
ca-certificates \
# app user creation
&& useradd -m app \
&& mkdir -p /home/app \
&& chown app:app /home/app \
# set up sudo for app user
&& sudo echo "app ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/app \
&& sudo usermod -a -G staff app
WORKDIR /home/app
USER app
ENV HOME /home/app
#####
# R
#####
# TODO: use packrat (or something else) for R package management
RUN Rscript -e "install.packages('packrat',repos='https://cloud.r-project.org/')" \
&& Rscript -e "install.packages('arrow',repos='https://cloud.r-project.org/')" \
&& Rscript -e 'arrow::install_arrow()'
COPY --chown=app:app packrat $HOME/packrat
COPY --chown=app:app Docker.Rprofile $HOME/.Rprofile
COPY --chown=app:app R/pkgs $HOME/R/pkgs
RUN Rscript -e 'packrat::restore()'
RUN Rscript -e 'install.packages(list.files("R/pkgs",full.names=TRUE),type="source",repos=NULL)'
#####
# Python (managed via pyenv)
#####
ENV PYENV_ROOT $HOME/.pyenv
ENV PYTHON_VERSION 3.7.6
ENV PYTHON_VENV_DIR $HOME/python_venv
ENV PATH $PYENV_ROOT/shims:$PYENV_ROOT/bin:$PATH
RUN git clone git://github.com/yyuu/pyenv.git $HOME/.pyenv \
&& rm -rf $HOME/.pyenv/.git \
&& env PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install -s $PYTHON_VERSION --verbose \
&& pyenv rehash \
&& echo 'eval "$(pyenv init -)"' >> ~/.bashrc \
&& echo "PS1=\"\[\e]0;\u@\h: \w\a\] \h:\w\$ \"" >> ~/.bashrc
RUN eval "$(pyenv init -)" \
&& pyenv shell $PYTHON_VERSION \
&& pyvenv $PYTHON_VENV_DIR \
# automatically activate the python venv when logging in
&& echo ". $HOME/python_venv/bin/activate" >> $HOME/.bashrc \
&& . $PYTHON_VENV_DIR/bin/activate
COPY requirements.txt $HOME/requirements.txt
RUN . $PYTHON_VENV_DIR/bin/activate \
&& pip install --upgrade pip setuptools \
&& pip install -r $HOME/requirements.txt
CMD ["/bin/bash"]