Skip to content

Commit

Permalink
Merge pull request #8 from boegel/better_base
Browse files Browse the repository at this point in the history
 install EasyBuild as a module in base image + clean up GCC 9.3.0 image
  • Loading branch information
boegel authored May 29, 2020
2 parents 925d20b + 0027aa1 commit 5f67a29
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 30 deletions.
33 changes: 29 additions & 4 deletions containers/Dockerfile.base-centos7
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
FROM centos:7.8.2003
# Set default easybuild version
ARG IMG_REGISTRY=docker.io
ARG IMG_ORG=library
ARG IMG_NAME=centos
ARG IMG_TAG=7.8.2003
# allow CI/CD to change all of the above
FROM ${IMG_REGISTRY}/${IMG_ORG}/${IMG_NAME}:${IMG_TAG}
# set default easybuild version
ARG EB_VER=4.2.1
LABEL easybuild_version=${EB_VER}
# install required packages (EPEL is required for Lmod)
RUN yum install -y epel-release \
&& yum install -y bzip2 file gcc-c++ git Lmod make openssl-devel patch python3-pip unzip vim which
&& yum install -y bzip2 file gcc-c++ git Lmod make openssl openssl-devel patch python3-pip unzip vim which rdma-core-devel
# install EasBuild & archspec
RUN pip3 install easybuild==${EB_VER} archspec
# add 'easybuild' user
RUN useradd -ms /bin/bash easybuild
# create /scratch & /easybuild directories
RUN mkdir /scratch && chown easybuild:easybuild /scratch \
&& mkdir /easybuild && chown easybuild:easybuild /easybuild
# disable output buffering in Python, so we see EasyBuild output as it progresses
ENV PYTHONUNBUFFERED=TRUE
# define $EB_PYTHON to ensure EasyBuild runs with python3
ENV EB_PYTHON=python3
# Define the ENTRYPOINT for subsequent commands (CMD)
Expand All @@ -19,5 +29,20 @@ SHELL ["/bin/bash", "-l", "-c"]
CMD ["bash"]
# switch to 'easybuild' user
USER easybuild
# install EasyBuild as a module (& clean up /scratch)
RUN eb --install-latest-eb-release --prefix /scratch --installpath /easybuild \
&& rm -rf /scratch/*
# print info on Lmod & EasyBuild
RUN ml --version && which -a eb && eb --version & eb --show-system-info
RUN ml use /easybuild/modules/all \
&& ml EasyBuild \
&& ml --version \
&& which -a eb \
&& eb --version \
&& eb --show-system-info
# remove globally installed EasyBuild, we can use the module going forward
USER root
RUN pip3 uninstall -y easybuild
# switch to 'easybuild' user
USER easybuild
# make sure we start in /home/easybuild rather than / when shell in started in container
WORKDIR /home/easybuild
26 changes: 8 additions & 18 deletions containers/Dockerfile.centos7-GCC-9.3.0
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
FROM easybuilders/base:centos7-eb4.2.1
ARG IMG_REGISTRY=docker.io
ARG IMG_ORG=easybuilders
ARG IMG_NAME=base
ARG IMG_TAG=centos7-eb4.2.1
# allow CI/CD to change all of the above
FROM ${IMG_REGISTRY}/${IMG_ORG}/${IMG_NAME}:${IMG_TAG}

# CPU_ARCH is expected to be defined in the "docker build" command,
# for example: docker build --build-arg CPU_ARCH=haswell
ARG CPU_ARCH
Expand All @@ -10,24 +16,8 @@ RUN export HOST_CPU_ARCH=$(python3 -c 'import archspec.cpu; print(archspec.cpu.h
# use $CPU_ARCH to define label and set it as environment variable (to use in subsequent builds
LABEL cpu_arch=${CPU_ARCH}
ENV CPU_ARCH=${CPU_ARCH}
# for example: docker build --build-arg CPU_ARCH=haswell
# create /scratch & /easybuild directories
USER root
RUN mkdir /scratch && chown easybuild:easybuild /scratch
RUN mkdir /easybuild && chown easybuild:easybuild /easybuild
USER easybuild
# use /easybuild for everything that should persist in the container (software, modules and sources)
# everything else goes in /scratch, which will be cleaned out
ENV EASYBUILD_PREFIX=/scratch
ENV EASYBUILD_INSTALLPATH=/easybuild
ENV EASYBUILD_SOURCEPATH=/easybuild/sources
# disable output buffering in Python, so we see EasyBuild output as it progresses
ENV PYTHONUNBUFFERED=TRUE
# install software & accompanying modules
RUN eb GCC-9.3.0.eb --robot --trace \
RUN eb --prefix /scratch --installpath /easybuild GCC-9.3.0.eb --robot --trace \
# clean up everything in /scratch
&& rm -rf /scratch/*
# finalize /easybuild, no changes can be made in /easybuild that persist!
VOLUME /easybuild
# make sure we start in /home/easybuild rather than / when shell in started in container
WORKDIR /home/easybuild
15 changes: 7 additions & 8 deletions containers/Dockerfile.centos7-foss2020a
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
FROM easybuilders/test:centos7-eb421-gcc930
USER root
RUN yum install -y rdma-core-devel openssl
USER easybuild
ARG IMG_REGISTRY=docker.io
ARG IMG_ORG=easybuilders
ARG IMG_NAME=test
ARG IMG_TAG=centos7-eb421-gcc930
# allow CI/CD to change all of the above
FROM ${IMG_REGISTRY}/${IMG_ORG}/${IMG_NAME}:${IMG_TAG}

# install software & accompanying modules
RUN (eb foss-2020a.eb --robot || tail -100 `eb --last-log`) \
# clean up everything in /scratch
&& rm -rf /scratch/*
# finalize /easybuild, no changes can be made in /easybuild that persist!
VOLUME /easybuild
# make sure we start in /home/easybuild rather than / when shell in started in container
WORKDIR /home/easybuild

0 comments on commit 5f67a29

Please sign in to comment.