Hayden closed merge request !135: Mataara-Server#34: Containerised Development Setup at Mataara / Mataara Server

Hayden
2025-04-15T02:55:08Z

Add Docker Compose setup for local development

Add Dockerfile to build a Python base image with required dependencies

Document bringing up an environment for local development

Validate Dockerfile in CI

Validate docker compose config in CI

Changes in this MR

settings.py

Currently hardcodes a requirement for SSL connection unless env var CI is set. Switched to "allow", happy to reverse this if we'll make it work in local dev somehow (would be fine with "CI, or DEV", but didn't want to complicate settings.py).

Dockerfile

Build a runnable image - currently Python 3.5, APT installation of pip and setuptools, and the libraries from Pip requirements/common.txt.

Storing the output of this as a built container image means local development (or CI pipelines?) can start from that save point (eliminating a lot of duplicated pip install --upgrade). Whether we should do that in the CI test runs, or start from scratch but improve caching, TBC.

Currently, each CI run will execute the apt, pip install etc steps for each job, and that's not desirable - it slows down feedback and exhausts our free CI runner allocation on Gitlab.

docker-compose.yml

Docker Compose configuration which uses the built image to bring up a local development environment.

Makefile

Previously, setup for Vagrant environment used Fabric commands, while setup in CI used a matching set of CLI commands.

For consistency and to increase clarity, we should use the same processes. The make commands here aim to do that.

install-debs: Install base OS dependencies for Pip and Node

install-pip: Upgrade Pip

create-venv: Create a venv and add it to .bashrc

install-common, install-dev, install-docs, install-build: Install Pip deps from requirements/{common,dev,docs,build}.txt

install-frontend: Install frontend deps via npm ci in archimedes/frontend

build-frontend: Build the frontend files and run Django collectstatic

create-mataara-config: Copy conf/${APP}.default.ini to /etc/${APP}/${APP}.ini

create-encryption-keys: Run the OpenSSL commands to create keys

run-mataara: Start the development server

django-tests: Run the Django tests

lint: Run flake8

See changes to the django_tests job for example.

conf/archimedes.default.ini

A default-ish config which we can re-use in CI and local development.

.gitlab-ci.yml

Move default before_script python setup tasks to a python-specific extends usage, so they only run on jobs which require it; switch from custom PIP_TRUSTED_HOSTS to Pip's config variable PIP_TRUSTED_HOST (so close!); add image build job.

.gitignore

Ignore some local dev tools (gitlab-ci-local, .idea) configuration.