|
| 1 | +### BASIL Apache deployment |
| 2 | + |
| 3 | +This folder contains helper scripts to deploy BASIL (API + Frontend) behind Apache on a Debian/Ubuntu host. |
| 4 | + |
| 5 | +Scripts expect configuration via a local `.env` file, then you run `run.sh` to provision PostgreSQL, build and configure the API (mod_wsgi) and the frontend under Apache. |
| 6 | + |
| 7 | +--- |
| 8 | + |
| 9 | +### Prerequisites |
| 10 | + |
| 11 | +- Run on a Debian/Ubuntu system with `systemd` and `apt`. |
| 12 | +- A user with sudo privileges and outbound Internet access. |
| 13 | +- Open TCP ports for the API and APP (defaults: 5000 and 9000). |
| 14 | + |
| 15 | +The scripts will install required packages (Apache, PostgreSQL, Python, Node toolchain) if missing. |
| 16 | + |
| 17 | +--- |
| 18 | + |
| 19 | +### Configure .env |
| 20 | + |
| 21 | +It is sourced by bash, so stick to `KEY=VALUE` and use quotes if values contain spaces. |
| 22 | + |
| 23 | +Required/commonly used variables: |
| 24 | + |
| 25 | +- BASIL_SERVER_NAME: public hostname or IP used in Apache vhosts |
| 26 | +- BASIL_SERVER_ALIAS: optional additional host alias |
| 27 | +- BASIL_SERVER_ADMIN: admin email for Apache configs |
| 28 | +- BASIL_API_PORT: API Apache vhost port (default 5000) |
| 29 | +- BASIL_APP_PORT: Frontend Apache vhost port (default 9000) |
| 30 | +- BASIL_ADMIN_PASSWORD: password of BASIL admin user created by default |
| 31 | +- BASIL_DB_PASSWORD: PostgreSQL user password used during DB init |
| 32 | +- BASIL_TESTING: 1 to use a `test` DB instead of `basil` (default 0) |
| 33 | +- BASIL_TEST_RUNS_BASE_DIR: base dir for tmt test runs (default `/var/basil/test-runs`) |
| 34 | +- BASIL_GITCLONE: 1 = force fresh clone to `/tmp/basil`, 0 = reuse if present (default 1) |
| 35 | +- BASIL_GITGOBACK: number of commits to revert from HEAD (default 0) |
| 36 | +- BASIL_COMMITBEFORE: ISO8601 date used only when `BASIL_GITGOBACK < 0` (e.g. `2025-01-01 00:00:00 +0000`) |
| 37 | +- BASIL_RESET_POSTGRES_CLUSTERS: 1 to wipe/recreate all local Postgres clusters (DANGEROUS), -1 to skip (default) |
| 38 | + |
| 39 | +Example `.env` you can copy and adjust: |
| 40 | + |
| 41 | +```bash |
| 42 | +# Apache vhost details |
| 43 | +BASIL_SERVER_NAME="your.host.name" |
| 44 | +BASIL_SERVER_ALIAS="your.host.alias" |
| 45 | +BASIL_SERVER_ADMIN= "[email protected]" |
| 46 | + |
| 47 | +# Ports |
| 48 | +BASIL_API_PORT=5000 |
| 49 | +BASIL_APP_PORT=9000 |
| 50 | + |
| 51 | +# BASIL runtime |
| 52 | +BASIL_ADMIN_PASSWORD="ChangeMe_Strong_Admin_Password" |
| 53 | +BASIL_TEST_RUNS_BASE_DIR="/var/basil/test-runs" |
| 54 | +BASIL_TESTING=0 |
| 55 | + |
| 56 | +# Database |
| 57 | +BASIL_DB_PASSWORD="ChangeMe_Strong_DB_Password" |
| 58 | +BASIL_RESET_POSTGRES_CLUSTERS=-1 |
| 59 | + |
| 60 | +# Git checkout behavior for building |
| 61 | +BASIL_GITCLONE=1 |
| 62 | +BASIL_GITGOBACK=0 |
| 63 | +# Only used if BASIL_GITGOBACK < 0 |
| 64 | +BASIL_COMMITBEFORE="2025-01-01 00:00:00 +0000" |
| 65 | +``` |
| 66 | + |
| 67 | +Notes: |
| 68 | +- Passwords are required: set both `BASIL_ADMIN_PASSWORD` and `BASIL_DB_PASSWORD`. |
| 69 | +- Use quotes for values with special characters. |
| 70 | + |
| 71 | +--- |
| 72 | + |
| 73 | +### Run the deployment |
| 74 | + |
| 75 | +From this folder: |
| 76 | + |
| 77 | +```bash |
| 78 | +sudo ./run.sh |
| 79 | +``` |
| 80 | + |
| 81 | +Why sudo? The scripts write under `/var/www`, `/etc/apache2`, manage services, and change ownership to `www-data`. |
| 82 | + |
| 83 | +What `run.sh` does: |
| 84 | +- Installs required packages via apt |
| 85 | +- Initializes PostgreSQL (`init_postgresql.sh`) |
| 86 | +- Builds and configures the API for Apache/mod_wsgi (`build_basil_api.sh`) |
| 87 | +- Builds the frontend, configures Apache static vhost with React router rewrite (`build_basil_frontend.sh`) |
| 88 | + |
| 89 | +Artifacts and logs in this folder: |
| 90 | +- `init_postgresql.log` |
| 91 | +- `build_basil_api.log` |
| 92 | +- `build_basil_frontend.log` |
| 93 | + |
| 94 | +--- |
| 95 | + |
| 96 | +### Verify |
| 97 | + |
| 98 | +- API version endpoint: `http://<BASIL_SERVER_NAME>:<BASIL_API_PORT>/version` |
| 99 | +- Frontend version: `http://<BASIL_SERVER_NAME>:<BASIL_APP_PORT>/version` |
| 100 | + |
| 101 | +Both checks are executed automatically at the end of the respective scripts and reported in the logs. |
| 102 | + |
| 103 | +--- |
| 104 | + |
| 105 | +### Troubleshooting |
| 106 | + |
| 107 | +- Ports already in use: adjust `BASIL_API_PORT` / `BASIL_APP_PORT` in `.env` and re-run. |
| 108 | +- Wrong hostname: update `BASIL_SERVER_NAME` (and optional alias) and re-run. |
| 109 | +- PostgreSQL reset: set `BASIL_RESET_POSTGRES_CLUSTERS=1` only if you understand it will drop existing clusters. |
| 110 | +- Rebuild from a clean checkout: set `BASIL_GITCLONE=1`. |
| 111 | + |
| 112 | + |
0 commit comments