CJVT updates August and September 2026
This commit is contained in:
@@ -52,20 +52,21 @@ Alternatively, set your own preferred log aggregator as per [the official docume
|
||||
2. Navigate into that directory and copy the _.env_ file from the _dev_ folder one level up (into the root directory of the portal).
|
||||
3. Open the copied _.env_ file in a text editor and adjust the parameters of your portal.
|
||||
|
||||
### 4. (Advanced/optional) Adjust data storage locations
|
||||
### 4. (Advanced/optional) Adjust data storage locations or other host-specific settings
|
||||
|
||||
By default, all data is stored and persisted inside Docker's [volumes](https://docs.docker.com/storage/volumes/)
|
||||
on your host's root partition.
|
||||
If you have a setup where for any reason you want to store data elsewhere,
|
||||
you can reconfigure the docker-compose.prod.yml to use [bind mounts](https://docs.docker.com/storage/bind-mounts/),
|
||||
just be mindful not to break shared volume dependencies.
|
||||
|
||||
_Using bind mounts has not been tested yet and might cause additional complications
|
||||
regarding file system permissions._
|
||||
on your host's root partition. If you have a setup where for any reason you want to store data
|
||||
elsewhere, e.g. using [bind mounts](https://docs.docker.com/storage/bind-mounts/), or need other
|
||||
host-specific tweaks (resource limits, etc.), do **not** edit docker-compose.prod.yml directly.
|
||||
Instead, copy docker-compose.prod.override.example.yml to docker-compose.prod.override.yml next to
|
||||
it and adjust only the keys that need to differ on this host. `./run-prod.sh` (see next step)
|
||||
automatically layers this override file in when present, so it never needs to be manually re-applied
|
||||
after pulling changes to docker-compose.prod.yml. docker-compose.prod.override.yml is gitignored on
|
||||
purpose — it's host-specific and shouldn't be tracked or committed.
|
||||
|
||||
### 5. Start the portal service cluster
|
||||
|
||||
1. Inside the portal directory, run the following command in CLI: `docker compose -f docker-compose.prod.yml --profile concordancer-manager up -d --build`
|
||||
1. Inside the portal directory, run the following command in CLI: `./run-prod.sh --profile concordancer-manager up -d --build`
|
||||
2. It's going to take some time for all the resources to get downloaded and built.
|
||||
Wait for control to be returned to CLI before continuing.
|
||||
|
||||
@@ -121,6 +122,97 @@ Same as above, except replace <CONCORDANCER_LISTEN_PORT> with the value of CONCO
|
||||
|
||||
Your portal should now be available at whichever address/domain your reverse proxy is set to listen to.
|
||||
|
||||
## Automated deployment (CI/CD)
|
||||
|
||||
The generic guide above builds images on the host with `up -d --build`. For a maintainer who
|
||||
runs one or more long-lived environments (e.g. staging + production VPSs), there is an automated
|
||||
pipeline built on **Gitea Actions** and the **Gitea container registry**. It builds the three
|
||||
custom images (`express`, `opensearch`, `concordancer`) once, pushes them to the registry, and
|
||||
each host **pulls** them instead of building — no more copying files around or building on the VPS.
|
||||
|
||||
**Flow:**
|
||||
|
||||
- Push to the default branch → CI builds + pushes images tagged `sha-<short>` → auto-deploys to **staging**.
|
||||
- Push a version tag `vX.Y.Z` → CI **promotes** the exact staging-tested images to that tag (no
|
||||
rebuild) → deploys to **production**. Pushing the tag is the deliberate human release gate.
|
||||
- Rollback / ad-hoc deploy → run the **deploy-dispatch** workflow with a previous tag.
|
||||
|
||||
The pieces live in the repo:
|
||||
|
||||
- `docker-compose.prod.yml` — each built service has both an `image:` (registry ref, via
|
||||
`${REGISTRY}`/`${IMAGE_TAG}`) and its `build:` block. Unset, the vars default to a local name so
|
||||
the generic `up --build` path still works untouched.
|
||||
- `.gitea/workflows/build-and-stage.yml`, `release-prod.yml`, `deploy-dispatch.yml`.
|
||||
- `dev/ci/build.sh` (buildx build + push, registry layer cache), `dev/ci/promote.sh` (retag
|
||||
without rebuild), `dev/ci/deploy.sh` (runner side: SSH the target the tag to deploy),
|
||||
`dev/ci/ci-deploy-wrapper.sh` (host side: the forced command that validates the tag and runs
|
||||
`git checkout` + `run-prod.sh pull` + `up -d`). The CI key is pinned to that wrapper, so a leaked
|
||||
key can only ever trigger a tag deploy on one host — never an arbitrary command
|
||||
(see [`dev/ci/README.md`](dev/ci/README.md#hardened-deploy-access)).
|
||||
|
||||
### One-time setup
|
||||
|
||||
1. **Enable Gitea Actions** and confirm the **container registry** is on (both are usually default
|
||||
in recent Gitea).
|
||||
2. **Register a runner.** On a build host — ideally a machine that is _not_ your public production
|
||||
server but has Docker, disk, and internet (the concordancer build downloads a large lexicon) —
|
||||
install the **Gitea Runner** (`gitea/runner`; formerly `act_runner`) and register it repo-scoped
|
||||
with the `self-hosted` label the workflows target. The runner only needs outbound reachability to
|
||||
Gitea and SSH reachability to the deploy hosts. Full step-by-step + smoke tests:
|
||||
[`dev/ci/README.md`](dev/ci/README.md).
|
||||
3. **Prepare each target host (staging, prod):**
|
||||
- Create a dedicated `deploy` user (keeps automation out of your personal account and gives
|
||||
clean audit/revocation); add it to the `docker` group.
|
||||
- `git clone` the repo to a stable path, e.g. `/opt/termportal-staging` or `/opt/termportal-prod`.
|
||||
- Put the host-only `.env` (with `REGISTRY=<gitea-host>/<owner>` set) and, if used,
|
||||
`docker-compose.prod.override.yml` in that directory. Both are gitignored, so `git checkout`
|
||||
during deploys never touches them.
|
||||
- `docker login <gitea-host>` once with a **read-only** registry token so `pull` works.
|
||||
- Install the **hardened deploy key + forced-command wrapper** — full commands in
|
||||
[`dev/ci/README.md`](dev/ci/README.md#hardened-deploy-access). In short: a **dedicated** CI
|
||||
keypair (never your personal key), its public half pinned in the deploy user's
|
||||
`authorized_keys` with `from="<runner-ip>",restrict,command="…/ci-deploy-wrapper.sh"`, and its
|
||||
private half stored as the Gitea secret below.
|
||||
- Do the first-time concordancer setup (section 6 above) once, as usual.
|
||||
4. **Add Gitea Actions secrets** (repo → Settings → Actions → Secrets):
|
||||
`REGISTRY_TOKEN` — a Personal Access Token with `write:package` scope, used by CI to push
|
||||
images (the automatic `GITEA_TOKEN` is not authorized to push packages); plus
|
||||
`STAGING_SSH_HOST`, `STAGING_SSH_USER`, `STAGING_SSH_KEY` and the `PROD_*` equivalents; also
|
||||
`STAGING_SSH_PORT` / `PROD_SSH_PORT` if a host's sshd doesn't listen on the default port 22
|
||||
(both default to 22 when unset). (No `*_DIR` secret is needed — each host's wrapper owns its
|
||||
checkout path via `ci-deploy.conf`.)
|
||||
|
||||
### Day-to-day
|
||||
|
||||
- **Deploy to staging:** `git push` to the default branch.
|
||||
- **Release to production:** `git tag -a v1.2.3 -m "…" && git push origin v1.2.3` (tag a commit
|
||||
already built on the default branch, so its `sha-<short>` images exist to promote). Use an
|
||||
**annotated** tag (`-a`), not a lightweight one — this repo's release tags carry a tagger, date,
|
||||
and message as a record of what shipped and why, which a lightweight tag (a bare pointer) doesn't
|
||||
have. Both tag kinds trigger the `release-prod` workflow the same way, since it matches on the ref
|
||||
name (`refs/tags/v*`); this only affects the tag's own metadata, not the deploy.
|
||||
- **Rollback:** run the **deploy-dispatch** workflow with the previous `vX.Y.Z` (or `sha-…`) tag.
|
||||
Note: this rolls back application code only — database/schema changes are forward-only (there is
|
||||
no migration framework), so back up and treat schema changes deliberately.
|
||||
|
||||
### Break-glass manual deploy
|
||||
|
||||
If CI is unavailable, SSH into the host and run the same wrapper the pipeline triggers:
|
||||
|
||||
```bash
|
||||
/home/deploy/ci-deploy-wrapper.sh v1.2.3 # checkout, pull, up -d for that tag
|
||||
```
|
||||
|
||||
Or drive the steps by hand (equivalent):
|
||||
|
||||
```bash
|
||||
cd /opt/termportal-prod
|
||||
git fetch --tags origin && git checkout --force v1.2.3
|
||||
export IMAGE_TAG=v1.2.3 # REGISTRY comes from this host's .env
|
||||
./run-prod.sh pull
|
||||
./run-prod.sh up -d
|
||||
```
|
||||
|
||||
## Linking your instance with others
|
||||
|
||||
1. Using a web browser, navigate to your portal's main page.
|
||||
|
||||
Reference in New Issue
Block a user