-
Notifications
You must be signed in to change notification settings - Fork 1
/
Singularity.v1.0.0
84 lines (63 loc) · 3.33 KB
/
Singularity.v1.0.0
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
Bootstrap: docker
From: ubuntu:16.04
%help
example_spm
An example SPM-based container that implements realignment, coregistration, and
smoothing for an fMRI data set. See /example_spm/README.md
%setup
# Make a directory to store various files. We need bin to run, the others are
# just to be informative for anyone who only has the container at hand.
mkdir -p ${SINGULARITY_ROOTFS}/opt/example_spm
%files
# Copy Matlab executable from bin (on host) to /example_spm in the container.
# No processing happens without it!
bin /opt/example_spm
# Let's also copy the source code. It's not needed to run the container, but
# it could helpful for someone if we include it in anyway.
src /opt/example_spm
# And the README file and compilation script
README.md /opt/example_spm
compile_matlab.sh /opt/example_spm
%labels
Maintainer [email protected]
%post
# Update the package manager and install needed packages
# wget Lets us download software during the build
# unzip,zip Lets us unzip same
# openjdk-8-jre Required for Matlab Runtime to work
# xvfb May be used if figures must be shown on a virtual display,
# as no actual display is available at runtime. Matlab
# Runtime requires this, anyway.
# ghostscript These two provide tools to generate/combine images/PDFs.
# imagemagick We are not using them for this simple example.
apt-get -qq update
apt-get -qq install -y wget unzip zip openjdk-8-jre xvfb
# If we are using ImageMagick to create PDFs, we need to relax its security
# policy to permit this. See https://usn.ubuntu.com/3785-1/
#sed -i 's/rights="none" pattern="PDF"/rights="read | write" pattern="PDF"/' \
# /etc/ImageMagick-6/policy.xml
# Download the Matlab Compiled Runtime installer, install, clean up.
mkdir /MCR
wget -nv -P /MCR http://ssd.mathworks.com/supportfiles/downloads/R2017a/deployment_files/R2017a/installers/glnxa64/MCR_R2017a_glnxa64_installer.zip
unzip -q /MCR/MCR_R2017a_glnxa64_installer.zip -d /MCR/MCR_R2017a_glnxa64_installer
/MCR/MCR_R2017a_glnxa64_installer/install -mode silent -agreeToLicense yes
rm -r /MCR/MCR_R2017a_glnxa64_installer /MCR/MCR_R2017a_glnxa64_installer.zip
rmdir /MCR
# Create input/output directories that we can bind to at runtime
mkdir /INPUTS && mkdir /OUTPUTS
# Singularity-hub doesn't work with github LFS (it gets the pointer info
# instead of the actual file) so we get the compiled matlab executable via
# direct download. The "raw" in the URL is critical here.
rm /opt/example_spm/bin/example_main
wget -nv -P /opt/example_spm/bin https://github.com/baxpr/example-spm-singularity-spider/raw/master/bin/example_main
chmod ugo+rx /opt/example_spm/bin/example_main
%environment
# We don't need to set the Matlab library path here, because Matlab's
# auto-generated run_??.sh script does it for us.
%runscript
# We use the "$@" argument to pass along any arguments that are given at the
# singularity command line - this is how we pass in file paths, parameters,
# etc. The first argument given here is the location of the Matlab Runtime -
# see the explanation in Matlab's auto-generated file bin/readme.txt
bash /opt/example_spm/bin/run_example_main.sh \
/usr/local/MATLAB/MATLAB_Runtime/v92 "$@"