diff --git a/docker/Dockerfile.devenv b/docker/Dockerfile.gcc similarity index 79% rename from docker/Dockerfile.devenv rename to docker/Dockerfile.gcc index 57d950e..5125140 100644 --- a/docker/Dockerfile.devenv +++ b/docker/Dockerfile.gcc @@ -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' | \ @@ -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 @@ -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/* diff --git a/docker/Dockerfile.intel b/docker/Dockerfile.intel new file mode 100644 index 0000000..fcf0730 --- /dev/null +++ b/docker/Dockerfile.intel @@ -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" ]