Skip to content

Commit 9e247f5

Browse files
Merge pull request #100 from matyasselmeci/pr/el10
EL10 / OSG 25 support for docker-software-base
2 parents c6a2f3f + 392b226 commit 9e247f5

File tree

4 files changed

+189
-13
lines changed

4 files changed

+189
-13
lines changed

.github/workflows/build-container.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,20 @@ jobs:
3131
tag_str: 'el9'
3232
- image: 'nvidia/cuda:11.8.0-runtime-rockylinux8'
3333
tag_str: 'cuda_11_8_0'
34+
- image: 'hub.opensciencegrid.org/osg-htc/alma10-base:combo'
35+
# ^^ see scripts/create-alma10-base.sh for how this gets created
36+
tag_str: 'el10'
3437
repo: ['development', 'testing', 'release']
35-
series: ['23', '24']
38+
series: ['23', '24', '25']
39+
exclude:
40+
- series: '23'
41+
base: {image: 'hub.opensciencegrid.org/osg-htc/alma10-base:combo', tag_str: 'el10'}
42+
- series: '24'
43+
base: {image: 'hub.opensciencegrid.org/osg-htc/alma10-base:combo', tag_str: 'el10'}
44+
- series: '25'
45+
repo: 'release'
46+
- series: '25'
47+
repo: 'testing'
3648
needs: make-date-tag
3749
steps:
3850
- name: checkout docker-software-base

Dockerfile

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,15 @@ ARG IMAGE_BASE=quay.io/almalinux/almalinux:9
33

44
FROM $IMAGE_BASE
55

6-
# "ARG IMAGE_BASE" needs to be here again because the previous instance has gone out of scope.
7-
ARG IMAGE_BASE=quay.io/almalinux/almalinux:9
86
ARG BASE_YUM_REPO=testing
9-
ARG OSG_RELEASE=23
7+
ARG OSG_RELEASE=24
108

119
LABEL maintainer OSG Software <[email protected]>
1210

1311
RUN \
1412
log () { printf "\n%s\t%s\n\n" "$(date '+%F %X %z')" "$*" ; } ; \
15-
# Attempt to grab the major version from the tag \
16-
DVER=$(egrep -o '[0-9][\.0-9]*$' <<< "$IMAGE_BASE" | cut -d. -f1); \
13+
# Grab the major version /etc/os-release \
14+
DVER=$(awk -F '[=".]+' '/^VERSION_ID=/ {print $2}' /etc/os-release); \
1715
log "Updating OS YUM cache" && time \
1816
yum makecache && \
1917
log "Updating OS" && time \
@@ -30,6 +28,9 @@ RUN \
3028
yum-config-manager --enable osg-upcoming-${BASE_YUM_REPO}; else \
3129
yum-config-manager --enable osg-upcoming; \
3230
fi && \
31+
# Impatiently ignore the Yum mirrors
32+
sed -i 's/\#baseurl/baseurl/; s/mirrorlist/\#mirrorlist/' \
33+
/etc/yum.repos.d/osg*.repo && \
3334
log "Updating EPEL/OSG YUM cache" && time \
3435
yum makecache && \
3536
log "Installing common software" && time \
@@ -50,11 +51,8 @@ RUN \
5051
log "Cleaning up YUM metadata" && time \
5152
yum clean all && \
5253
rm -rf /var/cache/yum/ && \
53-
# Impatiently ignore the Yum mirrors
54-
sed -i 's/\#baseurl/baseurl/; s/mirrorlist/\#mirrorlist/' \
55-
/etc/yum.repos.d/osg*.repo && \
5654
mkdir -p /etc/osg/image-{cleanup,init}.d/ && \
57-
# Support old init script dir name
55+
# Support old init script dir name \
5856
ln -s /etc/osg/image-{init,config}.d
5957

