Move docker build stuff into a subdirectory. Update structure to retire manual-{pre,post}
This commit is contained in:
25
docker/Dockerfile.bookworm
Normal file
25
docker/Dockerfile.bookworm
Normal file
@ -0,0 +1,25 @@
|
||||
FROM debian:bookworm
|
||||
ARG DEBIAN_FRONTEND=noninteractive
|
||||
ARG VPP_INSTALL_SKIP_SYSCTL=true
|
||||
ARG REPO=release
|
||||
EXPOSE 22/tcp
|
||||
RUN apt-get update && apt-get -y install curl procps tcpdump iproute2 iptables \
|
||||
iputils-ping net-tools git python3 python3-pip vim-tiny openssh-server bird2 \
|
||||
mtr-tiny traceroute && apt-get clean
|
||||
|
||||
# Install VPP
|
||||
RUN mkdir -p /var/log/vpp /root/.ssh/
|
||||
RUN curl -s https://packagecloud.io/install/repositories/fdio/${REPO}/script.deb.sh | bash
|
||||
RUN apt-get update && apt-get -y install vpp vpp-plugin-core && apt-get clean
|
||||
|
||||
# Build vppcfg
|
||||
RUN pip install --break-system-packages build netaddr yamale argparse pyyaml ipaddress
|
||||
RUN git clone https://github.com/pimvanpelt/vppcfg.git && cd vppcfg && python3 -m build && \
|
||||
pip install --break-system-packages dist/vppcfg-*-py3-none-any.whl
|
||||
|
||||
# Config files
|
||||
COPY files/etc/vpp/* /etc/vpp/
|
||||
COPY files/etc/bird/* /etc/bird/
|
||||
COPY files/init-container.sh /sbin/
|
||||
RUN chmod 755 /sbin/init-container.sh
|
||||
CMD ["/sbin/init-container.sh"]
|
1
docker/files/etc/bird/bird-local.conf
Normal file
1
docker/files/etc/bird/bird-local.conf
Normal file
@ -0,0 +1 @@
|
||||
# Containerlab user overrides go in this file.
|
26
docker/files/etc/bird/bird.conf
Normal file
26
docker/files/etc/bird/bird.conf
Normal file
@ -0,0 +1,26 @@
|
||||
# Bird2 configuration for VPP Containerlab
|
||||
|
||||
# router id 192.0.2.0;
|
||||
|
||||
timeformat base iso long;
|
||||
timeformat log iso long;
|
||||
timeformat protocol iso long;
|
||||
timeformat route iso long;
|
||||
|
||||
log "/var/log/bird/bird.log" { debug, trace, info, remote, warning, error, auth, fatal, bug };
|
||||
|
||||
protocol device { scan time 30; }
|
||||
|
||||
protocol direct { ipv4; ipv6; check link yes; }
|
||||
|
||||
protocol kernel kernel4 {
|
||||
ipv4 { import none; export where source != RTS_DEVICE; };
|
||||
learn off; scan time 300;
|
||||
}
|
||||
|
||||
protocol kernel kernel6 {
|
||||
ipv6 { import none; export where source != RTS_DEVICE; };
|
||||
learn off; scan time 300;
|
||||
}
|
||||
|
||||
include "bird-local.conf";
|
2
docker/files/etc/vpp/bootstrap.vpp
Normal file
2
docker/files/etc/vpp/bootstrap.vpp
Normal file
@ -0,0 +1,2 @@
|
||||
exec /etc/vpp/clab.vpp
|
||||
exec /etc/vpp/vppcfg.vpp
|
1
docker/files/etc/vpp/clab.vpp
Normal file
1
docker/files/etc/vpp/clab.vpp
Normal file
@ -0,0 +1 @@
|
||||
comment { This file will be overwritten / generated by containerlab upon deploy }
|
50
docker/files/etc/vpp/startup.conf
Normal file
50
docker/files/etc/vpp/startup.conf
Normal file
@ -0,0 +1,50 @@
|
||||
# This is the vpp-containerlab default startup.conf, which is meant to be
|
||||
# overridden by Containerlab's node/fdio_vpp/vpp_startup_config.go.tpl
|
||||
|
||||
unix {
|
||||
interactive
|
||||
log /var/log/vpp/vpp.log
|
||||
full-coredump
|
||||
cli-listen /run/vpp/cli.sock
|
||||
cli-prompt vpp-clab#
|
||||
cli-no-pager
|
||||
poll-sleep-usec 100
|
||||
exec /etc/vpp/bootstrap.vpp
|
||||
}
|
||||
|
||||
api-trace {
|
||||
on
|
||||
}
|
||||
|
||||
memory {
|
||||
main-heap-size 512M
|
||||
main-heap-page-size 4k
|
||||
}
|
||||
|
||||
buffers {
|
||||
buffers-per-numa 16000
|
||||
default data-size 2048
|
||||
page-size 4k
|
||||
}
|
||||
|
||||
statseg {
|
||||
size 64M
|
||||
page-size 4k
|
||||
per-node-counters on
|
||||
}
|
||||
|
||||
plugins {
|
||||
plugin default { enable }
|
||||
plugin dpdk_plugin.so { disable }
|
||||
plugin linux_cp_plugin.so { enable }
|
||||
plugin linux_nl_plugin.so { enable }
|
||||
plugin sflow_plugin.so { enable }
|
||||
}
|
||||
|
||||
linux-cp {
|
||||
default netns dataplane
|
||||
lcp-sync
|
||||
lcp-auto-subint
|
||||
del-static-on-link-down
|
||||
del-dynamic-on-link-down
|
||||
}
|
51
docker/files/init-container.sh
Executable file
51
docker/files/init-container.sh
Executable file
@ -0,0 +1,51 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
STARTUP_CONFIG=${STARTUP_CONFIG:="/etc/vpp/startup.conf"}
|
||||
CLAB_VPP_FILE=${CLAB_VPP_FILE:=/etc/vpp/clab.vpp}
|
||||
VPPCFG_VPP_FILE=${VPPCFG_VPP_FILE:=/etc/vpp/vppcfg.vpp}
|
||||
NETNS=${NETNS:="dataplane"}
|
||||
BIRD_ENABLED=${BIRD_ENABLED:="true"}
|
||||
|
||||
echo "Creating dataplane namespace"
|
||||
/usr/bin/mkdir -p /etc/netns/$NETNS
|
||||
/usr/bin/touch /etc/netns/$NETNS/resolv.conf
|
||||
/usr/sbin/ip netns add $NETNS
|
||||
|
||||
echo "Starting SSH, with credentials root:vpp"
|
||||
sed -i -e 's,^#PermitRootLogin prohibit-password,PermitRootLogin yes,' /etc/ssh/sshd_config
|
||||
sed -i -e 's,^root:.*,root:$y$j9T$kG8pyZEVmwLXEtXekQCRK.$9iJxq/bEx5buni1hrC8VmvkDHRy7ZMsw9wYvwrzexID:20211::::::,' /etc/shadow
|
||||
/etc/init.d/ssh start
|
||||
|
||||
if [ "$BIRD_ENABLED" == "true" ]; then
|
||||
echo "Starting Bird in $NETNS"
|
||||
mkdir -p /run/bird /var/log/bird
|
||||
chown bird:bird /var/log/bird
|
||||
ROUTERID=$(ip -br a show eth0 | awk '{ print $3 }' | cut -f1 -d/)
|
||||
sed -i -e "s,.*router id .*,router id $ROUTERID; # Set by container-init.sh," /etc/bird/bird.conf
|
||||
/usr/bin/nsenter --net=/var/run/netns/$NETNS /usr/sbin/bird -u bird -g bird
|
||||
fi
|
||||
|
||||
echo "Generating $CLAB_VPP_FILE"
|
||||
: > $CLAB_VPP_FILE
|
||||
MTU=9216
|
||||
for IFNAME in $(ip -br link show type veth | cut -f1 -d@ | grep -v '^eth0$' | sort); do
|
||||
MAC=$(ip -br link show dev $IFNAME | awk '{ print $3 }')
|
||||
echo " * $IFNAME hw-addr $MAC mtu $MTU"
|
||||
ip link set $IFNAME up mtu $MTU
|
||||
cat << EOF >> $CLAB_VPP_FILE
|
||||
create host-interface name $IFNAME hw-addr $MAC
|
||||
set interface name host-$IFNAME $IFNAME
|
||||
set interface mtu $MTU $IFNAME
|
||||
set interface state $IFNAME up
|
||||
|
||||
EOF
|
||||
done
|
||||
|
||||
echo "Generating $VPPCFG_VPP_FILE"
|
||||
: > $VPPCFG_VPP_FILE
|
||||
if [ -r /etc/vpp/vppcfg.yaml ]; then
|
||||
vppcfg plan --novpp -c /etc/vpp/vppcfg.yaml -o $VPPCFG_VPP_FILE
|
||||
fi
|
||||
|
||||
echo "Starting VPP"
|
||||
exec /usr/bin/vpp -c $STARTUP_CONFIG
|
Reference in New Issue
Block a user