Upgrade to debian-based rootfs

This commit is contained in:
Václav Valíček 2021-01-20 12:55:06 +01:00
parent bfda197c4d
commit 0264a6e81f
No known key found for this signature in database
GPG Key ID: 91AA271095BD0100
8 changed files with 83 additions and 27 deletions

View File

@ -1,23 +1,41 @@
# Alpine base image
FROM registry.sw3.cz/valicek1/lxc-alpine
# Debian base image
FROM registry.sw3.cz/valicek1/lxcbian-bullseye
VOLUME /data
RUN apk add --no-cache git bash openssh parallel openssh-keygen vim shadow
# install dependencies
RUN apt-get update
RUN apt-get full-upgrade -y --no-install-recommends
RUN apt-get install -y --no-install-recommends \
git bash openssh-server parallel vim cron npm nodejs logrotate
RUN apt-get clean
# create executor user
RUN useradd --uid 10000 -ms /bin/bash executor
ADD crontab /etc/crontabs/executor
RUN apk del shadow
# install crontab, enable cron
ADD crontab /etc/cron.d/repo-cloner-executor
RUN bash -c "dpkg -l | grep cron"
RUN systemctl enable ssh cron
ADD dockerbin/* checker/* src/* /usr/local/bin/
ADD executor-conf /etc/init.d
RUN rc-update add executor-conf default
# remove tty autospawn from inittab
RUN sed 's/^tty.*$//g' -i /etc/inittab
# disable motd
RUN echo > /etc/motd
# install tail logger
RUN apk add npm
RUN npm i frontail -g
# enable frontail at startup
ADD startup-logcat /usr/local/bin
ADD logcat.service /etc/systemd/system
RUN systemctl enable logcat
# enable log dumping & rotation
ADD startup-logdump /usr/local/bin
ADD syslog.logrotate /etc/logrotate.d/syslog
ADD logdump.service /etc/systemd/system
RUN systemctl enable logdump
RUN ln -fs /usr/share/zoneinfo/Europe/Prague /etc/localtime
CMD [ "/sbin/init" ]

View File

@ -1,3 +1,4 @@
# executor crontab
* * * * * /usr/local/bin/cron-command >> /home/executor/cron.log
0 0 * * * mv /home/executor/cron.log /home/executor/cron.old
MAILTO=""
* * * * * executor /usr/local/bin/cron-command >> /home/executor/cron.log 2>&1
0 0 * * * executor mv /home/executor/cron.log /home/executor/cron.old

View File

@ -1,16 +0,0 @@
#!/sbin/openrc-run
description="Sets executor initial evironment"
start() {
# make parallel citation shut up
mkdir -p ~executor/.parallel
touch ~executor/.parallel/will-cite
# repair ownership
find /data \! -user executor -exec chown executor:executor {} \;
# pidfile
touch /var/run/cloner.pid
chown executor:executor /var/run/cloner.pid
frontail /var/log/messages /home/executor/cron.log --daemonize --url-path /logs
}

13
logcat.service Normal file
View File

@ -0,0 +1,13 @@
[Unit]
Description=Logcat service startup
Documentation=Fix ownership and start logcat
After=network.target
[Service]
Type=forking
User=root
ExecStart=/usr/local/bin/startup-logcat
Restart=on-failure
[Install]
WantedBy=multi-user.target

12
logdump.service Normal file
View File

@ -0,0 +1,12 @@
[Unit]
Description=Dumps journalctl to syslog file
After=network.target
[Service]
Type=simple
User=root
ExecStart=/usr/local/bin/startup-logdump
Restart=on-failure
[Install]
WantedBy=multi-user.target

12
startup-logcat Executable file
View File

@ -0,0 +1,12 @@
#!/bin/bash
# make parallel citation shut up
mkdir -p ~executor/.parallel
touch ~executor/.parallel/will-cite
# repair ownership
find /data \! -user executor -exec chown executor:executor {} \;
frontail /var/log/syslog /home/executor/cron.log --daemonize --url-path /logs

4
startup-logdump Executable file
View File

@ -0,0 +1,4 @@
#!/bin/bash
journalctl -f > /var/log/syslog

12
syslog.logrotate Normal file
View File

@ -0,0 +1,12 @@
/var/log/syslog {
daily
missingok
rotate 10
compress
delaycompress
notifempty
nocreate
copytruncate
}