forked from kalaksi/docker-tftpd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
46 lines (38 loc) · 2.2 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
37
38
39
40
41
42
43
44
45
46
# Copyright (c) 2018 [email protected].
# This work is licensed under the terms of the MIT license. For a copy, see <https://opensource.org/licenses/MIT>.
FROM alpine:3.18.4
ENV TFTPD_BIND_ADDRESS="0.0.0.0:1069"
ENV TFTPD_EXTRA_ARGS=""
# Package will be downloaded manually since armhf has no package for syslinux (#1).
ARG SYSLINUX_PACKAGE="https://dl-cdn.alpinelinux.org/alpine/v3.17/main/x86_64/syslinux-6.04_pre1-r11.apk"
RUN apk add --no-cache tftp-hpa
# Help setting up the basic pxelinux environment.
RUN mkdir /tmp/syslinux && \
wget "$SYSLINUX_PACKAGE" -O /tmp/syslinux/syslinux.apk && \
tar -C /tmp/syslinux -xvf /tmp/syslinux/syslinux.apk && \
mkdir -p -m 0755 /tftpboot && \
cp -r /tmp/syslinux/usr/share/syslinux /tftpboot && \
rm -rf /tmp/syslinux && \
find /tftpboot -type f -exec chmod 444 {} \; && \
find /tftpboot -mindepth 1 -type d -exec chmod 555 {} \; && \
# Not all systems use pxelinux for PXE (e.g. u-boot). Therefore, the actual directories are
# placed in the tftp root and symlinks are provided for the syslinux environment.
ln -s ../boot /tftpboot/syslinux/boot && \
ln -s ../pxelinux.cfg /tftpboot/syslinux/pxelinux.cfg && \
# EFI alternatives. These will point to the symlinks above.
ln -s ../boot /tftpboot/syslinux/efi64/boot && \
ln -s ../pxelinux.cfg /tftpboot/syslinux/efi64/pxelinux.cfg
# Default configuration that can be overridden
COPY pxelinux.cfg /tftpboot/pxelinux.cfg
EXPOSE 1069/udp
# User-provided boot items, e.g. kernels
VOLUME /tftpboot/boot
# The daemon doesn't seem to work if container is not run as root, but it still drops the root
# privileges with the -u option.
# Note that the main process still runs as root, but files are being served as non-root.
CMD set -eu ;\
# Some devices such as the Raspberry Pi 4 expect files to be available directly in the TFTP root,
# so use a boot directory with the special name "root" to have it's contents copied to the TFTP root directory.
# See README for an example file structure for RPi.
[ -d /tftpboot/boot/root ] && cp -af /tftpboot/boot/root/* /tftpboot ;\
exec in.tftpd -L -vvv -u ftp --secure --address "$TFTPD_BIND_ADDRESS" $TFTPD_EXTRA_ARGS /tftpboot