Skip to content

Commit

Permalink
Split Dockerfile for gcc and intel
Browse files Browse the repository at this point in the history
  • Loading branch information
jwallwork23 committed Oct 28, 2024
1 parent db9aac0 commit 7a47d18
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 9 deletions.
15 changes: 6 additions & 9 deletions docker/Dockerfile.devenv → docker/Dockerfile.gcc
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
# Build stage with Spack pre-installed and ready to be used
FROM spack/ubuntu-jammy:0.21 AS builder

# Install software from spack.yaml
# Install software from spack_gcc.yaml
RUN mkdir /opt/spack-environment
COPY docker/spack.yaml /opt/spack-environment/spack.yaml
COPY docker/spack_gcc.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
# Install perl URI lib and strip all the binaries
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 '{}' \; | \
&& rm -rf /var/lib/apt/lists/* \
&& find -L /opt/views/view/* -type f -exec readlink -f '{}' \; | \
xargs file -i | \
grep 'charset=binary' | \
grep 'x-executable\|x-archive\|x-sharedlib' | \
Expand All @@ -32,7 +30,6 @@ FROM ubuntu:22.04
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
Expand All @@ -43,7 +40,7 @@ RUN { \
} > /entrypoint.sh \
&& chmod a+x /entrypoint.sh \
&& ln -s /opt/views/view /opt/view \
&& apt update \
&& apt update --no-cache \
&& apt install -y --no-install-recommends ca-certificates cpp m4 \
&& rm -rf /var/lib/apt/lists/*

Expand Down
54 changes: 54 additions & 0 deletions docker/Dockerfile.intel
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
FROM intel/oneapi-hpckit:latest AS intel

# Build stage with Spack pre-installed and ready to be used
FROM spack/ubuntu-jammy:0.21 AS builder

# Copy Intel compiler over
COPY --from=intel /opt/intel/oneapi /opt/intel/oneapi

# Install software from spack_intel.yaml
RUN mkdir /opt/spack-environment
COPY docker/spack_intel.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 and strip all the binaries
RUN apt-get update --no-cache \
&& apt-get install -y --no-install-recommends libany-uri-escape-perl \
&& rm -rf /var/lib/apt/lists/* \
&& 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:latest

# 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
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-get update --no-cache \
&& apt-get 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" ]

0 comments on commit 7a47d18

Please sign in to comment.