Introduce fickit-deploy image

This commit is contained in:
nemunaire 2023-07-25 06:42:42 +02:00
parent 3e5e8c9ba4
commit 4fb0c11736
7 changed files with 229 additions and 15 deletions

View File

@ -0,0 +1,22 @@
image: nemunaire/fickit-deploy:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}latest{{/if}}
{{#if build.tags}}
tags:
{{#each build.tags}}
- {{this}}
{{/each}}
{{/if}}
manifests:
- image: nemunaire/fickit-deploy:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-amd64
platform:
architecture: amd64
os: linux
- image: nemunaire/fickit-deploy:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm64
platform:
architecture: arm64
os: linux
variant: v8
- image: nemunaire/fickit-deploy:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm
platform:
architecture: arm
os: linux
variant: v7

View File

@ -326,6 +326,21 @@ steps:
branch:
- master
- name: docker fickit-deploy
image: plugins/docker
settings:
username:
from_secret: docker_username
password:
from_secret: docker_password
repo: nemunaire/fickit-deploy
auto_tag: true
auto_tag_suffix: ${DRONE_STAGE_OS}-${DRONE_STAGE_ARCH}
dockerfile: Dockerfile-deploy
when:
branch:
- master
trigger:
event:
- cron
@ -726,6 +741,17 @@ steps:
password:
from_secret: docker_password
- name: publish fickit-deploy
image: plugins/manifest
settings:
auto_tag: true
ignore_missing: true
spec: .drone-manifest-fickit-deploy.yml
username:
from_secret: docker_username
password:
from_secret: docker_password
trigger:
event:
- push

21
Dockerfile-deploy Normal file
View File

@ -0,0 +1,21 @@
FROM alpine:3.18
EXPOSE 67/udp
EXPOSE 69/udp
EXPOSE 80/tcp
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisord.conf"]
WORKDIR /srv
RUN apk add --no-cache \
busybox-extras \
supervisor \
syslinux \
tftp-hpa
RUN touch /var/lib/udhcpd/udhcpd.leases
COPY configs/deploy-supervisord.conf /etc/supervisord.conf
COPY configs/udhcpd-sample.conf /etc/udhcpd.conf
COPY configs/pxelinux.cfg /usr/share/syslinux/pxelinux.cfg/default

View File

@ -0,0 +1,24 @@
[supervisord]
nodaemon = true
silent = true
[program:httpd]
command = /usr/sbin/httpd -f -vv -h /srv
stdout_logfile = /dev/stdout
stdout_logfile_maxbytes = 0
stderr_logfile = /dev/stderr
stderr_logfile_maxbytes = 0
[program:tftpd]
command = /usr/sbin/in.tftpd -R 4096:32767 -v -s /usr/share/syslinux/
stdout_logfile = /dev/stdout
stdout_logfile_maxbytes = 0
stderr_logfile = /dev/stderr
stderr_logfile_maxbytes = 0
[program:udhcpd]
command = /usr/sbin/udhcpd -f
stdout_logfile = /dev/stdout
stdout_logfile_maxbytes = 0
stderr_logfile = /dev/stderr
stderr_logfile_maxbytes = 0

35
configs/pxelinux.cfg Normal file
View File

@ -0,0 +1,35 @@
TIMEOUT 30
ONTIMEOUT update
MENU background #00000000 * *
MENU color title * #FF22BBCC *
MENU color sel * #FFFFFFFF #FF22BBCC *
MENU color hotsel 1;7;37;40 #ffffffff #76a1d0ff *
UI vesamenu.c32
MENU TITLE FICKIT PXE BOOT
LABEL backend
MENU LABEL Prepare for ^backend
LINUX /fickit-prepare-kernel
INITRD /fickit-prepare-initrd.img
APPEND console=tty0 fickit.autoprepare=backend
LABEL frontend
MENU LABEL Prepare for ^frontend
LINUX /fickit-kernel
INITRD /fickit-boot-initrd.img
APPEND console=tty0 fickit.autoprepare=frontend
LABEL prepare
MENU LABEL Prepare with ^shell
LINUX /fickit-kernel
INITRD /fickit-boot-initrd.img
APPEND console=tty0
LABEL update
MENU LABEL ^Update images
LINUX /fickit-kernel
INITRD /fickit-update-initrd.img
APPEND console=ttyS0 console=tty0
MENU SEPARATOR
LABEL poweroff
MENU LABEL ^Shutdown
KERNEL poweroff.c32

View File

@ -0,0 +1,59 @@
# Sample udhcpd configuration file (/etc/udhcpd.conf)
# Values shown are defaults
# The start and end of the IP lease block
start 192.168.255.100
end 192.168.255.200
# The interface that udhcpd will use
interface eth0
# The maximum number of leases (includes addresses reserved
# by OFFER's, DECLINE's, and ARP conflicts). Will be corrected
# if it's bigger than IP lease block, but it ok to make it
# smaller than lease block.
max_leases 100
# The amount of time that an IP will be reserved (leased to nobody)
# if a DHCP decline message is received (seconds)
#decline_time 3600
# The amount of time that an IP will be reserved
# if an ARP conflict occurs (seconds)
#conflict_time 3600
# How long an offered address is reserved (seconds)
#offer_time 60
# If client asks for lease below this value, it will be rounded up
# to this value (seconds)
#min_lease 60
# The location of the pid file
#pidfile /var/run/udhcpd.pid
# The location of the leases file
#lease_file /var/lib/misc/udhcpd.leases
# The following are BOOTP specific options
# next server to use in bootstrap
siaddr 192.168.255.2 # default: 0.0.0.0 (none)
# tftp server name
#sname zorak # default: none
# tftp file to download (e.g. kernel image)
boot_file pxelinux.0 # default: none
# NOTE: "boot_file FILE" and "opt bootfile FILE" are conceptually the same,
# but "boot_file" goes into BOOTP-defined fixed-size field in the packet,
# whereas "opt bootfile" goes into DHCP option 0x43.
# Same for "sname HOST" and "opt tftp HOST".
# The remainder of options are DHCP options and can be specified with the
# keyword 'opt' or 'option'. If an option can take multiple items, such
# as the dns option, they can be listed on the same line, or multiple
# lines.
# Examples:
#opt dns 192.168.10.2 192.168.10.10
option subnet 255.255.255.0
opt router 192.168.255.2
option lease 3600

View File

@ -53,30 +53,57 @@ files:
ip link set eth0 up
udhcpc -i eth0
# /proc/cmdline parser (from Gentoo Wiki)
cmdline() {
local value
value=" $(cat /proc/cmdline) "
value="${value##* $1=}"
value="${value%% *}"
[ "$value" != "" ] && echo "$value"
}
# Retrieve metadata
wget -O /tmp/metadata.iso "$(ip r | grep default | awk '{ print $3 }')/fickit-metadata.iso"
mount /tmp/metadata.iso /mnt
/usr/bin/metadata -v file=/mnt/user-data
# Try to detect backend/frontend setup
if ip l | grep eth3 > /dev/null
AUTOPREPARE=$(cmdline fickit.autoprepare)
if [ -z "${AUTOPREPARE}" ]
then
# Try to detect backend/frontend setup
if ip l | grep -q eth3
then
DEFAULT_BOOT=1
echo -n "Detected: FRONTEND host "
else
DEFAULT_BOOT=0
echo -n "Detected: BACKEND host "
fi
[ "${RAID}" -eq 1 ] && echo "with RAID setup" || echo "without raid"
echo
read -p "Proceed? (y/N/Front/Back) " V
if [ "$V" == "F" ] || [ "$V" == "f" ]; then
DEFAULT_BOOT=1
elif [ "$V" == "B" ] || [ "$V" == "b" ]; then
DEFAULT_BOOT=0
elif [ "$V" != "y" ]; then
while true; do
/bin/ash
done
fi
elif [ "${AUTOPREPARE}" == "backend" ]
then
DEFAULT_BOOT=1
echo -n "Detected: FRONTEND host "
elif [ "${AUTOPREPARE}" == "frontend" ]
then
DEFAULT_BOOT=0
else
DEFAULT_BOOT=0
echo -n "Detected: BACKEND host "
fi
echo
echo "Invalid fickit.autoprepare value: got $AUTOPREPARE, expected frontend or backend."
echo
[ "${RAID}" -eq 1 ] && echo "with RAID setup" || echo "without raid"
echo
read -p "Proceed? (y/N/Front/Back) " V
if [ "$V" == "F" ] || [ "$V" == "f" ]; then
DEFAULT_BOOT=1
elif [ "$V" == "B" ] || [ "$V" == "b" ]; then
DEFAULT_BOOT=0
elif [ "$V" != "y" ]; then
while true; do
/bin/ash
done