-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
36 lines (30 loc) · 1.31 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
32
33
34
35
36
# syntax=docker/dockerfile:1
FROM debian:stable-slim
ARG CONFIG_PATH
ARG TFTP_HOST_IP
ARG TFTP_NETWORK
COPY dnsmasq.conf.tpl grub.cfg.tpl boot.cfg.tpl "$CONFIG_PATH"/
# Install and configure grub
RUN \
# Install Grub Tools and dnsmasq
apt-get update && apt-get install -y \
grub-pc-bin \
dnsmasq \
# Remove apt cache
&& rm -rf /var/lib/apt/lists/* \
# Replace variables in boot.cfg file
&& sed -e "s/\${TFTP_HOST_IP}/$TFTP_HOST_IP/" "$CONFIG_PATH"/boot.cfg.tpl > "$CONFIG_PATH"/boot.cfg \
# Create tftp directory structure
&& grub-mknetdir --net-directory=/tftp --subdir=/boot/grub -d /usr/lib/grub/i386-pc \
# Rebuild Grub core image with embedded config
&& grub-mkimage -O i386-pc-pxe -o /tftp/boot/grub/i386-pc/core.0 --config=$CONFIG_PATH/boot.cfg -p '(tftp,$TFTP_HOST_IP)/boot/grub' pxe tftp \
# Replace variables in dnsmasq and grub config files
&& sed -e "s/\${TFTP_NETWORK}/$TFTP_NETWORK/" -e "s/\${TFTP_HOST_IP}/$TFTP_HOST_IP/" "$CONFIG_PATH"/dnsmasq.conf.tpl > /etc/dnsmasq.conf \
&& sed -e "s/\${TFTP_HOST_IP}/$TFTP_HOST_IP/" "$CONFIG_PATH"/grub.cfg.tpl > /tftp/boot/grub/grub.cfg
# Copy images to tftp dir
COPY vmlinuz* initrd* memtest* /tftp/boot/
#COPY memtest* /tftp/boot/
#####
EXPOSE 67/udp
EXPOSE 68/udp
ENTRYPOINT ["dnsmasq", "-k", "--log-facility=-"]