249 lines
10 KiB
Markdown
249 lines
10 KiB
Markdown
# Local development
|
|
|
|
Use Python 3.12 or later. From the repository root, install the panel and its
|
|
development tools in a virtual environment.
|
|
|
|
```sh
|
|
python3 -m venv .venv
|
|
. .venv/bin/activate
|
|
python -m pip install -e '.[dev]'
|
|
export COULOBRE_SECRET_KEY="$(python -c 'from django.core.management.utils import get_random_secret_key; print(get_random_secret_key())')"
|
|
export COULOBRE_DEBUG=1
|
|
python manage.py migrate
|
|
python manage.py createsuperuser
|
|
python manage.py runserver
|
|
```
|
|
|
|
Open <http://127.0.0.1:8000/> and sign in with the administrator account.
|
|
Select **Add hosting account** and enter a name and a primary domain such as
|
|
`example.org`. Open an account from the list to edit its details or request an
|
|
Apache preview. Manage users, groups, and permissions at `/admin/`.
|
|
|
|
Use **Hosting plans** to add named plans with an optional description. Choose a
|
|
plan when creating or editing an account. Existing accounts start unassigned.
|
|
Operators need permission to view hosting plans before they can assign one.
|
|
|
|
## Give a reseller access to assigned accounts
|
|
|
|
In `/admin/`, create a normal user and add a **Reseller** record for that user.
|
|
Then open a hosting account in Coulobre Panel and select the reseller when
|
|
editing the account. Existing accounts start with no reseller assigned.
|
|
|
|
The reseller can sign in to Coulobre Panel to see their assigned accounts,
|
|
each account's hosting plan, and its web provisioning previews.
|
|
|
|
To let the reseller add accounts, set a positive account limit and select the
|
|
available hosting plans in the reseller's admin record. The reseller's account
|
|
list shows their allowance. The limit applies to self-service creation, and
|
|
operator assignments also count toward the allowance. New reseller accounts
|
|
automatically belong to that reseller and require an allowed plan. A limit of
|
|
zero keeps the reseller's access read-only.
|
|
|
|
Platform operators manage existing accounts, assignments, reseller allowances,
|
|
and node deployment files.
|
|
|
|
The local database defaults to `db.sqlite3`. Set `COULOBRE_SQLITE_PATH` to use a
|
|
different file. Keep `COULOBRE_DEBUG` for local development.
|
|
|
|
## Request a MariaDB database
|
|
|
|
Open a hosting account and select **Request database**. Choose a short suffix
|
|
such as `wordpress`. The panel derives the full database name from the account
|
|
ID and suffix, so two accounts can each request a database named `wordpress`.
|
|
|
|
The account page shows the requested databases. Operators can download a
|
|
versioned deployment manifest containing the account ID and suffix. Resellers
|
|
can view the requested database names on their own assigned accounts. The
|
|
manifest describes the database to provision on a MariaDB node.
|
|
|
|
Use the installed node command to validate the manifest and display the derived
|
|
database and login names.
|
|
|
|
```sh
|
|
coulobre-database-node inspect coulobre-database-1.json
|
|
```
|
|
|
|
### Apply a database manifest
|
|
|
|
Use a local MariaDB server with Unix socket authentication for
|
|
`root@localhost`. Install Coulobre with the `mariadb` extra in a root-owned
|
|
virtual environment and apply the downloaded manifest on that server.
|
|
|
|
```sh
|
|
sudo /opt/coulobre/bin/coulobre-database-node apply coulobre-database-1.json
|
|
```
|
|
|
|
The default socket is `/run/mysqld/mysqld.sock`. Use `--socket` for a different
|
|
local socket. The command creates a UTF-8 database and one login at
|
|
`localhost` with privileges on that exact database.
|
|
|
|
The command reports the path to a root-only credentials file under
|
|
`/var/lib/coulobre/database-node/`. Use those credentials when configuring the
|
|
application. Reapplying a manifest preserves the existing password and can
|
|
complete an interrupted first installation. Coulobre uses its local registry
|
|
and a database ownership marker to distinguish managed databases from existing
|
|
resources.
|
|
|
|
### Check a database installation
|
|
|
|
Run the following command on the MariaDB node with the same manifest and socket
|
|
used for installation.
|
|
|
|
```sh
|
|
sudo /opt/coulobre/bin/coulobre-database-node status coulobre-database-1.json
|
|
```
|
|
|
|
The read-only check verifies the local registry, the database ownership marker
|
|
and the application's direct MariaDB grants. It then connects over the local
|
|
socket with the stored application credentials and selects the database. The
|
|
JSON report includes the database and login names, the state, and a diagnostic
|
|
message when the installation needs attention.
|
|
|
|
| State | Exit code | Meaning |
|
|
| --- | --- | --- |
|
|
| `configured` | 0 | All checks passed. |
|
|
| `not_installed` | 2 | The registry, database, and login are absent. |
|
|
| `needs_attention` | 2 | An installation is incomplete or differs from the expected configuration. |
|
|
|
|
Exit code `1` indicates an invalid manifest or an unavailable check, for example
|
|
when the MariaDB administrative connection fails.
|
|
|
|
## Request an Apache configuration preview
|
|
|
|
Start RabbitMQ and set `COULOBRE_BROKER_URL` to its AMQP URL. The development
|
|
default is `amqp://guest:guest@127.0.0.1:5672//`. Use the same database and
|
|
broker settings for the panel, worker, and scheduler.
|
|
|
|
In separate terminals with the virtual environment active, start a worker
|
|
and a scheduler. Use one worker process with SQLite.
|
|
|
|
```sh
|
|
celery -A coulobre worker --pool=solo
|
|
celery -A coulobre beat
|
|
```
|
|
|
|
Open an account in **Hosting accounts** and select **Request Apache preview**.
|
|
The preview page shows the request status and the configuration once the worker
|
|
finishes. Use **Refresh status** for pending requests or **Web provisioning** to
|
|
find earlier previews. Each request captures the primary domain at queue time.
|
|
The preview references the future document root and PHP-FPM socket for the
|
|
account. Preview generation makes no changes to the hosting services.
|
|
|
|
The panel stores requests in its database before the scheduler publishes work
|
|
to RabbitMQ. After a broker outage, queued requests resume when the worker and
|
|
scheduler reconnect. Plans that remain incomplete five minutes after dispatch
|
|
are eligible for delivery again.
|
|
|
|
## Render configuration on a web node
|
|
|
|
Open a completed preview for the account's current domain and select **Download
|
|
deployment manifest**. The versioned JSON file contains the account ID and
|
|
primary domain. The web node command validates those values and derives the
|
|
system user, document root, and PHP-FPM socket from the account ID.
|
|
|
|
Install the panel package on the node at the same revision as the panel that
|
|
created the manifest. The command renders configuration to standard output.
|
|
Run it as a regular user in a directory for reviewing the generated files.
|
|
|
|
```sh
|
|
coulobre-web-node render coulobre-web-plan-1.json apache > apache.conf
|
|
coulobre-web-node render coulobre-web-plan-1.json php-fpm > php-fpm.conf
|
|
```
|
|
|
|
The command reads the manifest and packaged templates locally. The isolated
|
|
Ubuntu check below demonstrates loading the configuration.
|
|
|
|
## Apply a manifest on an Ubuntu web node
|
|
|
|
Use a dedicated Ubuntu 26.04 node with Apache and PHP 8.5 FPM installed from
|
|
the distribution packages. Enable FastCGI in Apache and start the native
|
|
services before applying a manifest.
|
|
|
|
```sh
|
|
sudo apt install apache2 php8.5-fpm
|
|
sudo a2enmod proxy_fcgi
|
|
sudo service php8.5-fpm start
|
|
sudo service apache2 restart
|
|
```
|
|
|
|
Install the matching Coulobre package in a root-owned virtual environment on
|
|
the node. Review the completed preview and transfer its deployment manifest
|
|
to the node. Apply it with the node operator account.
|
|
|
|
```sh
|
|
sudo /opt/coulobre/bin/coulobre-web-node apply coulobre-web-plan-1.json
|
|
```
|
|
|
|
The command reserves the account ID and domain on the node, creates a system
|
|
user and a document root under `/srv/coulobre/web/<account-id>/public`, and
|
|
installs Apache and PHP-FPM configuration. It validates both configurations,
|
|
reloads PHP-FPM, waits for the per-site socket, then reloads Apache.
|
|
|
|
Reapply the same manifest to retry or verify an existing installation. The
|
|
node checks the account registry for domain conflicts and protects existing
|
|
configuration files. If a configuration check or reload fails, the command
|
|
removes the configuration it added. It reloads the prior configuration for
|
|
affected services and reports any recovery errors. The account reservation and
|
|
document root stay available for the next attempt.
|
|
|
|
Check the local deployment state with the same manifest.
|
|
|
|
```sh
|
|
sudo /opt/coulobre/bin/coulobre-web-node status coulobre-web-plan-1.json
|
|
```
|
|
|
|
The JSON report includes the manifest identity and one of three states.
|
|
|
|
- `configured` means the reservation, Unix account, document root, service
|
|
configuration, running services, and PHP-FPM socket match the manifest.
|
|
- `not_installed` means the node has no reservation for the account.
|
|
- `needs_attention` includes the first mismatch or service problem found.
|
|
|
|
The status command reads local state. It exits with code 0 for `configured`,
|
|
code 2 for the other report states, and code 1 if it cannot read the manifest
|
|
or inspect the node. Use an HTTP request to verify the site's response as well.
|
|
|
|
## Run an isolated PHP test site
|
|
|
|
Open a completed preview for the account's current domain and select **Download
|
|
test bundle**. The archive contains the exact Apache preview, a matching PHP-FPM
|
|
pool, site metadata, and a small PHP test page. It is intended for the isolated
|
|
Ubuntu check below.
|
|
|
|
Run the test with Docker from the repository root. Set the bundle path to the
|
|
downloaded tar archive.
|
|
|
|
```sh
|
|
docker build -t coulobre-web-smoke tests/web-node
|
|
bundle="$PWD/coulobre-web-plan-1.tar"
|
|
docker run --rm --network none \
|
|
--mount "type=bind,src=$bundle,dst=/test/site.tar,readonly" \
|
|
coulobre-web-smoke
|
|
```
|
|
|
|
The Ubuntu container installs a system user for the site, checks the Apache and
|
|
PHP-FPM configurations, and makes an HTTP request with the account's primary
|
|
domain. A passing check confirms PHP execution through the generated socket.
|
|
The container uses its own filesystem and loopback interface.
|
|
|
|
## MariaDB
|
|
|
|
Create a dedicated MariaDB database and application user. Install the MariaDB or
|
|
MySQL client headers, Python headers, a C compiler, and `pkg-config`, then add
|
|
the database driver with `python -m pip install -e '.[dev,mariadb]'`.
|
|
|
|
Set `COULOBRE_DB_NAME`, `COULOBRE_DB_USER`, and `COULOBRE_DB_PASSWORD` for your
|
|
database and rerun `python manage.py migrate`. Set `COULOBRE_DB_HOST` and
|
|
`COULOBRE_DB_PORT` if the database uses a different address from `127.0.0.1:3306`.
|
|
|
|
## Checks
|
|
|
|
```sh
|
|
ruff check .
|
|
ruff format --check .
|
|
python manage.py check
|
|
python manage.py makemigrations --check --dry-run
|
|
python manage.py test coulobre
|
|
git diff --check
|
|
```
|