added source file for podman
This commit is contained in:
75
Dockerfile
Normal file
75
Dockerfile
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
FROM bci/bci-init:latest
|
||||||
|
|
||||||
|
LABEL Description="Warewulf Base Container"
|
||||||
|
LABEL maintainer="Christian Goll <cgoll@suse.com>"
|
||||||
|
|
||||||
|
|
||||||
|
RUN zypper -n install \
|
||||||
|
cpio \
|
||||||
|
gzip \
|
||||||
|
pigz \
|
||||||
|
rsync \
|
||||||
|
openssh-clients \
|
||||||
|
less \
|
||||||
|
dhcp-server \
|
||||||
|
tftp \
|
||||||
|
go1.18 \
|
||||||
|
git \
|
||||||
|
&& \
|
||||||
|
zypper -n install -t pattern devel_basis && \
|
||||||
|
zypper clean -a && \
|
||||||
|
systemctl enable dhcpd && \
|
||||||
|
systemctl enable tftp.socket
|
||||||
|
|
||||||
|
# now build the warewulf
|
||||||
|
COPY . /warewulf-src
|
||||||
|
RUN cd /warewulf-src &&\
|
||||||
|
make clean &&\
|
||||||
|
make lint &&\
|
||||||
|
make
|
||||||
|
|
||||||
|
# Our dhcpd will listen on ANY interface, limits will be handled by container runtime
|
||||||
|
RUN export DHCPDCONF=/etc/sysconfig/dhcpd; test -e $DHCPDCONF && \
|
||||||
|
sed -i 's/^DHCPD_INTERFACE=""/DHCPD_INTERFACE="ANY"/' $DHCPDCONF && \
|
||||||
|
sed -i 's/^DHCPD_RUN_CHROOTED="yes"/DHCPD_RUN_CHROOTED="no"/' $DHCPDCONF && \
|
||||||
|
WW4CONF=/etc/warewulf/warewulf.conf; test -e $WW4CONF && \
|
||||||
|
sed -i 's/^ipaddr:.*/ipaddr: EMPTY/' $WW4CONF && \
|
||||||
|
sed -i 's/^netmask:.*/netmask: EMPTY/' $WW4CONF && \
|
||||||
|
sed -i 's/^network:.*/network: EMPTY/' $WW4CONF && \
|
||||||
|
sed -i 's/^ range start:.*/ range start: EMPTY/' $WW4CONF && \
|
||||||
|
sed -i 's/^ range end:.*/ range end: EMPTY/' $WW4CONF
|
||||||
|
|
||||||
|
|
||||||
|
# We need the configs on the host as these files are quite important
|
||||||
|
RUN mkdir -p /container/warewulf && cp -rv /etc/warewulf/* /container/warewulf
|
||||||
|
COPY warewulf.service \
|
||||||
|
warewulf-container-manage.sh \
|
||||||
|
wwctl \
|
||||||
|
label-install \
|
||||||
|
label-uninstall \
|
||||||
|
label-purge \
|
||||||
|
/container
|
||||||
|
|
||||||
|
# Add a service which will create a porper config on the startup
|
||||||
|
COPY ww4-config.service \
|
||||||
|
/etc/systemd/system/
|
||||||
|
|
||||||
|
RUN systemctl enable ww4-config
|
||||||
|
|
||||||
|
|
||||||
|
RUN chmod +x \
|
||||||
|
/container/wwctl \
|
||||||
|
/container/warewulf-container-manage.sh \
|
||||||
|
/container/label-*
|
||||||
|
|
||||||
|
# need systemd for tftp and dhcpd
|
||||||
|
#ENTRYPOINT [ "/container/label-run" ]
|
||||||
|
CMD [ "/usr/sbin/init" ]
|
||||||
|
|
||||||
|
#EXPOSE 67/udp 68/udp 69/udp 9873
|
||||||
|
|
||||||
|
LABEL INSTALL="/usr/bin/docker run --env IMAGE=IMAGE --rm --privileged -v /:/host IMAGE /bin/bash /container/label-install"
|
||||||
|
LABEL UNINSTALL="/usr/bin/docker run --rm --privileged -v /:/host IMAGE /bin/bash /container/label-uninstall"
|
||||||
|
LABEL PURGE="/usr/bin/docker run -ti --rm --privileged -v /:/host IMAGE /bin/bash /container/label-purge"
|
||||||
|
LABEL RUN="/usr/bin/docker run -d --replace --name \${NAME} --privileged --net=host -v /:/host -v /etc/warewulf:/etc/warewulf -v /var/lib/warewulf/:/var/lib/warewulf/ -e NAME=\${NAME} -e IMAGE=\${IMAGE} \${IMAGE}"
|
||||||
|
|
||||||
75
container-scripts/label-install
Normal file
75
container-scripts/label-install
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
#!/bin/sh -eu
|
||||||
|
|
||||||
|
# This is the install script for warewulf when run in a privileged
|
||||||
|
# container.
|
||||||
|
|
||||||
|
cd /
|
||||||
|
PATH="/usr/bin:/usr/sbin"
|
||||||
|
CONTAINER=warewulf
|
||||||
|
BINSCRIPT=${CONTAINER}-container-manage.sh
|
||||||
|
WWCTL=wwctl
|
||||||
|
OVERLAYDIR=/var/lib/warewulf/overlays
|
||||||
|
CHROOTDIR=/var/lib/warewulf/chroots
|
||||||
|
CONTAINERDIR=/var/lib/warewulf/container
|
||||||
|
WAREWULFCONF=/etc/warewulf
|
||||||
|
BASHCOMPLETION=/usr/share/bash-completion/completions/wwctl
|
||||||
|
|
||||||
|
echo "LABEL INSTALL"
|
||||||
|
# ensure all scripts will be present on the host
|
||||||
|
copy_to_usr_local_bin() {
|
||||||
|
SCRIPT=$1
|
||||||
|
BASEDIR=`dirname $SCRIPT`
|
||||||
|
mkdir -p $BASEDIR
|
||||||
|
if [ ! -e /host/usr/local/bin/${SCRIPT} ]; then
|
||||||
|
echo "copy /container/${SCRIPT} in /host/usr/local/bin/"
|
||||||
|
rsync -u /container/${SCRIPT} /host/usr/local/bin/${SCRIPT}
|
||||||
|
else
|
||||||
|
echo "/host/usr/local/bin/${SCRIPT} already exist, will not update it"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
copy_to_etc() {
|
||||||
|
CONF=$1
|
||||||
|
BASEDIR=`dirname $CONF`
|
||||||
|
mkdir -p $BASEDIR
|
||||||
|
if [ ! -e /host/etc/${CONF} ]; then
|
||||||
|
echo "copy /container/${CONF} in /host/etc/"
|
||||||
|
rsync -u /container/${CONF} /host/etc/${CONF}
|
||||||
|
else
|
||||||
|
echo "/host/etc/${CONF} already exist, will not update it"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
sync_dir() {
|
||||||
|
DIR=$1
|
||||||
|
test -e /host/${DIR} || mkdir -pv /host/${DIR}
|
||||||
|
test -e /host/${DIR} && (rsync -au ${DIR} `dirname /host/${DIR}`; echo "updating $DIR")
|
||||||
|
}
|
||||||
|
|
||||||
|
# For podman, cp a systemd unit for starting on boot
|
||||||
|
if [ ! -e /host/etc/systemd/system/${CONTAINER}.service ]; then
|
||||||
|
mkdir -p /host/etc/systemd/system/
|
||||||
|
rsync -u /container/${CONTAINER}.service /host/etc/systemd/system/${CONTAINER}.service
|
||||||
|
else
|
||||||
|
echo "/host/etc/systemd/system/${CONTAINER}.service already exist"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# create the dirs
|
||||||
|
mkdir -p /host/etc/warewulf
|
||||||
|
mkdir -p /host/var/lib/warewulf
|
||||||
|
|
||||||
|
copy_to_usr_local_bin ${WWCTL}
|
||||||
|
copy_to_usr_local_bin ${BINSCRIPT}
|
||||||
|
|
||||||
|
# now sync hosts and overlays
|
||||||
|
sync_dir $OVERLAYDIR
|
||||||
|
sync_dir $CHROOTDIR
|
||||||
|
sync_dir $WAREWULFCONF
|
||||||
|
|
||||||
|
# bash completion
|
||||||
|
if [ ! -e /host/etc/bash_completion.d/wwctl ] ; then
|
||||||
|
mkdir -p /host/etc/bash_completion.d
|
||||||
|
cp $BASHCOMPLETION /host/etc/bash_completion.d/
|
||||||
|
fi
|
||||||
|
|
||||||
|
# containerdir
|
||||||
|
mkdir -p /host/$CONTAINERDIR
|
||||||
33
container-scripts/label-purge
Normal file
33
container-scripts/label-purge
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
OVERLAYDIR=/var/lib/warewulf/overlays
|
||||||
|
CHROOTDIR=/var/lib/warewulf/chroots
|
||||||
|
CONTAINERDIR=/var/lib/warewulf/container
|
||||||
|
WAREWULFCONF=/etc/warewulf
|
||||||
|
BASEDIR=/var/lib/warewulf
|
||||||
|
cat >&2 << EOF
|
||||||
|
WARNING:
|
||||||
|
Purging all warewulf configurations, containers aka node images and overlays
|
||||||
|
Wating for 10s, press any key to abort
|
||||||
|
EOF
|
||||||
|
|
||||||
|
count=0
|
||||||
|
while true ; do
|
||||||
|
if read -t 0; then # Input ready
|
||||||
|
read -n 1 char
|
||||||
|
echo "Aborting purge"
|
||||||
|
exit 0
|
||||||
|
else # No input
|
||||||
|
echo -n '.'
|
||||||
|
sleep 1
|
||||||
|
count=$(( $count + 1))
|
||||||
|
if [ $count -eq 10 ] ; then
|
||||||
|
echo
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
echo "PURGING"
|
||||||
|
/container/label-uninstall
|
||||||
|
rm -rv /host/$WAREWULFCONF /host/$OVERLAYDIR /host/$CHROOTDIR /host/$CONTAINERDIR
|
||||||
|
rmdir /host/$BASEDIR
|
||||||
|
|
||||||
20
container-scripts/label-uninstall
Normal file
20
container-scripts/label-uninstall
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
#!/bin/sh -eu
|
||||||
|
|
||||||
|
# This is the uninstall script for grafana when run in a privileged
|
||||||
|
# container.
|
||||||
|
|
||||||
|
CONTAINER=warewulf
|
||||||
|
cd /
|
||||||
|
PATH="/usr/bin:/usr/sbin"
|
||||||
|
|
||||||
|
if [ ! -d /host/etc ] || [ ! -d /host/usr/local/bin ]; then
|
||||||
|
echo "${CONTAINER}-uninstall: host file system is not mounted at /host"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# removing installed files
|
||||||
|
echo "LABEL UNINSTALL: Removing all files"
|
||||||
|
rm -vf /host/usr/local/bin/wwctl
|
||||||
|
rm -vf /host/usr/local/bin/warewulf-container-manage.sh
|
||||||
|
rm -vf /host/etc/systemd/system/${CONTAINER}.service
|
||||||
|
rm -vf /host/usr/share/bash-completion/completions/wwctl
|
||||||
Reference in New Issue
Block a user