Skip to content

Commit a4d3c11

Browse files
authored
feat(demo): add public demo deployment infrastructure (#18)
feat(demo): add public demo deployment infrastructure and OCI automation Add a complete public demo environment at https://nexuslims-demo.datasophos.co, including deployment automation, curated fixture data, and UI customizations. Key additions: - Demo Docker Compose stack with entrypoint, settings, read-only middleware, and context processors for guest/demo-user experience - 20 curated NexusLIMS XML fixture records with scripts to generate, seed, manage (GitHub Releases), and validate them - GitHub Actions workflow deploying via self-hosted runner on OCI (outbound HTTPS only -- no SSH allowlisting needed) - reset_demo.sh for scheduled 2-hour resets; preserves caddy_data/caddy_config to avoid Let's Encrypt rate limits - Full OCI provisioning guide in DEMO_DEPLOY.md (ARM VM, firewall, runner setup) - Homepage, tiles, detail/list XSLT, and CSS/JS customizations for demo UI - /release Claude command for changelog generation with -nx versioning Bug fixes: - Defer request creation in init_environment.py until after demo users exist - Use docker compose down in reset so volumes can be removed - Remove custom Caddy image build (use upstream image directly) Docs: - Add live demo badge and section to README - Update Django badge to 5.2, CDCS core refs from 2.18.* to 2.20.*
1 parent cb590f9 commit a4d3c11

65 files changed

Lines changed: 31671 additions & 117 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.claude/commands/release.md

Lines changed: 250 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,250 @@
1+
---
2+
allowed-tools: Bash(git:*), Bash(grep:*), Bash(cat:*), Read, Glob
3+
argument-hint: [version] [--dry-run] [--no-push]
4+
description: Prepare a NexusLIMS-CDCS release with intelligent changelog and upgrade instructions for deployment admins
5+
---
6+
7+
# NexusLIMS-CDCS Release Preparation
8+
9+
## Current State
10+
11+
Gather the following before proceeding:
12+
13+
1. **Current version:** Read `pyproject.toml` and extract the `version = "..."` line.
14+
2. **Current branch:** Run `git branch --show-current`.
15+
3. **Last tag:** Run `git describe --tags --abbrev=0`.
16+
4. **Commits since last tag:** Run `git log <last-tag>..HEAD --oneline`.
17+
5. **Files changed since last tag:** Run `git diff <last-tag>..HEAD --name-only | sort`.
18+
19+
Gather all five before proceeding.
20+
21+
---
22+
23+
## Instructions
24+
25+
### Step 1: Analyse Changed Files for Upgrade Impact
26+
27+
Scan the changed file list and categorise each into the buckets below. For any bucket
28+
that has matches, read the actual diff (`git diff <last-tag>..HEAD -- <file>`) to
29+
understand *what* changed so you can write concrete upgrade instructions.
30+
31+
| Bucket | Patterns | Deployment impact |
32+
|---|---|---|
33+
| **XSLT** | `xslt/*.xsl` | Must re-upload stylesheets to database |
34+
| **Schema** | `deployment/schemas/*.xsd` | Must re-upload schema to database |
35+
| **Migrations** | `*/migrations/*.py` | Must run `migrate` (auto on restart, but note it) |
36+
| **Docker image** | `deployment/Dockerfile`, `pyproject.toml`, `uv.lock` | Must rebuild image |
37+
| **Compose config** | `deployment/docker-compose*.yml` | Must restart stack |
38+
| **Env variables** | `deployment/.env.demo.example`, any `settings.py` | Check `.env` for new required variables |
39+
| **Init/seed scripts** | `deployment/scripts/init_environment.py`, `deployment/scripts/seed_demo_records.py` | Note behaviour changes |
40+
| **Caddy / TLS** | `deployment/caddy/Caddyfile*`, `deployment/caddy/docker-entrypoint.sh` | Restart Caddy; TLS config may have changed |
41+
| **Static assets** | `nexuslims_overrides/static/**`, `nexuslims_annotate/static/**` | Run `collectstatic` (auto on restart) |
42+
| **Templates** | `nexuslims_overrides/templates/**`, `nexuslims_annotate/templates/**` | Restart app; no manual step |
43+
| **App code** | `nexuslims_overrides/**`, `nexuslims_annotate/**`, `mdcs/**` | Restart app |
44+
| **Test / CI** | `tests/**`, `.github/**` | No deployment action needed |
45+
46+
For the **XSLT**, **Schema**, and **Env variables** buckets, always read the diff and
47+
describe *exactly* what changed (e.g. new variable names, renamed fields, added
48+
`xsl:variable` blocks).
49+
50+
### Step 2: Draft Upgrade Instructions
51+
52+
Write an **Upgrade Instructions** section for every release, regardless of what
53+
changed. The section always begins with a backup step, followed by any
54+
change-specific steps.
55+
56+
All upgrade instructions must use `admin-commands.sh` aliases where they exist
57+
(source it first: `source deployment/admin-commands.sh`). Fall back to raw Docker
58+
Compose commands only for operations that `admin-commands.sh` does not cover.
59+
Never reference `dev-commands.sh` or `demo-commands.sh` in upgrade instructions.
60+
61+
Available `admin-commands.sh` aliases relevant to upgrades:
62+
- `dc-prod` -- shorthand for `docker compose -f docker-compose.base.yml -f docker-compose.prod.yml`
63+
- `admin-init` -- re-runs `init_environment.py` (re-uploads schema and XSLT to database)
64+
- `admin-backup` -- backs up all CDCS data (templates, records, blobs, users)
65+
66+
**Template for the Upgrade Instructions section:**
67+
68+
```markdown
69+
### Upgrade Instructions
70+
71+
#### 1. Back up your data
72+
Always back up before upgrading:
73+
```bash
74+
cd deployment
75+
source admin-commands.sh
76+
admin-backup
77+
```
78+
79+
#### 2. Pull the new code
80+
```bash
81+
cd /opt/nexuslims-cdcs
82+
git pull
83+
```
84+
85+
#### 3. [Change-specific steps — include only the subsections that apply]
86+
87+
##### Rebuild Required
88+
(Include if Dockerfile / pyproject.toml / uv.lock changed)
89+
Python dependencies or the container definition changed. Rebuild before restarting:
90+
```bash
91+
cd deployment
92+
source admin-commands.sh
93+
dc-prod build cdcs
94+
```
95+
96+
##### New / Changed Environment Variables
97+
(Include if .env.demo.example or settings.py changed; list each variable explicitly)
98+
Add or update the following in your `.env`:
99+
```
100+
NEW_VARIABLE=value
101+
```
102+
103+
##### XSLT Stylesheets Updated
104+
(Include if xslt/*.xsl changed; describe what changed)
105+
Re-upload the updated stylesheets to the database after restarting:
106+
```bash
107+
cd deployment
108+
source admin-commands.sh
109+
admin-init
110+
```
111+
Or to update only XSLT without a full re-init:
112+
```bash
113+
docker exec ${COMPOSE_PROJECT_NAME}_cdcs bash /srv/scripts/update-xslt.sh
114+
```
115+
116+
##### Schema Updated
117+
(Include if deployment/schemas/*.xsd changed; describe what changed)
118+
Re-upload the updated schema to the database:
119+
```bash
120+
cd deployment
121+
source admin-commands.sh
122+
admin-init
123+
```
124+
125+
#### 4. Restart the stack
126+
```bash
127+
cd deployment
128+
source admin-commands.sh
129+
dc-prod down && dc-prod up -d
130+
```
131+
```
132+
133+
If the only changes are in Test / CI / app code / templates (no rebuild, no env
134+
changes, no schema/XSLT changes), the Upgrade Instructions section still includes
135+
steps 1, 2, and 4 -- just omit step 3.
136+
137+
### Step 3: Draft Release Notes
138+
139+
Write complete release notes using this structure. Do not hard-wrap long lines.
140+
141+
````markdown
142+
## NexusLIMS-CDCS vX.Y.Z
143+
144+
### Highlights
145+
(2–4 sentence plain-English summary of the most important changes, written for
146+
deployment admins, not developers)
147+
148+
As always, if you need assistance with configuration or deployment of NexusLIMS-CDCS,
149+
contact [Datasophos](https://datasophos.co/#contact).
150+
151+
### Upgrade Instructions
152+
(Always include -- see Step 2 template above)
153+
154+
### New Features
155+
(User- or admin-facing features; reference PR numbers where available)
156+
157+
### Bug Fixes
158+
(Bug fixes; reference PR numbers where available)
159+
160+
### Internal / Maintenance
161+
(Dependency bumps, CI changes, refactors -- one line each)
162+
163+
### Full Changelog
164+
https://github.com/datasophos/NexusLIMS-CDCS/compare/vPREV...vNEXT
165+
````
166+
167+
Base the content strictly on the commits and diffs gathered -- do not invent changes.
168+
169+
### Step 4: Determine the Version Number
170+
171+
**Version scheme for this project:**
172+
173+
- The version tracks the upstream CDCS/MDCS base: `3.20.0` means CDCS 3.20.0.
174+
- NexusLIMS-specific changes on top of a CDCS release use a `-nx` suffix:
175+
`3.20.0-nx1`, `3.20.0-nx2`, etc.
176+
- `pyproject.toml` stores the version in PEP 440 local form (e.g. `3.20.0+nx1`);
177+
git tags use the hyphen form (e.g. `v3.20.0-nx1`).
178+
179+
**Version bumping rules** (apply in order):
180+
181+
1. If the user supplied a version argument (e.g. `/release 3.21.0-nx1`), use it
182+
exactly and skip the rules below.
183+
184+
2. Check whether the CDCS/MDCS base packages changed since the last tag (look for
185+
bumped `core_*_app` versions in the `pyproject.toml` diff):
186+
- **Yes** → new version is `{NEW_CDCS_VERSION}-nx0` (e.g. `3.21.0-nx0`).
187+
- **No** → increment the `-nx` counter. If the current version has no `-nx` suffix
188+
(e.g. `3.20.0`), the new version is `3.20.0-nx1`. If it already has one (e.g.
189+
`3.20.0-nx1`), increment to `3.20.0-nx2`.
190+
191+
3. If the current `pyproject.toml` version contains `.devN` or `+devN`, strip the dev
192+
suffix before applying rule 2.
193+
194+
Present the suggested version and ask the user to confirm or change it.
195+
196+
### Step 5: User Review
197+
198+
Present the full release notes and proposed version. Ask the user to:
199+
1. Review and approve the release notes
200+
2. Confirm the version number
201+
202+
Do not proceed to Step 6 until the user explicitly approves.
203+
204+
### Step 6: Apply the Release
205+
206+
Once approved, and unless `--dry-run` was passed:
207+
208+
1. **Update `pyproject.toml`**: Set `version = "<VERSION>"` using the PEP 440 local
209+
form (e.g. `3.20.0+nx1` for tag `v3.20.0-nx1`).
210+
211+
2. **Write `RELEASE_NOTES.md`** to the project root with the approved release notes.
212+
213+
3. **Commit both files:**
214+
```bash
215+
git add pyproject.toml RELEASE_NOTES.md
216+
git commit -m "chore: release vVERSION"
217+
```
218+
219+
4. **Tag the release** (hyphen form):
220+
```bash
221+
git tag -a vVERSION -m "Release vVERSION"
222+
```
223+
224+
5. **Push** (unless `--no-push` was passed):
225+
```bash
226+
git push origin main
227+
git push origin vVERSION
228+
```
229+
230+
### Step 7: Post-Release Checklist
231+
232+
After completing Step 6:
233+
234+
- Check GitHub Actions: https://github.com/datasophos/NexusLIMS-CDCS/actions
235+
- The demo server will auto-deploy via the self-hosted runner on push to `main`
236+
- Verify the GitHub Release was created at: https://github.com/datasophos/NexusLIMS-CDCS/releases
237+
- If XSLT or schema changed, verify the update applied on the demo server:
238+
```bash
239+
docker logs nexuslims_demo_cdcs | grep -E "(stylesheet|schema|XSLT|Schema)"
240+
```
241+
242+
---
243+
244+
## Quick Reference: Version Scheme
245+
246+
| Scenario | `pyproject.toml` | git tag |
247+
|---|---|---|
248+
| First NexusLIMS changes on CDCS 3.20.0 | `3.20.0+nx1` | `v3.20.0-nx1` |
249+
| Second patch on 3.20.0 | `3.20.0+nx2` | `v3.20.0-nx2` |
250+
| Upgrade to CDCS 3.21.0 | `3.21.0+nx0` | `v3.21.0-nx0` |

0 commit comments

Comments
 (0)