Skip to content

Commit 6041ad4

Browse files
authored
Merge pull request #67 from stackhpc/rocky-container-pulp-2
Build DIB images from StackHPC package mirrors
2 parents e9f19c4 + 9ab176c commit 6041ad4

File tree

8 files changed

+109
-1
lines changed

8 files changed

+109
-1
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
========================
2+
apt-no-verify-peer
3+
========================
4+
Disable certificate verifiction for apt repositories.
5+
6+
No additional configuration is needed, other than including the element.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
3+
if [ ${DIB_DEBUG_TRACE:-1} -gt 0 ]; then
4+
set -x
5+
fi
6+
set -eu
7+
set -o pipefail
8+
9+
sudo rm -f ${TARGET_ROOT}/etc/apt/apt.conf.d/90no-verify-peer # dib-lint: safe_sudo
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
if [ ${DIB_DEBUG_TRACE:-0} -gt 0 ]; then
3+
set -x
4+
fi
5+
set -eu
6+
set -o pipefail
7+
8+
# Ensure apt doesn't verify the certificate issuer
9+
sudo mkdir -p ${TARGET_ROOT}/etc/apt/apt.conf.d/ # dib-lint: safe_sudo
10+
echo 'Acquire::https::Verify-Peer "false";' |\
11+
sudo tee ${TARGET_ROOT}/etc/apt/apt.conf.d/90no-verify-peer > /dev/null # dib-lint: safe_sudo
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
========================
2+
purge-command-not-found
3+
========================
4+
Purge command-not-found packages from an image.
5+
6+
Currently the pulp_deb plugin in Pulp does not support certain types of
7+
content, including i18n files and command-not-found indices. This breaks APT
8+
when the command-not-found is installed. This element can be used to
9+
uninstall the package, prior to running any other APT commands that may target
10+
Pulp package mirrors.
11+
12+
No additional configuration is needed, other than including the element.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
if [ ${DIB_DEBUG_TRACE:-0} -gt 0 ]; then
3+
set -x
4+
fi
5+
set -eu
6+
set -o pipefail
7+
8+
sudo apt purge -y command-not-found python3-commandnotfound

elements/rocky-container-stackhpc/README.rst

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,26 @@
22
rocky-container-stackhpc
33
========================
44
Custom containerfiles for usage with ``rocky-container`` builds.
5+
56
Usage:
67
Set ``DIB_CONTAINERFILE_DOCKERFILE`` environment variable to custom
78
Containerfile path provided by this role, e.g.:
89
DIB_CONTAINERFILE_DOCKERFILE: "/opt/kayobe/src/stackhpc-image-elements/elements/rocky-container-stackhpc/containerfiles/9-stackhpc"
10+
11+
Pass ``ROCKY_USE_CUSTOM_DNF_MIRRORS=true`` as a build-arg to disable
12+
upstream Rocky repository mirrors.
13+
14+
``ROCKY_CUSTOM_DNF_MIRROR_URLS`` is a comma-delimited list of repository URLs
15+
to build an image from, and should also be passed as a build-arg.
16+
``ROCKY_CUSTOM_DNF_MIRROR_URLS`` will be removed from the final image.
17+
18+
Use ``DIB_CONTAINERFILE_BUILDOPTS`` to pass through build args to the container
19+
engine:
20+
21+
.. code-block:: yaml
22+
DIB_CONTAINERFILE_BUILDOPTS: >-
23+
--build-arg=ROCKY_USE_CUSTOM_DNF_MIRRORS=true
24+
--build-arg=ROCKY_CUSTOM_DNF_MIRROR_URLS=http://localhost/rocky/9/AppStream/x86_64/os/,http://localhost/rocky/9/BaseOS/x86_64/os/
25+
26+
Set ``DIB_ROCKY_CONTAINER_STACKHPC_RESTORE_UPSTREAM_REPOFILES=true`` to restore the
27+
upstream Rocky repository mirror configuration in the final image.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
3+
if [ ${DIB_DEBUG_TRACE:-0} -gt 0 ]; then
4+
set -x
5+
fi
6+
set -eu
7+
set -o pipefail
8+
9+
DIB_ROCKY_CONTAINER_STACKHPC_RESTORE_UPSTREAM_REPOFILES=${DIB_ROCKY_CONTAINER_STACKHPC_RESTORE_UPSTREAM_REPOFILES:-"false"}
10+
11+
[ -n "$TARGET_ROOT" ]
12+
13+
# Remove custom repo files
14+
if [ -d /tmp/orig_repos ]; then
15+
sudo rm -f ${TARGET_ROOT}/etc/yum.repos.d/*.repo
16+
fi
17+
18+
# Conditionally restore upstream repo files
19+
if [[ ${DIB_ROCKY_CONTAINER_STACKHPC_RESTORE_UPSTREAM_REPOFILES} != "false" ]]; then
20+
sudo cp -f ${TARGET_ROOT}/tmp/orig_repos/*.repo ${TARGET_ROOT}/etc/yum.repos.d/
21+
fi
22+
23+
# Cleanup temporary copies of original repo files
24+
sudo rm -rf ${TARGET_ROOT}/tmp/orig_repos

elements/rocky-container-stackhpc/containerfiles/9-stackhpc

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,30 @@
11
# Based on https://github.com/openstack/diskimage-builder/blob/master/diskimage_builder/elements/rocky-container/containerfiles/9
22

33
FROM docker.io/rockylinux/rockylinux:9
4+
ARG ROCKY_USE_CUSTOM_DNF_MIRRORS="false"
5+
# Comma-delimited list of repo URLs
6+
ARG ROCKY_CUSTOM_DNF_MIRROR_URLS
7+
8+
RUN if [[ ${ROCKY_USE_CUSTOM_DNF_MIRRORS} != "false" ]]; then \
9+
dnf -y install 'dnf-command(config-manager)' && \
10+
mkdir /tmp/orig_repos && mv /etc/yum.repos.d/*.repo /tmp/orig_repos/ && \
11+
for REPO_URL in $(echo ${ROCKY_CUSTOM_DNF_MIRROR_URLS} | sed 's/,/ /g'); do \
12+
dnf config-manager --add-repo ${REPO_URL}; \
13+
done && \
14+
dnf --allowerasing -y distro-sync; \
15+
fi
416

517
RUN dnf group install -y 'Minimal Install' --allowerasing && \
618
dnf install -y findutils util-linux cloud-init
719

8-
RUN sed -i "s/renderers:.*/renderers: ['network-manager']\n activators: ['network-manager']/" /etc/cloud/cloud.cfg
20+
COPY <<EOF /etc/cloud/cloud.cfg.d/10-NetworkManager.cfg
21+
---
22+
system_info:
23+
activators:
24+
- "network-manager"
25+
26+
merge_type: 'dict(recurse_array)'
27+
EOF
928

1029
RUN systemctl unmask console-getty.service dev-hugepages.mount \
1130
getty.target sys-fs-fuse-connections.mount systemd-logind.service \

0 commit comments

Comments
 (0)