This repository has been archived by the owner on Apr 14, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
66 lines (51 loc) · 3.36 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
## NOTE: this uses multi-stage builds as in https://docs.docker.com/engine/userguide/eng-image/multistage-build/#use-multi-stage-builds
## Requires Docker v17.05+
## TODO: use ENV to specify a different Apsim release
# Build Container
FROM ubuntu:xenial as builder
MAINTAINER [email protected]
## Install and configure packages in the common layer
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF && \
echo "deb http://download.mono-project.com/repo/ubuntu wheezy/snapshots/4.8.0 main" | tee /etc/apt/sources.list.d/mono-official.list && \
apt-get update && \
apt-get -y install tzdata mono-runtime mono-vbnc libmonosgen-2.0-1 libboost-all-dev libxml2 tcl8.5 r-recommended && \
ln -fs /usr/share/zoneinfo/Pacific/Auckland /etc/localtime && dpkg-reconfigure -f noninteractive tzdata && \
Rscript -e 'install.packages(c("Rcpp", "RInside", "inline"),repos = "http://cran.us.r-project.org")'
## Install development packages and build Apsim
### svn co sometimes fails with a "Connection reset by peer" error, so we have to force checking out the entire repo
RUN apt-get -y install subversion p7zip p7zip-full g++ gfortran mono-devel libboost-all-dev libxml2-dev tcl8.5-dev && \
svn co https://apsrunet.apsim.info/svn/apsim/tags/Apsim79 apsim || while true; do svn cleanup apsim && svn update apsim; if [ $? -eq 0 ]; then break; fi; done
## These files have been hacked so that the build actually works
### Add CottonPassword.txt file for Cotton Model
ADD files/CottonPassword.txt /etc/CottonPassword.txt
### Prepended ProcessDataTypesInterface.exe with "mono" instead of calling it directly
ADD files/rlink-makefile /apsim/Model/RLink/Makefile.linux
ADD files/tcllink-makefile /apsim/Model/TclLink/Makefile
### Disabled building unit tests (requires NUnit v3 for which there is no Debian package and installing from source feels like an overkill)
ADD files/BuildAll.xml /apsim/Model/Build/BuildAll.xml
RUN cd /apsim/Model/Build && \
chmod +x BuildAll.sh && \
./BuildAll.sh && \
export APSIM=/apsim && \
cd /apsim/Release && \
./Release.sh
# Runtime Container
FROM ubuntu:xenial
MAINTAINER [email protected]
## Install and configure packages in the common layer
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF && \
echo "deb http://download.mono-project.com/repo/ubuntu wheezy/snapshots/4.8.0 main" | tee /etc/apt/sources.list.d/mono-official.list && \
apt-get update && \
apt-get -y install tzdata mono-runtime mono-vbnc libmonosgen-2.0-1 libboost-all-dev libxml2 tcl8.5 r-recommended && \
ln -fs /usr/share/zoneinfo/Pacific/Auckland /etc/localtime && dpkg-reconfigure -f noninteractive tzdata && \
Rscript -e 'install.packages(c("Rcpp", "RInside", "inline"),repos = "http://cran.us.r-project.org")'
## Get built artifact and extract
### /apsim needs to have 755 permissions so that non-privileged users can use the container
COPY --from=builder /apsim/Release/Apsim*.binaries.LINUX.X86_64.exe /tmp/apsim-release.exe
RUN /tmp/apsim-release.exe -y -o/apsim && \
rm -f /tmp/apsim-release.exe && \
chmod 755 apsim
WORKDIR /apsim/Temp/Model
ENV LD_LIBRARY_PATH=/apsim/Temp/Model
## This allows users to call the container directly with the name of the .exe file they want to run (Apsim.exe, ApsimToSim.exe, etc)
ENTRYPOINT ["/usr/bin/mono"]