Add baked-in image capability
Add capability to "bake in" a disk image into a container image. Rework deployment process
This commit is contained in:
parent
bd6050ea3e
commit
7911c7eefc
9 changed files with 108 additions and 39 deletions
4
docker/Corefile
Normal file
4
docker/Corefile
Normal file
|
@ -0,0 +1,4 @@
|
|||
.:53 {
|
||||
forward . /etc/resolv.conf
|
||||
reload
|
||||
}
|
|
@ -1,13 +1,27 @@
|
|||
# Build container
|
||||
FROM debian:11-slim AS builder
|
||||
RUN apt-get -y update && apt-get -y upgrade && apt-get -y install gcc libpcap-dev libvdeplug-dev libpcre3-dev libedit-dev libsdl2-dev libpng-dev libsdl2-ttf-dev build-essential && apt-get clean
|
||||
ADD simh-3.9-0.tgz /
|
||||
WORKDIR /simh-3.9-0
|
||||
RUN make pdp11
|
||||
|
||||
# Final container
|
||||
FROM debian:11-slim
|
||||
ENV DISK_FILENAME=rq0.dsk
|
||||
RUN apt-get -y update && apt-get -y upgrade && apt-get -y install ed libpcap-dev iproute2 iptables gcc vdeplug libpcre3 net-tools telnet
|
||||
RUN apt-get -y update && apt-get -y upgrade && apt-get -y install curl ed gcc iproute2 iptables libpcap-dev libpcre3 net-tools telnet vdeplug
|
||||
|
||||
# Add Tini to handle reaping processes
|
||||
ENV TINI_VERSION 0.19.0
|
||||
ADD https://github.com/krallin/tini/releases/download/v${TINI_VERSION}/tini /tini
|
||||
RUN chmod +x /tini
|
||||
ENTRYPOINT ["/tini", "--"]
|
||||
|
||||
# Add CoreDNS to forward DNS based on /etc/resolv.conf
|
||||
ENV COREDNS_VERSION 1.11.1
|
||||
RUN curl -L https://github.com/coredns/coredns/releases/download/v${COREDNS_VERSION}/coredns_${COREDNS_VERSION}_linux_amd64.tgz|tar -xzC /usr/local/bin/
|
||||
|
||||
COPY --from=builder /simh-3.9-0/BIN/pdp11 /usr/local/bin/pdp11
|
||||
COPY boot.ini.template /
|
||||
COPY startup.sh /
|
||||
CMD /startup.sh
|
||||
|
||||
# Uses pattern matching to optionally copy rq0.dsk.gz if it exists
|
||||
COPY startup.sh Corefile boot.ini.template rq0.dsk.g[z] /
|
||||
CMD ["/startup.sh"]
|
||||
|
|
|
@ -1,25 +1,43 @@
|
|||
#!/bin/sh
|
||||
set -ex
|
||||
set -e
|
||||
|
||||
[ -n "$DISK_FILENAME" ] || DISK_FILENAME="rq0.dsk"
|
||||
[ -f "/mnt/$DISK_FILENAME" ] || { echo "Unable to find tape /mnt/$DISK_FILENAME"; exit 1; }
|
||||
[ -w "/mnt/$DISK_FILENAME" ] || { echo "Tape /mnt/$DISK_FILENAME is not writable"; exit 1; }
|
||||
|
||||
echo -n "Checking for disk... "
|
||||
if [ -f "/mnt/$DISK_FILENAME" ]; then
|
||||
[ -w "/mnt/$DISK_FILENAME" ] || { echo "Disk /mnt/$DISK_FILENAME exists and is not writable"; exit 1; }
|
||||
echo "Disk found and is writable."
|
||||
else
|
||||
[ -w "/mnt/" ] || { echo "Disk /mnt/$DISK_FILENAME not found and /mnt not writable"; exit 1; }
|
||||
[ -f "/rq0.dsk.gz" ] || { echo "Disk /mnt/$DISK_FILENAME not found and image was not built with a default disk"; exit 1; }
|
||||
echo "Disk not found."
|
||||
echo "Extracting default disk image..."
|
||||
gzip -cd /rq0.dsk.gz > "/mnt/$DISK_FILENAME" || { echo "Failed to extract default disk image to /mnt/$DISK_FILENAME"; exit 1; }
|
||||
fi
|
||||
|
||||
# Start CoreDNS as soon as possible after validations done
|
||||
echo "Starting CoreDNS..."
|
||||
[ -z "$COREDNS_DEBUG" ] && COREDNS_QUIET="-quiet"
|
||||
coredns "$COREDNS_QUIET" -conf /Corefile &
|
||||
|
||||
# Set exit command only if NOEXIT not set
|
||||
[ -z "$NOEXIT" ] && EXIT_CMD="exit" || EXIT_CMD=""
|
||||
|
||||
echo "Configuring simh..."
|
||||
sed -e "s/<DISK_FILENAME>/${DISK_FILENAME}/" \
|
||||
-e "s/<EXIT>/${EXIT_CMD}/" /boot.ini.template > /boot.ini
|
||||
|
||||
cidr=28
|
||||
hostip=1.3.3.1
|
||||
pdpip=1.3.3.7
|
||||
echo "Configuring networking..."
|
||||
[ -z "$CIDR" ] && CIDR=28
|
||||
[ -z "$HOSTIP" ] && HOSTIP=1.3.3.1
|
||||
[ -z "$PDPIP" ] && PDPIP=1.3.3.7
|
||||
|
||||
ip tuntap add pdp mode tap
|
||||
ip link set pdp up
|
||||
ip addr add "${hostip}/${cidr}" dev pdp
|
||||
iptables -t nat -A PREROUTING ! -i pdp -p tcp --dport 4000 -j ACCEPT
|
||||
iptables -t nat -A PREROUTING ! -i pdp -j DNAT --to-destination 1.3.3.7
|
||||
ip addr add "${HOSTIP}/${CIDR}" dev pdp
|
||||
iptables -t nat -A PREROUTING ! -i pdp -p tcp --dport 4000 -j ACCEPT # dz serial device
|
||||
iptables -t nat -A PREROUTING ! -i pdp -j DNAT --to-destination "$PDPIP"
|
||||
iptables -t nat -A POSTROUTING ! -o pdp -j MASQUERADE
|
||||
|
||||
echo "Booting PDP-11..."
|
||||
pdp11 /boot.ini
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue