1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-11-11 12:46:49 +00:00
webvirtcloud/conf/docker/start
catborise 80a66dc8b5 build(docker): the image is Ubuntu 26.04 with supervisord in place of phusion's runit
phusion/baseimage brought sshd, syslog-ng, my_init and runit's per
service scripts, and an nginx log forwarder tailing a file. The image
is now ubuntu:26.04 with Ubuntu's supervisor: conf/docker holds the
start script (settings, secret key, ownership, migrations as www-data),
one supervisord.conf for the six processes, nginx's config with errors
to docker logs, the backup's cron line and the health check. A stop
signals every process at once, so the worker keeps its 60 s drain
within the 95 s grace. The same volumes and container name work as
before; README runs commands with exec -u www-data in place of
/sbin/setuser. The image goes from 805 MB to 642 MB.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kk4h2TcUiaWmU5MUszYSea
2026-11-08 16:09:21 +03:00

26 lines
1.1 KiB
Bash

#!/bin/sh
# The container's start: settings, secret key and database in place, the
# data the panel's own, migrations run; then the command (supervisord).
set -eu
cd /srv/webvirtcloud
[ -f webvirtcloud/settings.py ] || cp webvirtcloud/settings.py.template webvirtcloud/settings.py
if [ -z "${SECRET_KEY:-}" ] && [ ! -s data/secret_key ]; then
(umask 077 && venv/bin/python3 -c 'import secrets; print(secrets.token_urlsafe(50))' > data/secret_key)
fi
# the database lives in the data volume
touch data/db.sqlite3
ln -sfn /srv/webvirtcloud/data/db.sqlite3 db.sqlite3
# The database holds compute passwords and password hashes: the data, keys,
# settings and backups are readable by the panel's user only.
chown -R www-data:www-data data /var/www/.ssh /var/www/.pki
chown www-data:www-data backups webvirtcloud/settings.py
chmod 700 data backups /var/www/.ssh /var/www/.pki
chmod 600 data/db.sqlite3 webvirtcloud/settings.py
# cron starts its jobs with an empty environment: the backup reads this one
(umask 077 && export -p > /run/webvirtcloud.env)
runuser -u www-data -- venv/bin/python3 manage.py migrate --noinput
exec "$@"