-
Notifications
You must be signed in to change notification settings - Fork 74
/
Dockerfile
31 lines (31 loc) · 1.55 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
FROM stackbrew/debian:jessie
ENV ARCH amd64
ENV DIST stretch
ENV MIRROR http://ftp.nl.debian.org
RUN apt-get -q update
RUN apt-get -qy install dnsmasq wget iptables
RUN wget --no-check-certificate https://raw.github.com/jpetazzo/pipework/master/pipework
RUN chmod +x pipework
RUN mkdir /tftp
WORKDIR /tftp
RUN wget $MIRROR/debian/dists/$DIST/main/installer-$ARCH/current/images/netboot/debian-installer/$ARCH/linux
RUN wget $MIRROR/debian/dists/$DIST/main/installer-$ARCH/current/images/netboot/debian-installer/$ARCH/initrd.gz
RUN wget $MIRROR/debian/dists/$DIST/main/installer-$ARCH/current/images/netboot/debian-installer/$ARCH/pxelinux.0
RUN mkdir pxelinux.cfg
RUN printf "DEFAULT linux\nLABEL linux\nKERNEL linux\nAPPEND initrd=initrd.gz\n" >pxelinux.cfg/default
CMD \
echo Setting up iptables... &&\
iptables -t nat -A POSTROUTING -j MASQUERADE &&\
echo Waiting for pipework to give us the eth1 interface... &&\
/pipework --wait &&\
myIP=$(ip addr show dev eth1 | awk -F '[ /]+' '/global/ {print $3}') &&\
mySUBNET=$(echo $myIP | cut -d '.' -f 1,2,3) &&\
echo Starting DHCP+TFTP server...&&\
dnsmasq --interface=eth1 \
--dhcp-range=$mySUBNET.101,$mySUBNET.199,255.255.255.0,1h \
--dhcp-boot=pxelinux.0,pxeserver,$myIP \
--pxe-service=x86PC,"Install Linux",pxelinux \
--enable-tftp --tftp-root=/tftp/ --no-daemon
# Let's be honest: I don't know if the --pxe-service option is necessary.
# The iPXE loader in QEMU boots without it. But I know how some PXE ROMs
# can be picky, so I decided to leave it, since it shouldn't hurt.