1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-11-08 19:26:48 +00:00
webvirtcloud/Dockerfile
catborise 964b58778d ci: test Python 3.13, check migrations, schema, deploy and audit
- Matrix 3.10-3.13; pip cache keyed on the requirements.
- New steps: makemigrations --check, spectacular --validate
  --fail-on-warn, check --deploy --fail-level ERROR, pip-audit of the
  installed environment (the Django 4.2.30 advisories are ignored until
  the Django 5.2 upgrade), and a Docker image build.
- The separate vrtManager unittest run is dropped; manage.py test
  already runs those tests.
- CodeQL also runs on pull requests to master.
- Docker installs into a plain venv instead of using the distro's
  python3-lxml and python3-libvirt; lxml>=6.1, since the distro's
  lxml 5.2.1 has CVE-2026-41066.
- dev requirements add ruff and pip-audit.
2026-10-04 01:08:11 +03:00

79 lines
2.4 KiB
Docker

FROM phusion/baseimage:noble-1.0.2
EXPOSE 80
EXPOSE 6080
# Use baseimage-docker's init system.
CMD ["/sbin/my_init"]
RUN echo 'APT::Get::Clean=always;' >> /etc/apt/apt.conf.d/99AutomaticClean
# hadolint ignore=DL3008
RUN apt-get update -qqy \
&& DEBIAN_FRONTEND=noninteractive apt-get -qyy install \
--no-install-recommends \
git \
python3-venv \
python3-pip \
python3-dev \
libvirt-dev \
zlib1g-dev \
nginx \
pkg-config \
gcc \
libldap2-dev \
libssl-dev \
libsasl2-dev \
libsasl2-modules \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Setup webvirtcloud
WORKDIR /srv/webvirtcloud
# Install Python dependencies first; libvirt-python and python-ldap build from source
COPY conf/requirements.txt conf/requirements.txt
# hadolint ignore=DL3013,DL3042,SC1091
RUN python3 -m venv venv && \
. venv/bin/activate && \
pip3 install --no-cache-dir -U pip wheel && \
pip3 install --no-cache-dir -r conf/requirements.txt
# Copy application source
COPY . /srv/webvirtcloud
# Run collectstatic with temporary dummy key, then remove temporary settings file
# hadolint ignore=SC1091
RUN . venv/bin/activate && \
cp webvirtcloud/settings.py.template webvirtcloud/settings.py && \
SECRET_KEY="build-dummy-key-only-for-collectstatic" python3 manage.py collectstatic --noinput && \
rm -f webvirtcloud/settings.py && \
chown -R www-data:www-data /srv/webvirtcloud
# 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
COPY conf/nginx/webvirtcloud.conf /etc/nginx/conf.d/
# 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/novnc
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/webvirtcloud.sh /etc/service/webvirtcloud/run
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/webvirtcloud/run
# Declare mountable data directory for persistent SQLite and SSH keys
VOLUME ["/srv/webvirtcloud/data", "/var/www/.ssh"]
WORKDIR /srv/webvirtcloud