6058
COPY bin/* /usr/local/bin/
@@ -72,6 +70,7 @@ RUN chmod g+w /var/log /var/log/supervisor /var/run
7270

7371
# Allow use of SHA1 certificates.
7472
# Accepted values are "YES" (enable them, even on EL9), "NO" (disable them, even on EL8), "DEFAULT" (use OS default).
73+
# No effect on EL10
7574
ENV ENABLE_SHA1=DEFAULT
7675

7776
CMD ["/usr/local/sbin/supervisord_startup.sh"]

image-init.d/10-set-crypto-policies.sh

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@
22

33
if [[ $(id -u) = 0 ]]; then # only root can update crypto policies
44
# Set system crypto policies based on the ENABLE_SHA1 environment variable.
5+
is_el8=false
6+
is_el9=false
57
if grep -q '^VERSION_ID=["]8' /etc/os-release; then
68
is_el8=true
9+
elif grep -q '^VERSION_ID=["]9' /etc/os-release; then
10+
is_el9=true
711
else
8-
is_el8=false
12+
: # SHA1 is not supported on el10
913
fi
1014

1115
if command -v update-crypto-policies &>/dev/null; then
@@ -15,14 +19,16 @@ if [[ $(id -u) = 0 ]]; then # only root can update crypto policies
1519
YES)
1620
if $is_el8; then
1721
update-crypto-policies --set DEFAULT >/dev/null
18-
else
22+
elif $is_el9; then
1923
update-crypto-policies --set DEFAULT:SHA1 >/dev/null
24+
else
25+
echo "SHA1 is not supported on this platform; please unset ENABLE_SHA1"
2026
fi
2127
;;
2228
NO)
2329
if $is_el8; then
2430
update-crypto-policies --set DEFAULT:NO-SHA1 >/dev/null
25-
else
31+
elif $is_el9; then
2632
update-crypto-policies --set DEFAULT >/dev/null
2733
fi
2834
;;

scripts/create-alma10-base.sh

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
#!/bin/bash
2+
__SUMMARY__=$(cat <<__end__
3+
create-alma10-base
4+
5+
Create and push the Almalinux 10 image that will be used as a base for
6+
EL 10 builds. We need a single manifest that contains both an
7+
ARM image and an x86-64 image but the x86-64 image should be
8+
x86-64-v2-compatible.
9+
10+
This script should be run on an x86-64 host.
11+
12+
This script uses podman because docker's manifest manipulation commands
13+
aren't as good (for example, 'docker manifest add' is missing).
14+
15+
We go through some hoops to keep podman from sneakily downloading an
16+
image with the platform of the host system instead of the one we're
17+
trying to include in the manifest.
18+
__end__
19+
)
20+
21+
22+
REGISTRY=hub.opensciencegrid.org
23+
BASE_IMAGE=docker.io/almalinux/10-base:10
24+
ARM_IMAGE=alma10-arm.${RANDOM}
25+
X86_64_IMAGE=alma10-v2.${RANDOM}
26+
COMBINED_MANIFEST=${REGISTRY}/osg-htc/alma10-base:combo
27+
28+
29+
Prog=${0##*/}
30+
31+
32+
ask_yn () {
33+
while read -rn1 -p "$* (y/n) "
34+
do
35+
case $REPLY in
36+
[Yy]) return 0;;
37+
[Nn]) return 1;;
38+
*) echo >&2 "Enter y or n";;
39+
esac
40+
done
41+
return 2 # EOF
42+
}
43+
44+
45+
fail () {
46+
set +exu
47+
local ret=${1}
48+
shift
49+
echo -e "$Prog:" "$@" >&2
50+
exit "$ret"
51+
}
52+
53+
54+
warn () {
55+
local ret=${1}
56+
shift
57+
echo -e "$Prog:" "$@" >&2
58+
return "$ret"
59+
}
60+
61+
62+
usage () {
63+
echo >&2 "$__SUMMARY__"
64+
echo >&2
65+
echo >&2 "Usage: $Prog"
66+
exit "$1"
67+
}
68+
69+
70+
require_program () {
71+
command -v "$1" &>/dev/null ||
72+
fail 127 "Required program '$1' not found in PATH"
73+
}
74+
75+
if [[ $* == -h || $* == --help ]]; then
76+
usage 0
77+
fi
78+
79+
require_program podman
80+
81+
82+
set -o nounset
83+
84+
85+
on_exit () {
86+
if podman image exists ${BASE_IMAGE}.bak
87+
then
88+
podman untag ${BASE_IMAGE}
89+
podman tag ${BASE_IMAGE}.bak ${BASE_IMAGE} || warn "Unable to restore old ${BASE_IMAGE}"
90+
fi
91+
if podman image exists ${X86_64_IMAGE}
92+
then
93+
podman untag ${X86_64_IMAGE}
94+
fi
95+
if podman image exists ${ARM_IMAGE}
96+
then
97+
podman untag ${ARM_IMAGE}
98+
fi
99+
}
100+
101+
102+
# If the user has an existing base image, back it up
103+
if podman image exists ${BASE_IMAGE}
104+
then
105+
podman untag ${BASE_IMAGE}.bak &>/dev/null || :
106+
podman tag ${BASE_IMAGE} ${BASE_IMAGE}.bak || fail 3 "Unable to back up old ${BASE_IMAGE}"
107+
fi
108+
109+
trap on_exit EXIT
110+
111+
# Build the x86-64 image (based on the x86-64-v2 image from Docker Hub)
112+
podman build -t ${X86_64_IMAGE} -f- <<__end__
113+
# Copies all of the x86-64-v2 almalinux/10-base image into a new linux/amd64 image,
114+
# changing the platform docker thinks the image is (to avoid a platform mismatch
115+
# warning every time we try to run the image).
116+
117+
FROM --platform=linux/amd64/v2 ${BASE_IMAGE} AS alma10base
118+
119+
FROM --platform=linux/amd64 scratch
120+
COPY --from=alma10base / /
121+
CMD ["/bin/bash"]
122+
__end__
123+
# shellcheck disable=SC2181
124+
if [[ $? != 0 ]]
125+
then
126+
fail 4 "Unable to build x86_64 image"
127+
fi
128+
129+
# Untag the image we downloaded as part of the build and replace it with the ARM image
130+
podman untag ${BASE_IMAGE} || fail 5 "Unable to untag old ${BASE_IMAGE}"
131+
podman pull --platform=linux/arm64 ${BASE_IMAGE} || fail 6 "Unable to pull ARM image"
132+
# Rename the ARM image (otherwise podman will replace it with an x86-64 image when we try to add it to the manifest)
133+
podman tag ${BASE_IMAGE} ${ARM_IMAGE}
134+
# Create a new, empty manifest
135+
podman manifest rm ${COMBINED_MANIFEST} &>/dev/null || :
136+
(
137+
set -e
138+
podman manifest create ${COMBINED_MANIFEST}
139+
# Add the images for our two platforms.
140+
podman manifest add ${COMBINED_MANIFEST} ${X86_64_IMAGE}
141+
podman manifest add ${COMBINED_MANIFEST} ${ARM_IMAGE}
142+
) || fail 5 "Unable to create manifest"
143+
144+
echo "Manifest created: ${COMBINED_MANIFEST}"
145+
if ask_yn "Log in and push to ${REGISTRY}?"
146+
then
147+
podman login ${REGISTRY}
148+
podman manifest push ${COMBINED_MANIFEST} || fail 6 "Unable to push manifest;\n" \
149+
"once you have resolved the problem, you may push manually by running\n" \
150+
"\n" \
151+
"podman manifest push ${COMBINED_MANIFEST}"
152+
else
153+
echo "Not pushing. You may push manually by running"
154+
echo
155+
echo "podman manifest push ${COMBINED_MANIFEST}"
156+
fi
157+
158+
159+
# vim:et:sw=4:sts=4:ts=8

0 commit comments

Comments
 (0)