server/fickit-backend.yml
Renovate Bot 40b9c713dc
Some checks are pending
continuous-integration/drone/push Build is running
chore(deps): update alpine docker tag to v3.20
2024-05-24 12:54:35 +00:00

570 lines
19 KiB
YAML

kernel:
#image: nemunaire/kernel:5.10.62-0b705d955f5e283f62583c4e227d64a7924c138f-amd64
image: linuxkit/kernel:6.6.13
cmdline: "console=ttyS0 console=tty0"
init:
- linuxkit/init:v1.0.0
- linuxkit/runc:6062483d748609d505f2bcde4e52ee64a3329f5f
- linuxkit/containerd:v1.0.0
- linuxkit/ca-certificates:v1.0.0
- linuxkit/getty:v1.0.0
- nemunaire/mdadm:04814350d71ba9417e1f861be1685de26adf7a67
- nemunaire/kexec:839b4eedfce02a56c581dec2383dc6faff120855
onboot:
- name: mod
image: linuxkit/modprobe:v1.0.0
command: ["/bin/sh", "-c", "modprobe xhci_pci ahci intel_lpss_pci i2c_i801 megaraid_sas tg3 bnxt_en"]
- name: sysctl
image: linuxkit/sysctl:v1.0.0
binds:
- /etc/sysctl.d/01-fic.conf:/etc/sysctl.d/01-fic.conf:ro
# Metadata
- name: metadata
image: linuxkit/metadata:v1.0.0
command: ["/usr/bin/metadata", "-v", "cdrom"]
# Filesystem
- name: swap
image: linuxkit/swap:v1.0.0
command: ["/sbin/swapon", "/dev/sda3"]
- name: dm-crypt
image: linuxkit/dm-crypt:d49723bc9d10c5ada9e03b0670f4e57416d5d084
command: ["/usr/bin/crypto", "-l", "crypt_fic", "/dev/sda4"]
binds:
- /dev:/dev
- /run/config/dm-crypt:/etc/dm-crypt
- name: mount
image: linuxkit/mount:v1.0.0
command: ["/usr/bin/mountie", "-device", "/dev/mapper/crypt_fic", "/var/lib/fic" ]
# Network
# - name: dhcpcd
# image: linuxkit/dhcpcd:v1.0.0
# command: ["/sbin/dhcpcd", "--nobackground", "-f", "/dhcpcd.conf", "-1"]
# - name: ntp
# image: linuxkit/openntpd:v1.0.0
- name: synchro-ip-setup
image: linuxkit/ip:v1.0.0
command: ["/bin/sh", "-c", "ip a add 10.10.10.1/29 dev eth2; ip link set eth2 up;" ]
net: new
runtime:
interfaces:
- name: eth2
bindNS:
net: /run/netns/synchro
- name: qa-ip-setup
image: linuxkit/ip:v1.0.0
command: ["/bin/sh", "-c", "ip link show eth1 2> /dev/null && { ip a add 10.10.10.1/29 dev eth1; ip link set eth1 up; }; ip a add 172.17.0.6/24 dev vethin-qa; ip link set vethin-qa up" ]
net: new
runtime:
interfaces:
# - name: eth1 # for QA
- name: vethin-qa
add: veth
peer: veth-qa
bindNS:
net: /run/netns/fic-qa
- name: admin-ip-setup
image: linuxkit/ip:v1.0.0
#command: ["/bin/sh", "-c", "ip link add link eth3 name adminiface type vlan id 99; ip a add 172.16.99.219/24 dev adminiface; ip link set eth3 up; ip link set adminiface up; ip r add default via 172.16.99.1; ip a add 172.17.0.2/24 dev vethin-admin; ip link set vethin-admin up; ping -W 10 -c 1 172.16.99.1;" ]
command: ["/bin/sh", "-c", "ip link set eth3 up; while read IP; do ip a add ${IP} dev eth3; done < /run/config/ip_config/backend-admin; ip r add default via $(cat /run/config/ip_config/backend-router); ip a add 172.17.0.2/24 dev vethin-admin; ip link set vethin-admin up; echo 'Waiting for' $(cat /run/config/ip_config/backend-router); ping -W 10 -c 1 $(cat /run/config/ip_config/backend-router); ip link show eth1 2> /dev/null && { ip a add 10.0.0.1/24 dev eth1; ip link set eth1 up; };" ]
net: new
binds:
- /run/config/ip_config/:/run/config/ip_config/:ro
runtime:
interfaces:
- name: eth1 #iDRAC
- name: eth3
- name: vethin-admin
add: veth
peer: veth-admin
bindNS:
net: /run/netns/fic-admin
- name: checker-ip-setup
image: linuxkit/ip:v1.0.0
command: ["/bin/sh", "-c", "ip a add 172.17.0.3/24 dev vethin-checker; ip link set vethin-checker up;" ]
net: new
runtime:
interfaces:
- name: vethin-checker
add: veth
peer: veth-checker
bindNS:
net: /run/netns/fic-checker
- name: generator-ip-setup
image: linuxkit/ip:v1.0.0
command: ["/bin/sh", "-c", "ip a add 172.17.0.5/24 dev vethin-generat; ip link set vethin-generat up;" ]
net: new
runtime:
interfaces:
- name: vethin-generat
add: veth
peer: veth-generator
bindNS:
net: /run/netns/fic-generator
- name: mysql-ip-setup
image: linuxkit/ip:v1.0.0
command: ["/bin/sh", "-c", "ip a add 172.17.0.4/24 dev vethin-db; ip link set vethin-db up;" ]
net: new
runtime:
interfaces:
- name: vethin-db
add: veth
peer: veth-db
bindNS:
net: /run/netns/db
- name: bridge-setup
image: linuxkit/ip:v1.0.0
command: ["/bin/sh", "-c", "ip a add 172.17.0.1/24 dev br0; ip link set veth-admin master br0; ip link set veth-checker master br0; ip link set veth-generator master br0; ip link set veth-db master br0; ip link set veth-qa master br0; ip link set br0 up; ip link set veth-admin up; ip link set veth-checker up; ip link set veth-generator up; ip link set veth-db up; ip link set veth-qa up;" ]
runtime:
interfaces:
- name: br0
add: bridge
- name: firewall-synchro
image: linuxkit/ip:v1.0.0
command: ["/bin/bash", "-c", "/sbin/iptables-restore < /etc/iptables/rules-synchro.v4; /sbin/ip6tables-restore < /etc/iptables/rules.v6" ]
binds:
- /etc/iptables/rules-synchro.v4:/etc/iptables/rules-synchro.v4:ro
- /etc/iptables/rules.v6:/etc/iptables/rules.v6:ro
net: /run/netns/synchro
runtime:
mkdir:
- /var/lib/fic/teams
- name: firewall-admin
image: linuxkit/ip:v1.0.0
command: ["/bin/bash", "-c", "/sbin/iptables-restore < /etc/iptables/rules-admin.v4; /sbin/ip6tables-restore < /etc/iptables/rules.v6" ]
binds:
- /etc/iptables/rules-admin.v4:/etc/iptables/rules-admin.v4:ro
- /etc/iptables/rules.v6:/etc/iptables/rules.v6:ro
net: /run/netns/fic-admin
- name: create-secrets
image: alpine:3.20
command: ["/bin/init_secrets.sh"]
binds:
- /bin/init_secrets.sh:/bin/init_secrets.sh:ro
- /var/lib/fic/secrets:/var/lib/fic/secrets
runtime:
mkdir:
- /var/lib/fic/secrets
services:
# - name: getty
# image: linuxkit/getty:v1.0.0
# env:
# - INSECURE=true
# Enable acpi to shutdown on power events
- name: acpid
image: linuxkit/acpid:v1.0.0
- name: rngd
image: linuxkit/rngd:v1.0.0
- name: db
image: mariadb:11
command: ["/bin/bash", "/usr/local/bin/docker-entrypoint.sh", "mariadbd"]
capabilities:
- CAP_CHOWN
- CAP_SETUID
- CAP_SETGID
- CAP_DAC_OVERRIDE
env:
- MYSQL_DATABASE=fic
- MYSQL_USER=fic
- MYSQL_PASSWORD_FILE=/run/secrets/mysql_password
- MYSQL_RANDOM_ROOT_PASSWORD=yes
binds:
- /etc/hosts:/etc/hosts:ro
- /etc/mysql/conf.d:/etc/mysql/conf.d:ro
- /var/lib/fic/mysql:/var/lib/mysql
- /var/lib/fic/secrets/mysql_password:/run/secrets/mysql_password:ro
net: /run/netns/db
pid: new
ipc: new
uts: new
runtime:
mkdir:
- /var/lib/fic/mysql
- name: db-backup
image: nemunaire/mariadb-client:a77db996e46335c35c74ba8dbef3c65286386c6d
command: ["/bin/sh", "/root/mysql_backup.sh"]
env:
- MYSQL_HOST=db
- MYSQL_DATABASE=fic
- MYSQL_USER=fic
- MYSQL_PASSWORD_FILE=/run/secrets/mysql_password
binds:
- /etc/hosts:/etc/hosts:ro
- /root/mysql_backup.sh:/root/mysql_backup.sh:ro
- /var/lib/fic/backups/:/var/lib/fic/backups/
- /var/lib/fic/secrets/mysql_password:/run/secrets/mysql_password:ro
net: /run/netns/db
runtime:
mkdir:
- /var/lib/fic/backups
- name: fic-admin
image: nemunaire/fic-admin:latest
command: ["/srv/admin", "-4real", "-bind=127.0.0.1:8081", "-baseurl=/admin/", "-localimport=/mnt/fic", "-timestampCheck=/srv/submissions", "-git-import-remote=git@gitlab.cri.epita.fr:ing/majeures/srs/fic/2024/challenges.git"]
env:
- PATH=/usr/sbin:/usr/bin:/sbin:/bin
- MYSQL_HOST=db
- MYSQL_PASSWORD_FILE=/run/secrets/mysql_password
- FICCA_PASS_FILE=/run/secrets/fic_ca_pass
- FICOIDC_ISSUER_FILE=/run/config/ip_config/domain
- FICOIDC_SECRET_FILE=/run/secrets/fic_oidc_secret
binds:
- /etc/hosts:/etc/hosts:ro
- /run/config/ip_config/domain:/run/config/ip_config/domain:ro
- /var/lib/fic/secrets/fic_ca_pass:/run/secrets/fic_ca_pass:ro
- /var/lib/fic/secrets/fic_oidc_secret:/run/secrets/fic_oidc_secret:ro
- /var/lib/fic/secrets/mysql_password:/run/secrets/mysql_password:ro
- /var/lib/fic/raw_files:/mnt/fic
- /var/lib/fic/dashboard:/srv/DASHBOARD
- /var/lib/fic/files:/srv/FILES
- /var/lib/fic/generator:/srv/GENERATOR:ro
- /var/lib/fic/pki:/srv/PKI
- /var/lib/fic/settings:/srv/SETTINGS
- /var/lib/fic/submissions:/srv/submissions:ro
- /var/lib/fic/sync:/srv/SYNC
- /var/lib/fic/teams:/srv/TEAMS
net: /run/netns/fic-admin
pid: new
ipc: new
uts: new
runtime:
mkdir:
- /var/lib/fic/dashboard
- /var/lib/fic/files
- /var/lib/fic/generator
- /var/lib/fic/raw_files
- /var/lib/fic/pki
- /var/lib/fic/settings
- /var/lib/fic/submissions
- /var/lib/fic/sync
- /var/lib/fic/teams
- name: fic-evdist
image: nemunaire/fic-evdist:latest
binds:
- /etc/hosts:/etc/hosts:ro
- /var/lib/fic/dashboard:/srv/DASHBOARD
- /var/lib/fic/settings:/srv/SETTINGS
- /var/lib/fic/settingsdist:/srv/SETTINGSDIST
net: new
pid: new
ipc: new
uts: new
runtime:
mkdir:
- /var/lib/fic/settings
- /var/lib/fic/settingsdist
- name: fic-checker
image: nemunaire/fic-checker:latest
env:
- MYSQL_HOST=db
- MYSQL_PASSWORD_FILE=/run/secrets/mysql_password
binds:
- /etc/hosts:/etc/hosts:ro
- /var/lib/fic/generator:/srv/GENERATOR:ro
- /var/lib/fic/teams:/srv/TEAMS:ro
- /var/lib/fic/secrets/mysql_password:/run/secrets/mysql_password:ro
- /var/lib/fic/settingsdist:/srv/SETTINGSDIST:ro
- /var/lib/fic/submissions:/srv/submissions
net: /run/netns/fic-checker
pid: new
ipc: new
uts: new
runtime:
mkdir:
- /var/lib/fic/generator
- /var/lib/fic/settingsdist
- /var/lib/fic/submissions
- /var/lib/fic/teams
- name: fic-dashboard
image: nemunaire/fic-dashboard:latest
command: ["/srv/dashboard", "-bind=:8082", "-restrict-to-ips=/srv/DASHBOARD/restricted-ips.json"]
binds:
- /etc/hosts:/etc/hosts:ro
- /var/lib/fic/dashboard:/srv/DASHBOARD:ro
- /var/lib/fic/files:/srv/FILES:ro
- /var/lib/fic/teams:/srv/TEAMS:ro
- /var/lib/fic/settingsdist:/srv/SETTINGSDIST:ro
net: /run/netns/fic-admin
pid: new
ipc: new
uts: new
runtime:
mkdir:
- /var/lib/fic/dashboard
- /var/lib/fic/teams
- /var/lib/fic/settingsdist
- name: fic-generator
image: nemunaire/fic-generator:latest
command: ["/srv/generator", "-bind=/srv/GENERATOR/generator.socket"]
env:
- MYSQL_HOST=db
- MYSQL_PASSWORD_FILE=/run/secrets/mysql_password
binds:
- /etc/hosts:/etc/hosts:ro
- /var/lib/fic/generator:/srv/GENERATOR
- /var/lib/fic/teams:/srv/TEAMS
- /var/lib/fic/secrets/mysql_password:/run/secrets/mysql_password:ro
- /var/lib/fic/settingsdist:/srv/SETTINGSDIST:ro
net: /run/netns/fic-generator
pid: new
ipc: new
uts: new
runtime:
mkdir:
- /var/lib/fic/generator
- /var/lib/fic/settingsdist
- /var/lib/fic/teams
- name: fic-qa
image: nemunaire/fic-qa:latest
command: ["/srv/qa", "--bind=:8083", "-baseurl=/qa"]
env:
- MYSQL_HOST=db
- MYSQL_PASSWORD_FILE=/run/secrets/mysql_password
binds:
- /etc/hosts:/etc/hosts:ro
- /var/lib/fic/teams:/srv/TEAMS:ro
- /var/lib/fic/secrets/mysql_password:/run/secrets/mysql_password:ro
- /var/lib/fic/settingsdist:/srv/SETTINGSDIST:ro
net: /run/netns/fic-qa
pid: new
ipc: new
uts: new
runtime:
mkdir:
- /var/lib/fic/teams
- name: fic-synchro
image: nemunaire/rsync:a3d76b2dd0a9ad73be44dc77ad765b20d96a3285
command: ["/bin/ash", "/root/synchro.sh"]
binds:
- /etc/hosts:/etc/hosts:ro
- /var/lib/fic/ssh:/etc/ssh:ro
- /run/config/synchro/id_ed25519:/root/.ssh/id_ed25519:ro
- /root/synchro.sh:/root/synchro.sh:ro
- /var/lib/fic/files:/srv/FILES:ro
#- /var/lib/fic/pki/ca.key:/srv/PKI/ca.key:ro
- /var/lib/fic/pki/shared:/srv/PKI/shared:ro
- /var/lib/fic/settingsdist:/srv/SETTINGSDIST:ro
- /var/lib/fic/submissions:/srv/submissions
- /var/lib/fic/teams:/srv/TEAMS:ro
- /var/log/frontend:/var/log/frontend
net: /run/netns/synchro
runtime:
mkdir:
- /var/lib/fic/files
- /var/lib/fic/pki/shared
- /var/lib/fic/settingsdist
- /var/lib/fic/ssh
- /var/lib/fic/submissions
- /var/lib/fic/teams
- /var/log/frontend
- name: sshd
image: nemunaire/rsync:a3d76b2dd0a9ad73be44dc77ad765b20d96a3285
binds:
- /etc/hosts:/etc/hosts:ro
- /var/lib/fic/ssh:/etc/ssh:ro
- /run/config/ssh/authorized_keys:/root/.ssh/authorized_keys:ro
- /usr/bin/iptables:/usr/bin/iptables:ro
- /usr/bin/mariadb:/usr/bin/mariadb:ro
- /usr/bin/mysql:/usr/bin/mysql:ro
- /usr/bin/pnsenter:/usr/bin/pnsenter:ro
- /usr/bin/status:/usr/bin/status:ro
- /var/lib/fic/outofsync:/var/lib/fic/outofsync
- /var/lib/fic/raw_files:/mnt/fic
- /var/lib/fic/secrets:/var/lib/fic/secrets:ro
- /var/log:/var/log:ro
capabilities:
- all
net: /run/netns/fic-admin
pid: host
runtime:
mkdir:
- /var/lib/fic/outofsync
# - name: dhcp-server
# image: joebiellik/dhcpd
# binds:
# - /etc/dhcp/dhcpd.conf:/etc/dhcp/dhcpd.conf:ro
# capabilities:
# - CAP_NET_BIND_SERVICE
# - CAP_NET_RAW
# - CAP_DAC_OVERRIDE
# net: /run/netns/fic-admin
# pid: new
# ipc: new
# uts: new
files:
- path: etc/init.d/001-hostname
contents: |
#!/bin/sh
/bin/hostname deimos
mode: "0555"
- path: bin/init_secrets.sh
contents: |
#!/bin/sh
SECRETS_DIR="/var/lib/fic/secrets"
[ -f "${SECRETS_DIR}/mysql_password" ] || tr -d -c "a-zA-Z0-9" < /dev/urandom | fold -w31 | head -n 1 > "${SECRETS_DIR}/mysql_password"
[ -f "${SECRETS_DIR}/fic_ca_pass" ] || tr -d -c "a-zA-Z0-9" < /dev/urandom | fold -w31 | head -n 1 > "${SECRETS_DIR}/fic_ca_pass"
[ -f "${SECRETS_DIR}/fic_oidc_secret" ] || tr -d -c "a-zA-Z0-9" < /dev/urandom | fold -w31 | head -n 1 > "${SECRETS_DIR}/fic_oidc_secret"
mode: "0755"
- path: etc/profile.d/color_prompt.sh
contents: |
PS1='\[\e[1;33m\]'$PS1'\[\e[0m\]'
mode: "0444"
- path: etc/init.d/015-setup-sshd
source: configs/sshd-setup.sh
mode: "0555"
- path: etc/sysctl.d/01-fic.conf
source: configs/sysctl-backend.conf
mode: "0444"
- path: root/synchro.sh
source: configs/synchro.sh
mode: "0755"
- path: root/mysql_backup.sh
source: configs/mysql_backup.sh
mode: "0755"
- path: etc/hosts
source: configs/hosts
mode: "0644"
- path: usr/bin/status
contents: |
#!/bin/sh
nsenter -t 1 -m ctr -n services.linuxkit t ls
mode: "0755"
- path: usr/bin/upgrade_image
contents: |
#!/bin/sh
echo "Erasing image..."
[ -d /boot/imgs ] || mount /dev/sda1 /boot || exit 1
mv /var/lib/fic/outofsync/fickit-backend-squashfs.img /boot/imgs/fickit-backend-squashfs.img || \
exit 1
if [ $(sha3sum /var/lib/fic/outofsync/fickit-metadata.iso | cut -d " " -f 1) != $(sha3sum /boot/imgs/fickit-metadata.iso | cut -d " " -f 1) ]
then
ISO=$(mktemp -d)
mount /var/lib/fic/outofsync/fickit-metadata.iso "${ISO}"
NEW_KEY=$(sed -rn 's/.*"content": "([^"]+)"$/\1/p' "${ISO}/user-data" | head -n 1)
OLD_KEY=$(cat /run/config/dm-crypt/key)
[ "${NEW_KEY}" != "${OLD_KEY}" ] && {
read -p "DM-CRYPT key changed in metadata, are you sure you want to erase it? (y/N) " V
[ "$V" != "y" ] && [ "$V" != "Y" ] && exit 1;
};
cp /boot/imgs/fickit-metadata.iso /boot/imgs/fickit-metadata.iso.bak || exit 1;
mv /var/lib/fic/outofsync/fickit-metadata.iso /boot/imgs/fickit-backend-squashfs.img || exit 1;
dd if=/boot/imgs/fickit-metadata.iso of="$2" || exit 1;
echo
echo "Metadata erased"
fi
echo
echo "Done! You can reboot now."
mode: "0755"
- path: usr/bin/iptables
source: configs/nsenter_iptables.sh
mode: "0755"
- path: usr/bin/mysql
source: configs/nsenter_mysql.sh
mode: "0755"
- path: usr/bin/mariadb
source: configs/nsenter_mysql.sh
mode: "0755"
- path: usr/bin/pnsenter
source: configs/nsenter_process.sh
mode: "0755"
- path: etc/mysql/conf.d/max-conn.cnf
contents: |
[mysqld]
max_connections = 99999
mode: "0444"
- path: etc/dhcp/dhcpd.conf
contents: |
default-lease-time 600;
max-lease-time 7200;
option subnet-mask 255.255.255.0;
option broadcast-address 192.168.3.255;
subnet 192.168.3.0 netmask 255.255.255.0 {
range 192.168.3.11 192.168.3.250;
}
mode: "0440"
- path: etc/iptables/rules.v6
contents: |
*filter
:INPUT DROP [0:0]
:FORWARD DROP [0:0]
:OUTPUT DROP [0:0]
COMMIT
mode: "0440"
- path: etc/iptables/rules-admin.v4
contents: |
*filter
:INPUT DROP [0:0]
:FORWARD DROP [0:0]
:OUTPUT DROP [0:0]
[0:0] -A INPUT -i lo -j ACCEPT
[0:0] -A INPUT -m conntrack --ctstate INVALID -j DROP
[0:0] -A INPUT -p icmp -j ACCEPT
[0:0] -A INPUT -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
[0:0] -A INPUT -p tcp -m conntrack --ctstate NEW -m tcp --dport ssh -j ACCEPT
[0:0] -A INPUT -p tcp -m conntrack --ctstate NEW -m tcp --dport 8082 -j ACCEPT
[0:0] -A INPUT -i vethin-admin -s 172.17.0.0/24 -p tcp -m conntrack --ctstate NEW -j ACCEPT
[0:0] -A INPUT -j LOG
[0:0] -A FORWARD -j LOG
[0:0] -A OUTPUT -o lo -j ACCEPT
[0:0] -A OUTPUT -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
[0:0] -A OUTPUT -p icmp -j ACCEPT
[0:0] -A OUTPUT -o eth1 -d 10.0.0.0/24 -p tcp -m conntrack --ctstate NEW -m tcp --dport 443 -j ACCEPT
[0:0] -A OUTPUT -o vethin-admin -d 172.17.0.0/24 -p tcp -m conntrack --ctstate NEW -j ACCEPT
[0:0] -A OUTPUT -j LOG
[0:0] -A OUTPUT -j REJECT
COMMIT
mode: "0440"
- path: etc/iptables/rules-synchro.v4
contents: |
*filter
:INPUT DROP [0:0]
:FORWARD DROP [0:0]
:OUTPUT DROP [0:0]
[0:0] -A INPUT -i lo -j ACCEPT
[0:0] -A INPUT -m conntrack --ctstate INVALID -j DROP
[0:0] -A INPUT -p icmp --icmp-type 8 -j ACCEPT
[0:0] -A INPUT -p icmp --icmp-type 0 -j ACCEPT
[0:0] -A INPUT -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
[0:0] -A INPUT -j LOG
[0:0] -A FORWARD -j LOG
[0:0] -A OUTPUT -o lo -j ACCEPT
[0:0] -A OUTPUT -p icmp --icmp-type 0 -j ACCEPT
[0:0] -A OUTPUT -p icmp --icmp-type 8 -j ACCEPT
[0:0] -A OUTPUT -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
[0:0] -A OUTPUT -o eth2 -d 10.10.10.2 -p tcp -m conntrack --ctstate NEW -m tcp --dport ssh -j ACCEPT
[0:0] -A OUTPUT -j LOG
[0:0] -A OUTPUT -j REJECT
COMMIT
mode: "0440"
trust:
org:
- linuxkit
- library