mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-02 08:56:07 +00:00
Every update rebuilt settings.py from the template, and the operator put back their own values by reading a diff: a forgotten DATABASES started the panel on a new, empty sqlite database. Docker users who needed an option only settings.py has (LDAP, OTP_ENABLED, LOGIN_TRUSTED_PROXIES) mounted their own copy and kept it up to date by hand. webvirtcloud/settings.py is now the tracked file (no template, no copy in the installer, the image, the container's start or CI), and it runs data/local_settings.py last: the installation's own values, which an update does not touch, kept in Docker's data volume, in the panel's backups and readable by the panel's user only. The installer writes the time zone, the noVNC port (now checked to be a number), ALLOWED_HOSTS and CSRF_TRUSTED_ORIGINS there instead of editing settings.py with sed. LDAP is set up there too; settings.py keeps only python-ldap's timeouts. The README's update steps move an older version's own settings.py into the backup before git pull and have its values moved into the local file once.
72 lines
2.6 KiB
Docker
72 lines
2.6 KiB
Docker
# The panel in one container: supervisord runs nginx, gunicorn, the job
|
|
# worker, the two console daemons and cron (conf/docker).
|
|
FROM ubuntu:26.04 AS base
|
|
|
|
RUN apt-get update -qq \
|
|
&& DEBIAN_FRONTEND=noninteractive apt-get install -qqy --no-install-recommends \
|
|
ca-certificates \
|
|
cron \
|
|
libldap2 \
|
|
libsasl2-modules \
|
|
libvirt0 \
|
|
nginx \
|
|
openssh-client \
|
|
python3 \
|
|
supervisor \
|
|
tzdata \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
WORKDIR /srv/webvirtcloud
|
|
|
|
# Compilers and headers for libvirt-python and python-ldap stay in this stage.
|
|
FROM base AS build
|
|
|
|
RUN apt-get update -qq \
|
|
&& DEBIAN_FRONTEND=noninteractive apt-get install -qqy --no-install-recommends \
|
|
gcc \
|
|
libldap2-dev \
|
|
libsasl2-dev \
|
|
libssl-dev \
|
|
libvirt-dev \
|
|
pkg-config \
|
|
python3-dev \
|
|
python3-venv \
|
|
zlib1g-dev \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
COPY conf/requirements.txt conf/requirements-ldap.txt conf/
|
|
# pip's cache stays on the build host for the next build; pip itself is not
|
|
# shipped: a dependency change is a new image
|
|
RUN --mount=type=cache,target=/root/.cache/pip \
|
|
python3 -m venv venv \
|
|
&& venv/bin/pip install -r conf/requirements.txt -r conf/requirements-ldap.txt \
|
|
&& venv/bin/pip uninstall -y pip
|
|
|
|
FROM base
|
|
|
|
# 4 gunicorn workers of 4 threads (about 140 MB each); docker-compose.override.yml can set another number
|
|
ENV GUNICORN_CMD_ARGS="--workers 4"
|
|
|
|
COPY --from=build /srv/webvirtcloud/venv venv
|
|
COPY . .
|
|
|
|
# The code stays root's: the panel writes only to its data and backup
|
|
# directories (made its own at start). A key exists only for collectstatic.
|
|
RUN SECRET_KEY=build-only WEBVIRTCLOUD_LOG_FILE=/tmp/build.log venv/bin/python3 manage.py collectstatic --noinput \
|
|
&& rm -f /tmp/build.log # the log handler makes the file at its first line only
|
|
|
|
COPY conf/docker/nginx.conf /etc/nginx/nginx.conf
|
|
COPY conf/nginx/webvirtcloud.conf /etc/nginx/conf.d/
|
|
COPY conf/docker/supervisord.conf /etc/supervisor/supervisord.conf
|
|
COPY --chmod=644 conf/docker/backup.cron /etc/cron.d/webvirtcloud-backup
|
|
COPY --chmod=755 conf/docker/start conf/docker/healthcheck /usr/local/bin/
|
|
|
|
EXPOSE 80
|
|
# the database, secret key and logs; SSH keys and TLS certificates for the
|
|
# computes; the daily backups
|
|
VOLUME ["/srv/webvirtcloud/data", "/var/www/.ssh", "/var/www/.pki", "/srv/webvirtcloud/backups"]
|
|
|
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 CMD ["healthcheck"]
|
|
|
|
ENTRYPOINT ["start"]
|
|
CMD ["supervisord", "-c", "/etc/supervisor/supervisord.conf"]
|