Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
**/*.log
**/console/cert.pem*
**/dhcpd.*
webvirtcloud/settings.py

# IDEs and OS
**/.idea
Expand Down
5 changes: 5 additions & 0 deletions .github/linters/.hadolint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ignored:
- DL3008
- DL3013
- DL3042
- SC1091
4 changes: 3 additions & 1 deletion .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,13 @@ jobs:
- name: Lint Code Base
uses: docker://github/super-linter:latest
env:
FILTER_REGEX_EXCLUDE: .*(static|scss|venv|locale)/.*
FILTER_REGEX_EXCLUDE: .*(static|scss|venv|locale|templates)/.*
DEFAULT_BRANCH: master
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VALIDATE_ALL_CODEBASE: false
VALIDATE_MARKDOWN: false
VALIDATE_HTML: false
VALIDATE_JSCPD: false
VALIDATE_ANSIBLE: false
VALIDATE_CLOJURE: false
VALIDATE_COFFEE: false
Expand Down
66 changes: 66 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Test Suite

on:
push:
branches: [master]
pull_request:
branches: [master]

jobs:
test:
name: Python ${{ matrix.python-version }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ['3.10', '3.11', '3.12']

steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
cache-dependency-path: 'conf/requirements.txt'

- name: Install System Dependencies
run: |
sudo apt-get update -qq
sudo apt-get install -y --no-install-recommends \
libvirt-dev \
libldap2-dev \
libsasl2-dev \
python3-lxml \
zlib1g-dev \
libxslt1-dev \
pkg-config \
gcc \
libssl-dev \
libxml2-dev

- name: Install Python Dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
pip install -r conf/requirements.txt
if [ -f dev/requirements.txt ]; then pip install -r dev/requirements.txt; fi

- name: Configure WebVirtCloud Settings
run: |
cp webvirtcloud/settings.py.template webvirtcloud/settings.py
SECRET_KEY=$(python -c 'import secrets; print(secrets.token_urlsafe(50))')
sed -i "s|^SECRET_KEY = .*|SECRET_KEY = \"${SECRET_KEY}\"|" webvirtcloud/settings.py

- name: Run Django Migrations
run: |
python manage.py migrate --noinput

- name: Run Django Test Suite
run: |
python manage.py test

- name: Run vrtManager Unit Tests
run: |
python -m unittest discover -s vrtManager -p "test_*.py"
5 changes: 5 additions & 0 deletions .hadolint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ignored:
- DL3008
- DL3013
- DL3042
- SC1091
17 changes: 0 additions & 17 deletions .travis.yml

This file was deleted.

46 changes: 28 additions & 18 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,18 @@ 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 \
python3-lxml \
python3-libvirt \
libvirt-dev \
zlib1g-dev \
nginx \
Expand All @@ -30,42 +32,50 @@ RUN apt-get update -qqy \
# Setup webvirtcloud
WORKDIR /srv/webvirtcloud

# Install Python dependencies first to leverage Docker layer caching
# Install Python dependencies first with system-site-packages to leverage prebuilt bindings
COPY conf/requirements.txt conf/requirements.txt
RUN python3 -m venv venv && \
# hadolint ignore=DL3013,DL3042,SC1091
RUN python3 -m venv --system-site-packages venv && \
. venv/bin/activate && \
pip3 install -U pip && \
pip3 install wheel && \
pip3 install -r conf/requirements.txt && \
pip3 cache purge
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 && \
python3 manage.py makemigrations && \
python3 manage.py migrate && \
python3 manage.py collectstatic --noinput && \
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 /etc/nginx/sites-enabled/default && \
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 services to runit
RUN mkdir /etc/service/nginx && \
mkdir /etc/service/nginx-log-forwarder && \
mkdir /etc/service/webvirtcloud && \
mkdir /etc/service/novnc
# 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

# Define mountable directories.
#VOLUME []
# Declare mountable data directory for persistent SQLite and SSH keys
VOLUME ["/srv/webvirtcloud/data", "/var/www/.ssh"]

WORKDIR /srv/webvirtcloud
Loading
Loading