-
Notifications
You must be signed in to change notification settings - Fork 2
/
Perl_speaks_NONMEM.Dockerfile
128 lines (116 loc) · 5.48 KB
/
Perl_speaks_NONMEM.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
# Dockerfile to build Perl-speaks-NONMEM version 5.2.6
# Build with the following command:
# docker build \
# -t humanpredictions/psn:5.3.0-1 \
# -t humanpredictions/psn:latest \
# -f Perl_speaks_NONMEM.Dockerfile .
# Start from the NMQual installation
FROM humanpredictions/nonmem:latest
# Dockerfile Maintainer
MAINTAINER William Denney <[email protected]>
# First, install perl libraries required for PsN, then install R and
# required libraries, then install python (then clean up the image as
# much as possible).
RUN ln -fs /usr/share/zoneinfo/UCT /etc/localtime \
&& apt-get update \
&& apt-get install --yes --no-install-recommends \
cpanminus \
expect \
\
r-base pandoc \
libpq-dev libcairo2-dev libssl-dev libcurl4-openssl-dev \
libmariadb-dev libgmp-dev libmpfr-dev libxml2-dev \
libudunits2-dev libblas-dev liblapack-dev libmagick++-dev \
make \
\
python3 python3-venv python3-dev \
&& rm -rf /var/lib/apt/lists/ \
/var/cache/apt/archives/ \
/usr/share/doc/ \
/usr/share/man/ \
/usr/share/locale/ \
/etc/apt/sources.list.d/multi.list
## Install perl modules using cpanminus
RUN cpanm Math::Random \
&& cpanm MouseX::Params::Validate \
&& cpanm Archive::Zip \
&& cpanm Test::Exception \
&& cpanm Test::More
## Install and test PsN
ENV PSN_VERSION_MAJOR=5
ENV PSN_VERSION_MINOR=3
ENV PSN_VERSION_PATCH=0
ENV PSN_VERSION=${PSN_VERSION_MAJOR}.${PSN_VERSION_MINOR}.${PSN_VERSION_PATCH}
ENV PSN_VERSION_UNDERSCORE=${PSN_VERSION_MAJOR}_${PSN_VERSION_MINOR}_${PSN_VERSION_PATCH}
ARG PSNURL=https://github.com/UUPharmacometrics/PsN/releases/download/v${PSN_VERSION}/PsN-${PSN_VERSION}.tar.gz
ARG NMTHREADS=4
## For PsN Installation
ENV R_LIBS_SITE=/opt/PsN/${PSN_VERSION}/PsN_${PSN_VERSION_UNDERSCORE}/Rlib
ENV R_LIBS_USER=${R_LIBS_SITE}
## The echo command provides inputs to setup.pl
## A 120 second timeout is used for python installation, and it may
## take longer on some systems.
RUN cd /mnt \
&& wget --no-show-progress --no-check-certificate -O psn.tar.gz ${PSNURL} \
&& tar zxf psn.tar.gz \
&& cd PsN-Source \
&& mkdir -p ${R_LIBS_SITE} \
&& Rscript -e "install.packages(c('renv', 'remotes'), lib='${R_LIBS_SITE}', repos='https://cloud.r-project.org')" \
&& Rscript -e ".libPaths(c('${R_LIBS_SITE}', .libPaths())); options(renv.consent=TRUE); renv::settings\$use.cache(FALSE); renv::restore(library='${R_LIBS_SITE}', lockfile='PsNR/renv.lock')" \
&& expect -c "set timeout { 120 exit }; \
spawn perl setup.pl; \
expect -ex \"PsN Utilities installation directory \[/usr/local/bin\]:\"; \
send \"/opt/PsN/${PSN_VERSION}/bin\r\"; \
expect -ex \"does not exist. Would you like to create it?\[y/n\]\"; \
send \"y\r\"; \
expect -ex \"Path to perl binary used to run Utilities \[/usr/bin/perl\]:\"; \
send \"/usr/bin/perl\r\"; \
expect -ex \"PsN Core and Toolkit installation directory \[\"; \
send \"/opt/PsN/${PSN_VERSION}\r\"; \
expect -ex \"Would you like this script to check Perl modules \[y/n\]?\"; \
send \"y\r\"; \
expect -ex \"Continue installing PsN (installing is possible even if modules are missing)\[y/n\]?\"; \
send \"y\r\"; \
expect -ex \"Would you like to continue anyway\"; \
send \"y\r\"; \
expect -ex \"Would you like to install the PsNR R package\"; \
send \"y\r\"; \
expect -ex \"install the pharmpy python package\"; \
send \"y\r\"; \
expect -ex \"Would you like to install the PsN test library?\"; \
send \"y\r\"; \
expect -ex \"PsN test library installation directory \[\"; \
send \"/opt/PsN/${PSN_VERSION}/test\r\"; \
expect -ex \"Would you like help to create a configuration file?\"; \
send \"y\r\"; \
expect -ex \"Would you like to add another one\"; \
send \"n\r\"; \
expect -ex \"or press ENTER to use the name\"; \
send \"nm_current\r\"; \
expect -ex \"installation program.\"; \
send \"\r\";" \
&& mv /opt/PsN/${PSN_VERSION}/PsN_${PSN_VERSION_UNDERSCORE}/psn.conf /mnt/psn.conf \
&& cat /mnt/psn.conf | \
sed 's/threads=5/threads='$NMTHREADS'/' > \
/opt/PsN/${PSN_VERSION}/PsN_${PSN_VERSION_UNDERSCORE}/psn.conf \
&& PSN_NONMEM_VERSION=$(echo $NONMEM_VERSION | sed 's/\.[0-9]$//g') \
&& MPICOUNT=$(echo $(for MPINAME in /opt/NONMEM/nm_current/run/mpilinux_[0-9]*.pnm; do echo $(basename $MPINAME | sed 's/[^0-9]*//g'); done) | sort -n) \
&& for PARACOUNT in $MPICOUNT ; do \
printf "parallel${PARACOUNT}=/opt/NONMEM/nm_current,${PSN_NONMEM_VERSION}\n" >> \
/opt/PsN/${PSN_VERSION}/PsN_${PSN_VERSION_UNDERSCORE}/psn.conf ; \
done \
&& printf "\n\n" >> \
/opt/PsN/${PSN_VERSION}/PsN_${PSN_VERSION_UNDERSCORE}/psn.conf \
&& for PARACOUNT in $MPICOUNT ; do \
printf "[default_options_parallel${PARACOUNT}]\nparafile=/opt/NONMEM/nm_current/run/mpilinux_${PARACOUNT}.pnm\n" >> \
/opt/PsN/${PSN_VERSION}/PsN_${PSN_VERSION_UNDERSCORE}/psn.conf ; \
done \
&& cd /opt/PsN/${PSN_VERSION}/test/PsN_test_${PSN_VERSION_UNDERSCORE} \
&& prove -r unit \
&& prove -r system \
&& rm -r /opt/PsN/${PSN_VERSION}/test \
&& rm -rf mnt/*
RUN ln -s /opt/PsN/${PSN_VERSION} /opt/PsN/current
ENV PATH /opt/PsN/${PSN_VERSION}/bin:$PATH
## Run execute to run a NONMEM model
CMD ["/opt/PsN/current/bin/execute"]