mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-01 16:36:06 +00:00
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
This commit is contained in:
parent
b03828c684
commit
80a66dc8b5
21 changed files with 218 additions and 203 deletions
130
Dockerfile
130
Dockerfile
|
|
@ -1,22 +1,39 @@
|
|||
FROM phusion/baseimage:resolute-1.0.23 AS build
|
||||
# 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
|
||||
|
||||
# Compilers and headers for libvirt-python and python-ldap; they stay in this stage.
|
||||
# hadolint ignore=DL3008
|
||||
RUN apt-get update -qqy \
|
||||
&& DEBIAN_FRONTEND=noninteractive apt-get -qyy install \
|
||||
--no-install-recommends \
|
||||
python3-venv \
|
||||
python3-dev \
|
||||
libvirt-dev \
|
||||
zlib1g-dev \
|
||||
pkg-config \
|
||||
gcc \
|
||||
libldap2-dev \
|
||||
libssl-dev \
|
||||
libsasl2-dev \
|
||||
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
||||
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
|
||||
|
|
@ -25,79 +42,30 @@ RUN --mount=type=cache,target=/root/.cache/pip \
|
|||
&& venv/bin/pip install -r conf/requirements.txt -r conf/requirements-ldap.txt \
|
||||
&& venv/bin/pip uninstall -y pip
|
||||
|
||||
FROM phusion/baseimage:resolute-1.0.23
|
||||
FROM base
|
||||
|
||||
EXPOSE 80
|
||||
|
||||
# Use baseimage-docker's init system. my_init force-stops services after
|
||||
# KILL_PROCESS_TIMEOUT seconds (default 30); the worker drains jobs for 60 s.
|
||||
ENV KILL_PROCESS_TIMEOUT=80
|
||||
CMD ["/sbin/my_init"]
|
||||
|
||||
RUN echo 'APT::Get::Clean=always;' >> /etc/apt/apt.conf.d/99AutomaticClean
|
||||
|
||||
# Shared libraries of the compiled wheels, and nginx; no compilers or headers.
|
||||
# hadolint ignore=DL3008
|
||||
RUN apt-get update -qqy \
|
||||
&& DEBIAN_FRONTEND=noninteractive apt-get -qyy install \
|
||||
--no-install-recommends \
|
||||
python3 \
|
||||
nginx \
|
||||
libvirt0 \
|
||||
libsasl2-modules \
|
||||
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
||||
|
||||
WORKDIR /srv/webvirtcloud
|
||||
COPY --from=build /srv/webvirtcloud/venv venv
|
||||
COPY . /srv/webvirtcloud
|
||||
COPY . .
|
||||
|
||||
# The code stays root's: the panel writes only to its data and backup
|
||||
# directories (made its own at start). A settings file and a key exist only
|
||||
# for collectstatic.
|
||||
RUN cp webvirtcloud/settings.py.template webvirtcloud/settings.py && \
|
||||
SECRET_KEY="build-dummy-key-only-for-collectstatic" WEBVIRTCLOUD_LOG_FILE=/tmp/build.log \
|
||||
venv/bin/python3 manage.py collectstatic --noinput && \
|
||||
rm -f webvirtcloud/settings.py /tmp/build.log
|
||||
|
||||
# Setup Nginx
|
||||
RUN printf "\n%s" "daemon off;" >> /etc/nginx/nginx.conf && \
|
||||
rm -f /etc/nginx/sites-enabled/default && \
|
||||
chown -R www-data:www-data /var/lib/nginx
|
||||
RUN cp webvirtcloud/settings.py.template webvirtcloud/settings.py \
|
||||
&& SECRET_KEY=build-only WEBVIRTCLOUD_LOG_FILE=/tmp/build.log venv/bin/python3 manage.py collectstatic --noinput \
|
||||
&& rm webvirtcloud/settings.py /tmp/build.log
|
||||
|
||||
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/
|
||||
|
||||
# Register startup init script and services to runit
|
||||
RUN mkdir -p /etc/my_init.d \
|
||||
/etc/service/nginx \
|
||||
/etc/service/nginx-log-forwarder \
|
||||
/etc/service/webvirtcloud \
|
||||
/etc/service/webvirtcloud-worker \
|
||||
/etc/service/novnc \
|
||||
/etc/service/socketiod
|
||||
COPY conf/runit/10_webvirtcloud_init.sh /etc/my_init.d/10_webvirtcloud_init.sh
|
||||
COPY conf/runit/nginx /etc/service/nginx/run
|
||||
COPY conf/runit/nginx-log-forwarder /etc/service/nginx-log-forwarder/run
|
||||
COPY conf/runit/novncd.sh /etc/service/novnc/run
|
||||
COPY conf/runit/socketiod.sh /etc/service/socketiod/run
|
||||
COPY conf/runit/webvirtcloud.sh /etc/service/webvirtcloud/run
|
||||
COPY conf/runit/webvirtcloud-worker.sh /etc/service/webvirtcloud-worker/run
|
||||
COPY --chmod=644 conf/runit/backup.cron /etc/cron.d/webvirtcloud-backup
|
||||
COPY --chmod=755 conf/runit/healthcheck /usr/local/bin/webvirtcloud-healthcheck
|
||||
RUN chmod +x /etc/my_init.d/10_webvirtcloud_init.sh \
|
||||
/etc/service/nginx/run \
|
||||
/etc/service/nginx-log-forwarder/run \
|
||||
/etc/service/novnc/run \
|
||||
/etc/service/socketiod/run \
|
||||
/etc/service/webvirtcloud/run \
|
||||
/etc/service/webvirtcloud-worker/run
|
||||
|
||||
# The panel's page and every service (conf/runit/healthcheck). X-Forwarded-Proto:
|
||||
# https keeps the probe from being redirected when the HTTPS profile is on
|
||||
# (nginx passes the header on; see conf/nginx).
|
||||
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
|
||||
CMD /usr/local/bin/webvirtcloud-healthcheck
|
||||
|
||||
# Declare mountable data directory for persistent SQLite, SSH keys and TLS certificates, and their backups
|
||||
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"]
|
||||
|
||||
WORKDIR /srv/webvirtcloud
|
||||
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 CMD ["healthcheck"]
|
||||
|
||||
ENTRYPOINT ["start"]
|
||||
CMD ["supervisord", "-c", "/etc/supervisor/supervisord.conf"]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue