Add deterministic source release packaging
This commit is contained in:
+9
-5
@@ -16,15 +16,19 @@ The MongoDB initialization script runs only on a new volume. Changing `.env` lat
|
||||
|
||||
GuestOps follows the CMS/CMSFront deployment pattern: Gitea stores the application source, a specific committed version is compressed, and a version-selected Ansible playbook installs it. No Gitea Actions runner is required.
|
||||
|
||||
On the trusted packaging machine, run the automated checks, select the full commit SHA, and create the archive from that committed tree rather than from a working directory:
|
||||
On the trusted packaging machine, fetch the current remote refs, run the automated checks, select the full commit SHA, and create the archive from that committed tree rather than from a working directory:
|
||||
|
||||
```sh
|
||||
git archive --format=tar.gz --prefix=GuestOps-0.2.0/ \
|
||||
--output GuestOps-0.2.0.tar.gz FULL_40_CHARACTER_SHA
|
||||
sha256sum GuestOps-0.2.0.tar.gz > GuestOps-0.2.0.tar.gz.sha256
|
||||
git fetch origin --prune --tags
|
||||
git rev-parse origin/main
|
||||
python3 deploy/package_source.py \
|
||||
--ref FULL_40_CHARACTER_SHA \
|
||||
--output-directory /secure/release-staging
|
||||
```
|
||||
|
||||
Store the archive and checksum under a versioned GuestOps files directory in the private Ansible repository. The GuestOps playbook and environment variables should select that version, copy and verify the archive, extract it into the application directory, preserve the private `.env` and provider configuration, and build images tagged with the full source commit:
|
||||
The packaging command resolves the ref to a full commit, reads both application versions from that committed tree, requires them to match, creates deterministic gzip output, and writes a `.source.json` record containing the version, commit, filename, size and SHA-256. Existing package files are never overwritten. Independently confirm that the selected commit is the intended release line before transferring it.
|
||||
|
||||
Store the archive and source record under a versioned GuestOps files directory in the private Ansible repository. The GuestOps playbook and environment variables should select that version, verify the archive against the source record, extract it into the application directory, preserve the private `.env` and provider configuration, and build images tagged with the full source commit:
|
||||
|
||||
```sh
|
||||
docker build --target api -t guestops-api:FULL_40_CHARACTER_SHA .
|
||||
|
||||
+11
-4
@@ -4,17 +4,24 @@ The owner-only **Workspace health** page reports database reachability, the work
|
||||
|
||||
## Release evidence and rollback
|
||||
|
||||
Create the release source archive from an exact committed Gitea tree with `git archive`, then verify its SHA-256 before Ansible installs it. Ansible builds the API and worker images under the full Git commit SHA. The accompanying `release-record.json` binds the source-archive checksum, application version, commit, image references and immutable Docker image IDs. Retain the archive, checksum, record and Ansible result together in restricted off-host release storage.
|
||||
Create the release source archive from an exact committed Gitea tree with `deploy/package_source.py`, then verify its generated source record before Ansible installs it. The tool packages only the selected commit, produces deterministic gzip output, rejects version disagreement, and refuses to overwrite an existing release. Ansible builds the API and worker images under the full Git commit SHA. The post-build `release-record.json` binds the source-archive checksum, application version, commit, image references and immutable Docker image IDs. Retain the archive, source record, release record and Ansible result together in restricted off-host release storage.
|
||||
|
||||
Before deployment, verify the archive against its record without loading it:
|
||||
```sh
|
||||
git fetch origin --prune --tags
|
||||
python3 deploy/package_source.py \
|
||||
--ref FULL_40_CHARACTER_SHA \
|
||||
--output-directory /secure/release-staging
|
||||
```
|
||||
|
||||
Before deployment, verify the archive against its source record:
|
||||
|
||||
```sh
|
||||
python3 - <<'PY'
|
||||
import hashlib, json, pathlib
|
||||
r = json.load(open('release-record.json', encoding='utf-8'))
|
||||
r = json.load(open('GuestOps-0.2.0-COMMIT.source.json', encoding='utf-8'))
|
||||
p = pathlib.Path(r['artifact']['name'])
|
||||
assert hashlib.sha256(p.read_bytes()).hexdigest() == r['artifact']['sha256']
|
||||
print(r['commit'], r['version'], r['images'])
|
||||
print(r['commit'], r['version'], r['artifact'])
|
||||
PY
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user