-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
74 lines (61 loc) · 2.42 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
# Build stage with Spack pre-installed and ready to be used
FROM spack/ubuntu-jammy:0.21 as builder
# What we want to install and how we want to install it
# is specified in a manifest file (spack.yaml)
RUN mkdir /opt/spack-environment \
&& (echo spack: \
&& echo ' packages:' \
&& echo ' all:' \
&& echo ' compiler: [[email protected]]' \
&& echo ' specs:' \
&& echo ' - [email protected]+log+program_options' \
&& echo ' - [email protected]' \
&& echo ' - [email protected]' \
&& echo ' - [email protected]' \
&& echo ' - [email protected]' \
&& echo ' - [email protected]+mpi+parallel-netcdf' \
&& echo ' - [email protected]' \
&& echo ' - netcdf-fortran' \
&& echo ' - [email protected]' \
&& echo ' - [email protected]' \
&& echo ' concretizer:' \
&& echo ' unify: true' \
&& echo ' config:' \
&& echo ' install_missing_compilers: false' \
&& echo ' install_tree: /opt/software' \
&& echo ' view: /opt/views/view') > /opt/spack-environment/spack.yaml
# Install the software, remove unnecessary deps
RUN cd /opt/spack-environment && spack env activate . && spack install --fail-fast && spack gc -y
# install perl URI lib
RUN apt update && apt install -y libany-uri-escape-perl
# download and install xios
#COPY install-xios.sh .
RUN spack env activate /opt/spack-environment
#&& bash install-xios.sh
# Strip all the binaries
RUN find -L /opt/views/view/* -type f -exec readlink -f '{}' \; | \
xargs file -i | \
grep 'charset=binary' | \
grep 'x-executable\|x-archive\|x-sharedlib' | \
awk -F: '{print $1}' | xargs strip
# Modifications to the environment that are necessary to run
RUN cd /opt/spack-environment && \
spack env activate --sh -d . > activate.sh
# Bare OS image to run the installed executables
FROM ubuntu:22.04
COPY --from=builder /opt/spack-environment /opt/spack-environment
COPY --from=builder /opt/software /opt/software
#COPY --from=builder /xios /xios
COPY --from=builder /usr /usr
# paths.view is a symlink, so copy the parent to avoid dereferencing and duplicating it
COPY --from=builder /opt/views /opt/views
RUN { \
echo '#!/bin/sh' \
&& echo '.' /opt/spack-environment/activate.sh \
&& echo 'exec "$@"'; \
} > /entrypoint.sh \
&& chmod a+x /entrypoint.sh \
&& ln -s /opt/views/view /opt/view \
&& apt update && apt install -y ca-certificates python3-dev python3-netcdf4
ENTRYPOINT [ "/entrypoint.sh" ]
CMD [ "/bin/bash" ]