From 922648d59b2dfdc0737deded028f0d75b695c9e6 Mon Sep 17 00:00:00 2001 From: CodingWithSaksham Date: Sun, 28 Jun 2026 20:43:47 +0530 Subject: [PATCH 1/4] [feature] Add Docker support for development and testing #741 Added Docker support to streamline development and testing workflows Closes #741 --- Dockerfile | 47 +++++++++++++++++++++++++++++++ docker-compose.yml | 30 +++++++++++++++++--- docs/developer/installation.rst | 50 +++++++++++++++++++++++++++++++++ tests/docker-entrypoint.sh | 23 +++++++++++++++ 4 files changed, 146 insertions(+), 4 deletions(-) create mode 100644 Dockerfile create mode 100644 tests/docker-entrypoint.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..a017ca80 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,47 @@ +# NOTE: This Docker image is for development purposes only. + +FROM python:3.12-slim-bookworm + +# System dependencies from the developer installation guide +RUN apt-get update && \ + apt-get install -y --no-install-recommends \ + xmlsec1 \ + gettext \ + fping \ + gdal-bin \ + libproj-dev \ + libgeos-dev \ + libspatialite-dev \ + spatialite-bin \ + libsqlite3-mod-spatialite \ + sqlite3 \ + libsqlite3-dev \ + zlib1g-dev \ + libjpeg-dev \ + openssl \ + libssl-dev \ + libglib2.0-0 \ + libcairo2 \ + libpango-1.0-0 \ + libpangocairo-1.0-0 \ + libgdk-pixbuf-2.0-0 \ + shared-mime-info \ + && rm -rf /var/lib/apt/lists/* + +WORKDIR /opt/openwisp + +# Install test requirements first so this layer is cached separately +# from the source code copy below. +COPY requirements-test.txt . +RUN pip install --no-cache-dir -r requirements-test.txt + +# Copy source and install the package with all optional extras +COPY . . +RUN pip install --no-cache-dir -e ".[saml,openvpn_status]" + +ENV PYTHONUNBUFFERED=1 \ + REDIS_HOST=redis \ + INFLUXDB_HOST=influxdb + +EXPOSE 8000 +CMD ["bash", "docker-entrypoint.sh"] diff --git a/docker-compose.yml b/docker-compose.yml index a7592770..ee87f4f0 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,3 @@ -version: "3" - services: influxdb: image: influxdb:1.8-alpine @@ -11,12 +9,36 @@ services: INFLUXDB_DB: openwisp2 INFLUXDB_USER: openwisp INFLUXDB_USER_PASSWORD: openwisp + networks: + - openwisp redis: image: redis:alpine ports: - "6379:6379" - entrypoint: redis-server --appendonly yes + command: redis-server --appendonly yes + networks: + - openwisp + + radius: + build: + context: . + dockerfile: Dockerfile + image: openwisp-radius-dev + working_dir: /opt/openwisp/tests + ports: + - "8000:8000" + volumes: + - .:/opt/openwisp/ + depends_on: + - redis + - influxdb + networks: + - openwisp volumes: - influxdb-data: {} + influxdb-data: + +networks: + openwisp: + driver: bridge diff --git a/docs/developer/installation.rst b/docs/developer/installation.rst index f93e9b8e..638f4107 100644 --- a/docs/developer/installation.rst +++ b/docs/developer/installation.rst @@ -115,6 +115,56 @@ Run quality assurance tests with: ./run-qa-checks +.. _radius_dev_docker: + +Install and Run on Docker +------------------------- + +.. warning:: + + This Docker image is for development purposes only. + + For the official OpenWISP Docker images, see: :doc:`docker-openwisp + `. + +Ensure `Docker `_ and +`Docker Compose `_ are installed +on your system. + +Fork and clone the forked repository: + +.. code-block:: shell + + git clone git://github.com//openwisp-radius + +Navigate into the cloned repository: + +.. code-block:: shell + + cd openwisp-radius/ + +Build the development image: + +.. code-block:: shell + + docker compose build + +Start all services (Redis, InfluxDB, and the development server): + +.. code-block:: shell + + docker compose up + +The development server will be available at ``http://127.0.0.1:8000/``. +The admin interface is at ``http://127.0.0.1:8000/admin/`` with credentials +``admin`` / ``admin``. + +To run the test suite inside the container: + +.. code-block:: shell + + docker compose run --rm radius bash -c "cd /opt/openwisp && ./runtests" + Alternative Sources ------------------- diff --git a/tests/docker-entrypoint.sh b/tests/docker-entrypoint.sh new file mode 100644 index 00000000..b7adcede --- /dev/null +++ b/tests/docker-entrypoint.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +set -euo pipefail + +create_superuser() { + local username="$1" + local email="$2" + local password="$3" + cat < Date: Sun, 28 Jun 2026 23:22:54 +0530 Subject: [PATCH 2/4] [change] Address @coderabbitai's changes and fix CI --- Dockerfile | 2 +- docs/developer/installation.rst | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index a017ca80..eccee820 100644 --- a/Dockerfile +++ b/Dockerfile @@ -28,7 +28,7 @@ RUN apt-get update && \ shared-mime-info \ && rm -rf /var/lib/apt/lists/* -WORKDIR /opt/openwisp +WORKDIR /opt/openwisp/tests # Install test requirements first so this layer is cached separately # from the source code copy below. diff --git a/docs/developer/installation.rst b/docs/developer/installation.rst index 638f4107..3ae09ac8 100644 --- a/docs/developer/installation.rst +++ b/docs/developer/installation.rst @@ -127,9 +127,8 @@ Install and Run on Docker For the official OpenWISP Docker images, see: :doc:`docker-openwisp `. -Ensure `Docker `_ and -`Docker Compose `_ are installed -on your system. +Ensure `Docker `_ and `Docker Compose +`_ are installed on your system. Fork and clone the forked repository: @@ -156,8 +155,8 @@ Start all services (Redis, InfluxDB, and the development server): docker compose up The development server will be available at ``http://127.0.0.1:8000/``. -The admin interface is at ``http://127.0.0.1:8000/admin/`` with credentials -``admin`` / ``admin``. +The admin interface is at ``http://127.0.0.1:8000/admin/`` with +credentials ``admin`` / ``admin``. To run the test suite inside the container: From cf3733205ab244c6ce9dcd9182fa22df3dfb8830 Mon Sep 17 00:00:00 2001 From: CodingWithSaksham Date: Sun, 28 Jun 2026 23:43:32 +0530 Subject: [PATCH 3/4] [fix] Revert Dockerfile change --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index eccee820..a017ca80 100644 --- a/Dockerfile +++ b/Dockerfile @@ -28,7 +28,7 @@ RUN apt-get update && \ shared-mime-info \ && rm -rf /var/lib/apt/lists/* -WORKDIR /opt/openwisp/tests +WORKDIR /opt/openwisp # Install test requirements first so this layer is cached separately # from the source code copy below. From 6b8edbefec5738123d300d49c633b18a2f08ac85 Mon Sep 17 00:00:00 2001 From: CodingWithSaksham Date: Mon, 29 Jun 2026 20:55:19 +0530 Subject: [PATCH 4/4] [change] Add .dockerignore and remove WORKDIR from Dockerfile --- .dockerignore | 37 +++++++++++++++++++++++++++++++++++++ Dockerfile | 2 -- 2 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..3059dda7 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,37 @@ +# Python bytecode +__pycache__/ +*.py[cod] +*$py.class + +# Virtual environments +.venv/ +venv/ +env/ +ENV/ + +# Packaging / build artifacts +build/ +dist/ +*.egg-info/ +.eggs/ +pip-wheel-metadata/ + +# Test / coverage / type-check caches +.pytest_cache/ +.coverage +.coverage.* +.mypy_cache/ +.pyre/ +.ruff_cache/ + +# Git / editor / OS files +.git/ +.gitignore +.gitattributes +.vscode/ +.idea/ +.DS_Store +Thumbs.db + +docker-compose*.yml +Dockerfile* diff --git a/Dockerfile b/Dockerfile index a017ca80..218be9b1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -28,8 +28,6 @@ RUN apt-get update && \ shared-mime-info \ && rm -rf /var/lib/apt/lists/* -WORKDIR /opt/openwisp - # Install test requirements first so this layer is cached separately # from the source code copy below. COPY requirements-test.txt .