Skip to content

Commit fb808a3

Browse files
committed
Refactor of next-server
1 parent 0e7c3bd commit fb808a3

File tree

5 files changed

+123
-14
lines changed

5 files changed

+123
-14
lines changed

Dockerfile

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,40 @@
11
FROM alpine:3.21
22

3-
RUN mkdir -p /tftpboot; \
4-
apk --update add --no-cache tftp-hpa busybox
3+
# Install necessary packages and create directories
4+
RUN mkdir -p /httpboot/ipxe && \
5+
apk --update add --no-cache tftp-hpa busybox nginx envsubst && \
6+
# Download boot files
7+
wget -P /httpboot https://boot.ipxe.org/ipxe.efi && \
8+
wget -P /httpboot https://boot.ipxe.org/ipxe.pxe && \
9+
wget -P /httpboot https://boot.ipxe.org/undionly.kpxe && \
10+
wget -P /httpboot https://boot.ipxe.org/snponly.efi && \
11+
wget -P /httpboot https://github.com/ipxe/wimboot/releases/latest/download/wimboot && \
12+
wget -P /httpboot https://boot.netboot.xyz/ipxe/netboot.xyz.kpxe && \
13+
wget -P /httpboot https://boot.netboot.xyz/ipxe/netboot.xyz-undionly.kpxe && \
14+
wget -P /httpboot https://boot.netboot.xyz/ipxe/netboot.xyz.efi && \
15+
wget -P /httpboot https://boot.netboot.xyz/ipxe/netboot.xyz-snp.efi && \
16+
wget -P /httpboot https://boot.netboot.xyz/ipxe/netboot.xyz-snponly.efi && \
17+
wget -P /httpboot https://boot.netboot.xyz/ipxe/netboot.xyz-arm64.efi && \
18+
wget -P /httpboot https://boot.netboot.xyz/ipxe/netboot.xyz-arm64-snp.efi && \
19+
wget -P /httpboot https://boot.netboot.xyz/ipxe/netboot.xyz-arm64-snponly.efi && \
20+
# Set permissions
21+
find /httpboot -type f -exec chmod 0444 {} +
522

23+
# Set default environment variables for ports
24+
ENV TFTP_PORT=69
25+
ENV HTTP_PORT=80
26+
27+
# Expose ports
628
EXPOSE 69/udp
29+
EXPOSE 80
730

8-
ADD https://boot.netboot.xyz/ipxe/netboot.xyz.kpxe /tftpboot/
9-
ADD https://boot.netboot.xyz/ipxe/netboot.xyz-undionly.kpxe /tftpboot/
10-
ADD https://boot.netboot.xyz/ipxe/netboot.xyz.efi /tftpboot/
11-
ADD https://boot.netboot.xyz/ipxe/netboot.xyz-snp.efi /tftpboot/
12-
ADD https://boot.netboot.xyz/ipxe/netboot.xyz-snponly.efi /tftpboot/
13-
ADD https://boot.netboot.xyz/ipxe/netboot.xyz-arm64.efi /tftpboot/
14-
ADD https://boot.netboot.xyz/ipxe/netboot.xyz-arm64-snp.efi /tftpboot/
15-
ADD https://boot.netboot.xyz/ipxe/netboot.xyz-arm64-snponly.efi /tftpboot/
16-
ADD https://boot.netboot.xyz/ipxe/netboot.xyz-rpi4-snp.efi /tftpboot/
31+
# Copy scripts and configuration files
32+
COPY entrypoint.sh /entrypoint.sh
33+
COPY generate_index.sh /generate_index.sh
34+
COPY nginx.conf /etc/nginx/nginx.conf
1735

18-
RUN find /tftpboot -type f -exec chmod 0444 {} +
36+
# Make scripts executable
37+
RUN chmod +x /entrypoint.sh /generate_index.sh
1938

20-
ENTRYPOINT ["sh", "-c"]
21-
CMD ["busybox syslogd -n -O /dev/stdout & in.tftpd -Lvvv --secure -u nobody /tftpboot"]
39+
# Set entrypoint
40+
ENTRYPOINT ["/entrypoint.sh"]

