Commit 7968c941 authored by Tom McCauley's avatar Tom McCauley
Browse files

try cc8 build

parent db8b2229
# CC8 OS capable of using/running CMS software release(s).
# Make the base image configurable:
ARG BASEIMAGE=gitlab-registry.cern.ch/linuxsupport/c8-base:20210601-1.x86_64
# Set up the CC8 CMSSW base:
FROM ${BASEIMAGE}
LABEL maintainer="Clemens Lange <clemens.lange@cern.ch>"
# Build-time metadata as defined at http://label-schema.org
ARG BUILD_DATE
ARG VCS_REF
ARG VCS_URL
ARG VERSION
LABEL org.label-schema.build-date=$BUILD_DATE \
org.label-schema.name="CC8 CMS base OS" \
org.label-schema.description="CC8 OS capable of using/running CMS software release(s)." \
org.label-schema.url="http://cms-sw.github.io/" \
org.label-schema.vcs-ref=$VCS_REF \
org.label-schema.vcs-url=$VCS_URL \
org.label-schema.vendor="CERN" \
org.label-schema.version=$VERSION \
org.label-schema.schema-version="1.0"
# Perform the installation as root
USER root
WORKDIR /root
RUN yum install -y libX11-devel libXext-devel mesa-libGLU-devel \
mesa-libGL-devel libSM libXft libXext \
pciutils glx-utils mesa-dri-drivers libX11 libXi libXrender \
tcsh zsh tcl tk e2fsprogs perl-ExtUtils-Embed libXmu e2fsprogs-libs libXpm bc libaio \
tar patch krb5-devel perl-Data-Dumper gcc unzip zip perl-libwww-perl libXpm-devel libXft-devel svn \
gcc-c++ strace cern-wrappers krb5-workstation wget hostname readline-devel nano bzip2 perl-Switch perl-Storable \
perl-Env packages perl-Thread-Queue CERN-CA-certs tk-devel tcl-devel which platform-python-pip voms-clients-cpp \
java-1.8.0-openjdk java-1.8.0-openjdk-devel popt libXcursor libXrandr libXinerama nspr nss nss-util file file-libs \
readline bzip2-libs python-requests-kerberos libgfortran time python2-psutil \
HEP_OSlibs git \
yum-plugin-ovl openssl \
glibc-devel.i686 glibc-devel \
glibc-headers \
sudo nano && \
yum clean -y all
RUN wget http://repository.egi.eu/sw/production/cas/1/current/repo-files/EGI-trustanchors.repo && \
mv EGI-trustanchors.repo /etc/yum.repos.d/ && \
wget http://repository.egi.eu/sw/production/cas/1/GPG-KEY-EUGridPMA-RPM-3 && \
mv GPG-KEY-EUGridPMA-RPM-3 /etc/pki/rpm-gpg/ && \
wget http://linuxsoft.cern.ch/wlcg/wlcg-centos8.repo && \
mv wlcg-centos8.repo /etc/yum.repos.d/ && \
wget http://linuxsoft.cern.ch/wlcg/RPM-GPG-KEY-wlcg && \
mv RPM-GPG-KEY-wlcg /etc/pki/rpm-gpg/ && \
yum install -y ca-policy-egi-core wlcg-repo.noarch wlcg-voms-cms && \
yum clean -y all
RUN groupadd -g 1000 cmsusr && adduser -u 1000 -g 1000 -G root cmsusr && \
echo "cmsusr ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers && \
groupadd -g 1001 cmsinst && adduser -u 1001 -g 1001 cmsinst && \
install -d /opt && install -d -o cmsinst /opt/cms
# Make Images grid/singularity compatible
RUN mkdir -p /cvmfs /afs /eos /opt/cms /pool
# Add a couple of useful files to cmsusr account
WORKDIR /home/cmsusr
USER cmsusr
ENV USER cmsusr
ENV HOME /home/cmsusr
ADD dot-pythonrc.py $HOME/.pythonrc.py
ADD dot-bashrc $HOME/.bashrc
ADD dot-bashrc $HOME/.zshrc
ADD entrypoint.sh /opt/cms/entrypoint.sh
RUN sudo chmod 755 /opt/cms/entrypoint.sh && \
sudo chown -R cmsusr /home/cmsusr && \
chmod 755 /home/cmsusr
ENTRYPOINT ["/opt/cms/entrypoint.sh"]
CMD ["/bin/zsh"]
default: build
# Build Docker image
build: docker_build output
# Build and push Docker image
release: docker_build docker_push output
# Image can be overidden with env var.
DOCKER_IMAGE ?= cmscloud/cc8-cms
CERN_IMAGE ?= gitlab-registry.cern.ch/cms-cloud/cmssw-docker/cc8-cvmfs
# Get the latest commit.
GIT_COMMIT = $(strip $(shell git rev-parse --short HEAD))
# Get the date as version number
CODE_VERSION = $(strip $(shell date +"%Y-%m-%d"))
# Find out if the working directory is clean
GIT_NOT_CLEAN_CHECK = $(shell git status --porcelain)
ifneq (x$(GIT_NOT_CLEAN_CHECK), x)
DOCKER_TAG_SUFFIX = "-dirty"
endif
# If we're releasing to Docker Hub, and we're going to mark it with the latest tag, it should exactly match a version release
ifeq ($(MAKECMDGOALS),release)
# Use the version number as the release tag.
DOCKER_TAG = $(CODE_VERSION)
# See what commit is tagged to match the version
VERSION_COMMIT = $(strip $(shell git rev-list $(CODE_VERSION) -n 1 | cut -c1-7))
ifneq ($(VERSION_COMMIT), $(GIT_COMMIT))
$(error echo You are trying to push a build based on commit $(GIT_COMMIT) but the tagged release version is $(VERSION_COMMIT))
endif
# Don't push to Docker Hub if this isn't a clean repo
ifneq (x$(GIT_NOT_CLEAN_CHECK), x)
$(error echo You are trying to release a build based on a dirty repo)
endif
else
# Add the commit ref for development builds. Mark as dirty if the working directory isn't clean
DOCKER_TAG = $(CODE_VERSION)-$(GIT_COMMIT)$(DOCKER_TAG_SUFFIX)
endif
docker_build:
# Build Docker image
docker build \
--build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \
--build-arg VERSION=$(CODE_VERSION) \
--build-arg VCS_URL=`git config --get remote.origin.url` \
--build-arg VCS_REF=$(GIT_COMMIT) \
-t $(DOCKER_IMAGE):$(DOCKER_TAG) \
--compress --squash .
# Tag image as latest
docker tag $(DOCKER_IMAGE):$(DOCKER_TAG) $(DOCKER_IMAGE):latest
docker_push:
# Tag image also for CERN GitLab container registry
docker tag $(DOCKER_IMAGE):$(DOCKER_TAG) $(CERN_IMAGE):$(DOCKER_TAG)
docker tag $(DOCKER_IMAGE):$(DOCKER_TAG) $(CERN_IMAGE):latest
# Push to DockerHub
docker push $(DOCKER_IMAGE):$(DOCKER_TAG)
docker push $(DOCKER_IMAGE):latest
# Push to CERN GitLab container registry
docker push $(CERN_IMAGE):$(DOCKER_TAG)
docker push $(CERN_IMAGE):latest
output:
@echo Docker Image: $(DOCKER_IMAGE):$(DOCKER_TAG)
## .bashrc/.zshrc
export PYTHONSTARTUP=$HOME/.pythonrc.py
export PS1='[\t] \e[91m\u\e[0m@\e[34m\h \e[36m\w \e[0m$ '
export PROMPT='[%*] %F{red}%n%f@%F{blue}%m%f %F{yellow}%3~%f $ '
# define aliases
alias cmsenv='eval `scramv1 runtime -sh`'
alias cmsrel='scramv1 project CMSSW'
##
## for tab-completion
##
import rlcompleter, readline
readline.parse_and_bind('tab: complete')
readline.parse_and_bind( 'set show-all-if-ambiguous On' )
##
## for history
##
import os, atexit
histfile = os.path.join(os.environ["HOME"], ".python_history")
try:
readline.read_history_file(histfile)
except IOError:
pass
atexit.register(readline.write_history_file, histfile)
del os, atexit, histfile
del readline
#!/bin/sh
set -e
echo "::: Setting up CMS environment\
(works only if /cvmfs is mounted on host) ..."
if [ -f /cvmfs/cms.cern.ch/cmsset_default.sh ]; then
source /cvmfs/cms.cern.ch/cmsset_default.sh
echo "::: Setting up CMS environment... [done]"
else
echo "::: Could not set up CMS environment... [ERROR]"
echo "::: /cvmfs/cms.cern.ch/cmsset_default.sh not found/available"
fi
exec "$@"
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment