-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathDockerfile.devenv
52 lines (44 loc) · 1.67 KB
/
Dockerfile.devenv
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
# Build stage with Spack pre-installed and ready to be used
FROM spack/ubuntu-jammy:0.21 AS builder
# Install software from spack.yaml
RUN mkdir /opt/spack-environment
COPY spack.yaml /opt/spack-environment/spack.yaml
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 --no-install-recommends libany-uri-escape-perl \
&& rm -rf /var/lib/apt/lists/*
# 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 necessary files from the builder stage
COPY --from=builder /opt/spack-environment /opt/spack-environment
COPY --from=builder /opt/software /opt/software
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
# Create entrypoint script
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 --no-install-recommends ca-certificates cpp m4 \
&& rm -rf /var/lib/apt/lists/*
# Set entrypoint and default command
ENTRYPOINT [ "/entrypoint.sh" ]
CMD [ "/bin/bash" ]