entrypoint.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/sh
2+
3+
# Print ASCII logo to logs
4+
echo "Loading netboot.xyz next-server container..."
5+
echo
6+
echo " _ _ _ "
7+
echo " _ __ ___| |_| |__ ___ ___ | |_ __ ___ _ ____ "
8+
echo "| '_ \ / _ \ __| '_ \ / _ \ / _ \| __| \ \/ / | | |_ / "
9+
echo "| | | | __/ |_| |_) | (_) | (_) | |_ _ > <| |_| |/ / "
10+
echo "|_| |_|\___|\__|_.__/ \___/ \___/ \__(_)_/\_\\__, /___| "
11+
echo " |___/ "
12+
echo
13+
echo "If you enjoy netboot.xyz projects, please support us at:"
14+
echo
15+
echo "https://opencollective.com/netbootxyz"
16+
echo "https://github.com/sponsors/netbootxyz"
17+
echo
18+
echo Source: https://github.com/netbootxyz/docker-next-server
19+
echo
20+
21+
# Generate index.html
22+
./generate_index.sh
23+
24+
# Start syslog
25+
busybox syslogd -n -O /dev/stdout &
26+
27+
# Start TFTP server with logging to stdout
28+
in.tftpd -Lvvv --address :${TFTP_PORT} --ipv4 --secure -u nobody /httpboot 2>&1 &
29+
30+
# Replace environment variables in nginx configuration
31+
HTTP_PORT=${HTTP_PORT:-80}
32+
export HTTP_PORT
33+
envsubst '${HTTP_PORT}' < /etc/nginx/nginx.conf > /etc/nginx/nginx.conf.tmp && mv /etc/nginx/nginx.conf.tmp /etc/nginx/nginx.conf
34+
35+
# Start nginx
36+
nginx -g 'daemon off;'

generate_index.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/sh
2+
3+
# Generate index.html with ASCII logo and support message
4+
echo "<pre>" > /httpboot/index.html
5+
echo " " >> /httpboot/index.html
6+
echo " _ _ _ " >> /httpboot/index.html
7+
echo " _ __ ___| |_| |__ ___ ___ | |_ __ ___ _ ____ " >> /httpboot/index.html
8+
echo "| '_ \ / _ \ __| '_ \ / _ \ / _ \| __| \ \/ / | | |_ / " >> /httpboot/index.html
9+
echo "| | | | __/ |_| |_) | (_) | (_) | |_ _ > <| |_| |/ / " >> /httpboot/index.html
10+
echo "|_| |_|\___|\__|_.__/ \___/ \___/ \__(_)_/\_\\__, /___| " >> /httpboot/index.html
11+
echo " |___/ " >> /httpboot/index.html
12+
echo "</pre>" >> /httpboot/index.html
13+
echo
14+
echo "<p>This directory listing contains both latest netboot.xyz binaries and upstream iPXE files.</p>" >> /httpboot/index.html
15+
echo "<ul>" >> /httpboot/index.html
16+
for file in /httpboot/*; do
17+
filename=$(basename "$file")
18+
echo "<li><a href=\"$filename\">$filename</a></li>" >> /httpboot/index.html
19+
done
20+
echo "</ul>" >> /httpboot/index.html
21+
echo "If you enjoy netboot.xyz projects, please support us at:<br>" >> /httpboot/index.html
22+
echo "<a href=\"https://opencollective.com/netbootxyz\">Open Collective</a><br>" >> /httpboot/index.html
23+
echo "<a href=\"https://github.com/sponsors/netbootxyz\">GitHub Sponsors</a>" >> /httpboot/index.html
24+
echo "</body></html>" >> /httpboot/index.html

go.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
docker rm -f next-server-dev
3+
docker rmi -f next-server-dev
4+
docker build . -t next-server-dev
5+
docker run -d -it --name=next-server-dev --restart=always -p 69:69/udp -p 8080:80 next-server-dev

nginx.conf

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
events {}
2+
3+
http {
4+
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
5+
'$status $body_bytes_sent "$http_referer" '
6+
'"$http_user_agent" "$http_x_forwarded_for"';
7+
8+
access_log /dev/stdout main;
9+
error_log /dev/stderr;
10+
11+
server {
12+
listen ${HTTP_PORT};
13+
server_name localhost;
14+
15+
location / {
16+
root /httpboot;
17+
autoindex on;
18+
}
19+
20+
location /ipxe/ {
21+
root /httpboot;
22+
autoindex on;
23+
}
24+
}
25+
}

0 commit comments

Comments
 (0)