Skip to content

Commit

Permalink
Update Dockerfile.devenv
Browse files Browse the repository at this point in the history
  • Loading branch information
stephanieleroux authored Oct 9, 2024
1 parent f29d041 commit f3b51a4
Showing 1 changed file with 17 additions and 38 deletions.
55 changes: 17 additions & 38 deletions Dockerfiles/Dockerfile.devenv
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,11 @@ FROM spack/ubuntu-jammy:0.21 AS builder
# Install software from spack_devenv.yaml
RUN mkdir /opt/spack-environment
COPY Dockerfiles/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
RUN source /opt/spack/share/spack/setup-env.sh && \
cd /opt/spack-environment && \
spack env activate . && \
spack install --fail-fast && \
spack gc -y

# Bare OS image to run the installed executables
FROM ubuntu:22.04
Expand All @@ -33,24 +17,19 @@ 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

# Copy the entrypoint script into the container
COPY Dockerfiles/entrypoint.sh /entrypoint.sh

# Make the script executable
RUN chmod +x /entrypoint.sh && \
ln -s /opt/views/view /opt/view && \
apt update && \
apt install -y --no-install-recommends ca-certificates python3-dev python3-netcdf4 && \
rm -rf /var/lib/apt/lists/*
# Create entrypoint script
RUN { \
echo '#!/bin/sh'; \
echo '. /opt/spack/share/spack/setup-env.sh'; \ # Set up Spack environment
echo '. /opt/spack-environment/activate.sh'; \ # Activate the Spack environment
echo 'jupyter lab --ip=0.0.0.0 --no-browser --allow-root &'; \ # Start Jupyter Lab in the background
echo 'exec "$@"'; \
} > /entrypoint.sh \
&& chmod a+x /entrypoint.sh \
&& ln -s /opt/views/view /opt/view

# Set entrypoint and default command
ENTRYPOINT ["/entrypoint.sh"]
CMD ["/bin/bash"]





ENTRYPOINT [ "/entrypoint.sh" ]
CMD [ "/bin/bash" ]

0 comments on commit f3b51a4

Please sign in to comment.