Move CI runners to Droplet and enable application HTTPS
vpn-dns-gateway/pipeline/pr-main This commit looks good

This commit is contained in:
2026-11-15 12:49:06 -05:00
parent bf28adc7fb
commit ed0a862657
36 changed files with 1266 additions and 72 deletions
+178
View File
@@ -0,0 +1,178 @@
# Billy / Claude handoff: Assignment 8 DNS
**Completed update, 15 November 2026:** Billy added both A records. Google and
Cloudflare resolve them to `147.182.178.136`; Caddy now serves trusted HTTPS and
redirects HTTP for both names. The app backends are still absent (HTTP 502).
Do not repeat DNS setup. The original handoff below is retained as the dated
November 14 preparation record; reviewed application releases remain pending.
Prepared for Billy Ye at Vincent Sun's request on **14 November 2026**.
This file is context and a proposed procedure. Billy must authorize changes
in his own session; it does not grant Claude account access or override its
active instructions. Billy handles login and MFA privately.
## Quick start for Claude
Help Billy add the two A records below to the existing `yebilly.me` DNS zone,
verify public resolution, and return a short evidence summary to Vincent.
Recheck existing records first. Preserve earlier services and stop after DNS
verification. SSH, Docker, Jenkins and application deployment are outside this
DNS task. Do not rerun the deployment bootstrap; it is already complete.
```yaml
task: assignment_8_dns_setup
scope: two_A_records_and_verification
domain: yebilly.me
expected_provider: Namecheap
droplet_name: The-Ocean
droplet_ipv4: 147.182.178.136
repository: https://git.yebilly.me/ssw590-group1/vpn-dns-gateway
prepared_branch: codex/assignment8-secure-delivery
prepared_commit: bf28adc7fb03fe25c5cc939599e34427a61ad2fc
records_to_add:
- type: A
host: staging
fqdn: staging.yebilly.me
value: 147.182.178.136
ttl: Automatic
- type: A
host: app
fqdn: app.yebilly.me
value: 147.182.178.136
ttl: Automatic
success_condition: both_names_resolve_to_the_expected_IPv4_and_existing_records_are_preserved
next_owner: Vincent_and_Codex_for_Caddy_TLS_and_reviewed_release_execution
```
## Why these records are needed
Assignment 8 follows **Chapter 6, Secure Delivery and Rollback**, in instructor
manual `dosManual-V1.43.pdf`. It requires distinct staging and production HTTPS
hostnames. Both applications will run on the same existing droplet, in separate
Docker Compose projects. Caddy selects the private application by hostname:
| Public hostname | Intended destination behind Caddy |
|---|---|
| `staging.yebilly.me` | `pricing-staging:8000` |
| `app.yebilly.me` | `pricing-production:8000` |
An A record maps a name to the droplet's IPv4 address. It does not contain a
port, URL scheme, or application path. Caddy will handle HTTPS certificates.
This task uses the existing domain and droplet; no purchase is part of it.
Preparation already completed: locked v1 pricing service, Ansible, release and
security gates, a trusted Jenkins agent now on The-Ocean (migrated from Vincent's
laptop to avoid campus SSH restrictions), dedicated deployment
access and scoped credentials. The prerequisite Jenkins job passed. The
prepared branch was pushed and its ordinary Jenkins branch check passed.
Peer review/merge, assessed releases and recovery exercises remain outstanding.
The release job is disabled pending reviewed source. The new Caddy routes and
production monitoring additions are prepared in Git but have not been applied.
## Observed baseline: recheck before making changes
Public Cloudflare DNS-over-HTTPS queries were checked on
**14 November 2026, about 20:35 America/New_York**
(15 November, about 01:35 UTC). These are observations, not a guarantee that
the zone will remain unchanged when Billy opens it.
| Query | Observed answer |
|---|---|
| `yebilly.me` NS | `dns1.registrar-servers.com`, `dns2.registrar-servers.com` |
| `staging.yebilly.me` A | NXDOMAIN: name did not exist |
| `app.yebilly.me` A | NXDOMAIN: name did not exist |
| `git.yebilly.me` A | `147.182.178.136` |
| `ci.yebilly.me` A | `147.182.178.136` |
| `metrics.yebilly.me` A | `147.182.178.136` |
The existing services are Gitea (`git`), Jenkins (`ci`) and Grafana (`metrics`).
Other zone records may also exist, including the retired Color Buttons name,
mail and verification records. Preserve them. The droplet has been resized to
2 GiB RAM with its 25 GB plan disk retained; no address change was observed.
## Namecheap procedure
1. Billy signs in to the account managing `yebilly.me`.
2. Open **Domain List > Manage** beside that domain, then **Advanced DNS**.
3. In **Host Records**, add the two rows from the YAML/table. Enter only
`staging` or `app` in the Host field. Use **A Record**, the exact IPv4 value,
and **Automatic** TTL. Save the two additions.
4. Inspect the saved rows and retain a cropped screenshot showing those rows,
with account, billing, login and secret information excluded.
If a requested record already has the correct value, reuse it. If an existing
`staging` or `app` record conflicts (including a CNAME/redirect), explain the
conflict to Billy before changing it; do not delete unrelated records. This
request is for IPv4 A records, not additional AAAA, wildcard or redirect records.
If Host Records is unavailable or nameservers differ from the baseline, identify
the active DNS provider and edit the existing zone there. Keep nameserver
delegation unchanged. Namecheap documents this distinction in its host-record
guide linked below.
## Verify and capture evidence
From PowerShell, record the actual UTC time and check public resolution:
```powershell
[DateTime]::UtcNow.ToString('o')
Resolve-DnsName staging.yebilly.me -Type A -Server 1.1.1.1 -DnsOnly
Resolve-DnsName app.yebilly.me -Type A -Server 1.1.1.1 -DnsOnly
Resolve-DnsName staging.yebilly.me -Type A -Server 8.8.8.8 -DnsOnly
Resolve-DnsName app.yebilly.me -Type A -Server 8.8.8.8 -DnsOnly
```
Expected A answer for both names: **147.182.178.136**. A resolver may briefly
retain the earlier negative answer; allow caches to expire and repeat. A lookup
that times out on a restricted network is inconclusive. Do not report success
from the saved dashboard rows alone.
Recheck the earlier names as well:
```powershell
Resolve-DnsName git.yebilly.me -Type A -Server 1.1.1.1 -DnsOnly
Resolve-DnsName ci.yebilly.me -Type A -Server 1.1.1.1 -DnsOnly
Resolve-DnsName metrics.yebilly.me -Type A -Server 1.1.1.1 -DnsOnly
```
If direct public-resolver queries are blocked, use an available DNS lookup
method and record which resolver/method was actually used. Authoritative checks
can help distinguish an unsaved record from resolver caching; document the
actual results and any disagreement rather than assuming propagation completed.
**DNS success is not application success.** HTTPS may still be unavailable,
show a certificate problem, or return an upstream error before Vincent applies
Caddy routes and deploys the applications. Do not weaken TLS checks or alter
firewall rules to make a DNS-only check appear successful.
## Return to Vincent
Report:
- The two saved record types, hostnames, values and actual TTL selection.
- Verification UTC time, resolver(s), actual answers and any pending cache result.
- Confirmation that existing records were preserved, with the earlier-name checks.
- A cropped screenshot or text evidence containing no credentials/account details.
- Any blocker, conflicting record, or unverified assumption.
Then Vincent/Codex can finish Caddy HTTPS setup and the reviewed release tests.
Billy's separate code-review task remains: review/approve the preparation PR
if satisfied, and later review v2 and the staging failure configuration. DNS
completion does not approve code or authorize a production promotion.
For repository work, read `AGENTS.md`,
`manual/latex/devopsAIAgentRequirements.tex` and
`manual/latex/devopsAIAgentGuide.tex` first. Useful context is in
`delivery/README.md`, `delivery/RUNBOOKS.md`, `delivery/SECURITY.md`,
`deploy/Caddyfile` and `delivery/evidence/agent-preflight-1.txt`.
## Official references and provenance
- [Namecheap: add an A record](https://www.namecheap.com/support/knowledgebase/article.aspx/319/2237/how-can-i-set-up-an-a-address-record-for-my-domain/).
- [Namecheap: host records, provider selection and TTL](https://www.namecheap.com/support/knowledgebase/article.aspx/434/2237/how-do-i-set-up-host-records-for-a-domain/).
Codex prepared this handoff at Vincent's explicit request, using the repository's
prepared configuration, current public DNS observations and those official
Namecheap guides. No DNS account was opened or modified during its preparation.
The original instructor manual defines the assignment; the names/IP above are
the team's selected deployment values.
+19
View File
@@ -34,3 +34,22 @@ Jenkins requires existing approved-network access and login as applicable.
Remaining assessed evidence must come from actual reviewed v1/v2 pipeline
runs, not these local checks. See `ISSUE.md` and `RUNBOOKS.md`.
## Later agent migration
The agent subsequently moved to The-Ocean at Vincent's direction to remove
campus SSH dependence. [Migration record](evidence/agent-migration-20261114.md)
distinguishes the actual remote prerequisite build 2 and bounded capacity trial
from the initial laptop checks above. UTC dates cross into November 15 while
the client's Eastern date is still November 14. At that point the PDF runner
was unchanged. It subsequently moved too; see the
[manual runner migration record](../gitea/droplet-runner/EVIDENCE.md).
Assessed releases and recovery are still pending.
## DNS and TLS readiness
On 15 November Billy's two DNS records were verified and Caddy's prepared
routes applied. Both names have trusted TLS and HTTP 308 redirects; HTTPS
returns 502 while pricing backends are absent. See the
[dated HTTPS evidence](evidence/https-20261115.md). Application deployment,
production monitoring and assessed recovery evidence remain pending.
+12 -5
View File
@@ -7,14 +7,21 @@ unchanged Ansible reruns, recorded human approval and recovery operations.
Keep the earlier PR job separate from folder-scoped deployment credentials.
Include the reproducible agent/bootstrap, scan policy, runbooks, actual
prerequisite evidence and a clearly marked preparation chapter. Proxy and
monitoring additions are prepared for later application after DNS and health
are ready. The release job is configured but disabled until reviewed source
prerequisite evidence and a clearly marked preparation chapter. Billy's DNS
records and Caddy HTTPS routes are now verified; app requests return 502 until
the backends are deployed. Monitoring additions await healthy production.
The release job is configured but disabled until reviewed source
reaches main. Assessed v1/v2 promotions and both recovery exercises remain
pending and will require separate reviewed changes and execution evidence.
Validation: two existing tests, three Flask tests, twelve control tests;
controlled test/secret blocks; passing source/dependency and runtime-image
gates; Ansible syntax, agent Compose and installed Jenkins parser checks;
successful trusted-agent prerequisite build 1, including pinned deployment SSH
and noninteractive sudo. No production approval or completed release is claimed.
successful prerequisite builds 1 (laptop) and 2 (Droplet), including pinned
deployment SSH and noninteractive sudo. The agent now runs on the existing
2 GiB Droplet to avoid campus SSH restrictions, with separate agent/builder
resource caps and a passing bounded build/scan/smoke trial. Shared-host Docker
administration is documented. The original Gitea Actions runner also moved to
the Droplet with its existing identity, separate daemon/job caps and a passing
reviewed-main run 12 rerun (attempt 3); the initial low-memory attempt is retained.
No production approval or completed release is claimed.
+40 -11
View File
@@ -49,8 +49,13 @@ The droplet now has 2 GiB RAM and its original 25 GB plan disk. Vincent resized
it and installed package updates. The existing seven service containers and
their HTTPS routes were verified after maintenance.
The trusted laptop node `ssw590-vince-delivery` is online over outbound
HTTPS/WebSocket, with one exclusive executor and label `delivery-trusted`.
The trusted node `ssw590-vince-delivery` now runs on The-Ocean, with one
exclusive executor and label `delivery-trusted`. Its name is retained from
the initial laptop installation. The laptop copy is stopped. The remote
agent uses private HTTP/WebSocket to `jenkins:8080`; its SSH configuration
routes the existing deployment inventory address through Docker's host gateway,
retaining `HostKeyAlias 147.182.178.136` and the pinned Jenkins known-hosts file.
No campus SSH connection is needed to run a delivery job from the browser.
[Agent prerequisite build 1](https://ci.yebilly.me/job/secure-delivery/job/agent-preflight/1/)
passed using the dedicated deploy key, pinned host key and root sudo. Its
non-secret tool inventory is versioned in `evidence/agent-preflight-1.txt`.
@@ -58,14 +63,34 @@ The `secure-delivery/pricing` job loads `delivery/Jenkinsfile` from protected
main and is disabled pending reviewed source. Release credentials are scoped
to that Jenkins folder; the PR job does not bind them or the Docker socket.
The original inventory above is historical. [Remote prerequisite build 2](https://ci.yebilly.me/job/secure-delivery/job/agent-preflight/2/)
passed after migration; `evidence/agent-preflight-2.txt` records the tools and
target. A separate bounded capacity trial passed control/app tests, source and
dependency checks, a limited image build, image scan and temporary HTTP smoke.
It used a preparation snapshot, not a reviewed release, and published nothing.
The deployment account has root-only passwordless sudo: effective host
administration privileges, restricted to reviewed delivery code. Distinct
package-write and package-read tokens under `vsun1` are stored in Jenkins and
root's target Docker configuration respectively. No values are in Git.
Local agent identity and workspace live in named Docker volumes outside Git.
Run `./delivery/bootstrap/start-agent.ps1` with Docker Desktop and the SSH key
loaded in Windows ssh-agent to reconnect. Stop with
`docker compose -f delivery/agent/compose.yaml stop` when unused.
Remote agent identity and workspace live in named Docker volumes outside Git.
The agent has administrative access to the same Docker host as Jenkins and
Gitea; a container is not a security boundary against malicious trusted jobs.
Use only reviewed delivery code. `agent/compose.droplet.yaml` caps the agent
at 512 MiB RAM / 768 MiB RAM+swap and 0.5 CPU; a dedicated pinned BuildKit
builder has 256 MiB / 384 MiB and 0.5 CPU. Builds select that builder explicitly.
Agent and builder restart unless stopped. `bootstrap/start-droplet-agent.sh`
is the root-operated installation/reconnect helper in
`/opt/ssw590-delivery-agent`; it detects the Docker socket group (987 on this host).
No public agent, Docker API or app port is added.
`bootstrap/start-agent.ps1` refuses to start the laptop copy by default.
For an intentional fallback, first stop the remote agent and builder, then use
`-AllowLaptopFallback`. Never connect both copies of the same node. Preserve
their volumes. The Gitea Actions manual-build runner subsequently moved to
The-Ocean too; see `../gitea/droplet-runner/README.md`. Neither active runner
now depends on Docker Desktop. Run manual builds and delivery releases sequentially.
See `RUNBOOKS.md`.
Ansible syntax, agent Compose configuration, and the installed Jenkins
controller's declarative parser checks passed. These are preparation checks;
@@ -73,12 +98,16 @@ controller's declarative parser checks passed. These are preparation checks;
## Remaining checkpoints
Vincent creates the issue, commits/pushes this branch, and obtains Billy's PR
review. Keep main protection. Billy/domain owner must add A records `staging`
and `app`, both pointing to `147.182.178.136`; distinct DNS names are required.
The prepared Caddy additions are not yet applied to the server. Enable the
Vincent pushed preparation commit `bf28adc` and opened PR #24. The later
migration changes are uncommitted and need the same review path. Create the
issue and obtain Billy's PR review. Keep main protection. Billy added the A
records; Google and Cloudflare now resolve both names to `147.182.178.136`.
On 15 November Caddy's prepared routes were validated and gracefully reloaded;
both names have trusted HTTPS and HTTP redirects. They currently return 502
because the app containers are not deployed. See `evidence/https-20261115.md`.
Enable the
release job after the reviewed source reaches main, then follow `RUNBOOKS.md`.
Keep the laptop awake during runs. Production approval requires an authorized
Keep Jenkins and the remote delivery node available. Production approval requires an authorized
human; an agent must not approve unattended.
`SECURITY.md` defines the gate policy. `bootstrap/` makes administrator setup
+48 -5
View File
@@ -2,11 +2,17 @@
These are execution instructions, not completed release evidence.
Current status, 15 November 2026: Billy's DNS records resolve correctly and the
two Caddy routes are active with trusted certificates and HTTP-to-HTTPS redirects.
502 is expected while the app backends are absent. The one-time HTTPS helper
has already run; use the normal validate/reload procedure for later changes.
Monitoring additions and assessed releases remain pending.
## Authority and preparation
Billy reviews code; Vincent commits/pushes. Jenkins users `billy` or `vsun1`
may approve production interactively; administrators retain override authority.
The laptop agent must be online and source/configuration commits reviewed and
The Droplet delivery agent must be online and source/configuration commits reviewed and
merged into protected main. Do not run untrusted PR/fork code with its Docker
socket or the delivery folder's credentials. Exclusive scheduling alone does
not prevent someone authorized to alter jobs from selecting the node.
@@ -52,8 +58,8 @@ procedure. The temporary candidate checks already passed without a reload.
## Healthy production rollback
Record the detection/decision UTC and reason. Before approval, start the laptop
observer, for example:
Record the detection/decision UTC and reason. Before approval, start the HTTPS
observer on an available client or the remote agent, for example:
```text
python delivery/ci/observe.py --url https://app.yebilly.me --seconds 600 --output build/evidence/assignment8/rollback-health.csv
@@ -99,7 +105,10 @@ below the alert duration. HTTP status cannot validate the expected price.
Each stateless app is capped at 64 MiB RAM, 96 MiB RAM+swap, 0.25 CPU and 64
PIDs, with a read-only root filesystem, 16 MiB /tmp tmpfs, UID 10001 and all
capabilities dropped. The laptop agent is capped at 2 GiB/2 CPU. One droplet
capabilities dropped. The remote agent is capped at 512 MiB RAM / 768 MiB
RAM+swap and 0.5 CPU; its pinned BuildKit builder at 256 MiB / 384 MiB and
0.5 CPU. The preparation trial passed but used swap and is not a full release
load test. Keep one exclusive executor and serialized delivery. One droplet
and a shared proxy network provide neither high availability nor strong lateral
isolation. A real database migration or external payment can invalidate image
rollback; use compatible expand/migrate/contract changes and tested backups.
@@ -110,7 +119,7 @@ Archive required evidence first. Remove only the two pricing Compose projects,
their routes, monitoring additions and test DNS names. Revoke the two named
Assignment 8 package tokens, then remove the deploy key/sudo grant and its
Jenkins folder/node when no longer needed. Preserve required job history before
removing configuration. Stop the local agent; remove only its identity/workspace
removing configuration. Stop the remote agent and dedicated builder; remove only their identity/workspace
volumes after approval. Preserve Gitea, Jenkins home, proxy storage, monitoring
volumes and earlier assignments. Never system-prune or use `down -v` here.
@@ -122,3 +131,37 @@ creation. Metadata records token names, not values. Transient private inputs
are erased after Jenkins encrypts them. If setup fails partway, inspect its
marker/logs and existing state rather than rerunning or rotating credentials.
Do not restore entire volumes/databases over later work without a reviewed plan.
## Agent placement and campus demonstration
The node name `ssw590-vince-delivery` is historical; it now runs on The-Ocean.
Deployment SSH goes to `host.docker.internal` through the mounted SSH config,
with the original public-IP host-key alias and strict verification. The Jenkins
connection is private HTTP/WebSocket on `gitea_web`; public browser access
continues through Caddy HTTPS and its existing allowlist. No campus SSH is
needed for this delivery path. Rehearse campus browser access before presenting.
The Gitea Actions PDF runner now also runs on The-Ocean. Its existing label
`latex-local` is historical. Both laptop copies are stopped; run manual builds
and delivery releases sequentially. See `../gitea/droplet-runner/README.md`.
To stop the remote agent from an authorized administrator shell:
```sh
cd /opt/ssw590-delivery-agent
docker compose -f compose.droplet.yaml stop
docker stop buildx_buildkit_ssw590-delivery-limited0
```
To reconnect, run `bash /opt/ssw590-delivery-agent/start-droplet-agent.sh`.
It reuses protected identity and workspace volumes; do not rerun the original
host/account bootstrap. Agent recreation reuses the node identity. The verified
tool image was transferred from Docker Desktop and checked by archive SHA-256
and image ID before loading. It can be rebuilt from `agent/Dockerfile` on a
build-capable machine and transferred again if required.
For a laptop fallback, stop the remote copy first, load the administrator key
into Windows ssh-agent, then run
`./delivery/bootstrap/start-agent.ps1 -AllowLaptopFallback`.
Stop the laptop copy before starting the remote one again.
No new cloud instance or plan change was made; existing Droplet billing applies.
VS maintains this agent and BY retains server administration ownership.
+11 -3
View File
@@ -25,7 +25,15 @@ The synthetic fixture is generated only for a deliberate blocked-gate run.
Its label identifies course test data and has no credential authority. Remove
the fixture and repeat the gate before a release can proceed.
The deployment agent has administrative Docker access to the laptop's Linux
VM and deployment privileges on the droplet. Run reviewed delivery code on
The deployment agent now has administrative Docker access on The-Ocean,
including the host running the controller, registry and monitoring, as well as
deployment privileges. Co-location reduces isolation: the agent's container
and resource caps do not prevent a malicious Docker-authorized job from
accessing other containers or host files. This is a documented course-lab
trade-off to avoid campus SSH restrictions, not a hardened production design.
Run reviewed delivery code on
this agent. Pull-request jobs must not receive its Docker socket or release
credentials. The agent connects to Jenkins over outbound HTTPS/WebSocket.
credentials. The remote agent connects over private HTTP/WebSocket on the
existing Docker network; browser access remains HTTPS through Caddy. Strict
SSH verification retains the public-IP host-key alias while transport stays
on Docker's host gateway. No firewall, TLS, approval or credential scope was relaxed.
+54
View File
@@ -0,0 +1,54 @@
name: ssw590-delivery
services:
agent:
image: ssw590-delivery-agent:20261114
restart: unless-stopped
entrypoint: ["java", "-jar", "/usr/share/jenkins/agent.jar"]
command:
- -url
- http://jenkins:8080/
- -name
- ssw590-vince-delivery
- -secret
- "@/run/delivery-identity/agent-secret"
- -webSocket
- -workDir
- /home/jenkins/agent
environment:
JAVA_TOOL_OPTIONS: "-Xms32m -Xmx96m -XX:+UseSerialGC -XX:MaxMetaspaceSize=96m"
GOMEMLIMIT: 192MiB
TRIVY_PARALLEL: "1"
BUILDX_CONFIG: /home/jenkins/agent/.buildx
DELIVERY_BUILDER: ssw590-delivery-limited
# Docker membership is host administration, including controller access.
# Only reviewed delivery jobs may select this exclusive one-executor node.
group_add: ["${DOCKER_GID:?set to the host Docker socket group}"]
extra_hosts:
- "host.docker.internal:host-gateway"
networks: [web]
volumes:
- workspace:/home/jenkins/agent
- /var/run/docker.sock:/var/run/docker.sock
- identity:/run/delivery-identity:ro
- ./ssh_config.droplet:/etc/ssh/ssh_config.d/90-delivery-target.conf:ro
mem_limit: 512m
memswap_limit: 768m
cpus: 0.5
pids_limit: 128
security_opt: ["no-new-privileges:true"]
cap_drop: ["ALL"]
logging:
driver: json-file
options:
max-size: 10m
max-file: "3"
networks:
web:
external: true
name: gitea_web
volumes:
identity:
external: true
name: ssw590-delivery-identity
workspace:
name: ssw590-delivery-workspace
+6
View File
@@ -0,0 +1,6 @@
# On The-Ocean only: keep the inventory and pinned public-key identity, but
# send deployment SSH to this Docker host's gateway, never across campus Wi-Fi.
Host 147.182.178.136
HostName host.docker.internal
HostKeyAlias 147.182.178.136
ConnectTimeout 10
+57
View File
@@ -0,0 +1,57 @@
#!/bin/sh
# Run inside the idle trusted agent from a non-secret preparation snapshot.
# This is a capacity/tool trial, never a reviewed release or registry push.
set -eu
export TRIVY_CACHE_DIR=/home/jenkins/agent/.cache/trivy
mkdir -p build/delivery/reports
date -u
python3 -B -m unittest discover -s delivery/ci -p 'test_controls.py' -v
sh delivery/ci/test-app.sh
python3 delivery/ci/security.py source
: "${DELIVERY_BUILDER:?use the limited remote builder}"
docker buildx build --builder "$DELIVERY_BUILDER" --load --platform linux/amd64 \
--build-arg APP_COMMIT=uncommitted-remote-preflight \
-t ssw590-pricing:remote-preflight-v1 delivery/app
python3 delivery/ci/security.py image --image ssw590-pricing:remote-preflight-v1
name=ssw590-delivery-capacity-smoke
cleanup() { docker rm -f "$name" >/dev/null 2>&1 || true; }
# Refuse to replace any existing container, even one from an interrupted trial.
if docker container inspect "$name" >/dev/null 2>&1; then
echo 'Inspect the existing trial container before retrying' >&2
exit 1
fi
trap cleanup EXIT
docker run -d --name "$name" --network gitea_web --read-only \
--tmpfs /tmp:rw,nosuid,noexec,size=16m --memory 64m --memory-swap 96m \
--cpus .25 --pids-limit 64 --cap-drop ALL --security-opt no-new-privileges \
ssw590-pricing:remote-preflight-v1
python3 - <<'PY'
import json, time, urllib.request, urllib.error
url = 'http://ssw590-delivery-capacity-smoke:8000'
for attempt in range(30):
try:
with urllib.request.urlopen(url + '/health', timeout=2) as response:
health = json.load(response)
break
except (OSError, ValueError):
time.sleep(1)
else:
raise RuntimeError('Application failed to start')
def get(path):
with urllib.request.urlopen(url + path, timeout=5) as response:
return json.load(response)
identity, price = get('/'), get('/price?quantity=3')
assert health['status'] == 'ok' and health['version'] == 'v1', health
assert identity['commit'] == 'uncommitted-remote-preflight', identity
assert price['total'] == 30, price
try:
get('/price?quantity=-1')
raise AssertionError('Invalid quantity accepted')
except urllib.error.HTTPError as error:
assert error.code == 400, error.code
print(json.dumps({'health': health, 'identity': identity, 'price': price,
'invalid_quantity_status': 400}, indent=2))
PY
docker inspect "$name" --format 'smoke OOMKilled={{.State.OOMKilled}} memory={{.HostConfig.Memory}}'
date -u
echo 'PASS: remote capacity preparation; no image published or assessed environment deployed'
+1 -1
View File
@@ -46,7 +46,7 @@ def knownHosts = new FileCredentialsImpl(scope, 'delivery-known-hosts',
assert store.addCredentials(Domain.global(), knownHosts)
def launcher = new JNLPLauncher()
launcher.setWebSocket(true)
def node = new DumbSlave('ssw590-vince-delivery', 'Trusted laptop Docker/Ansible delivery agent',
def node = new DumbSlave('ssw590-vince-delivery', 'Trusted The-Ocean Docker/Ansible delivery agent (legacy node name)',
'/home/jenkins/agent', '1', Node.Mode.EXCLUSIVE, 'delivery-trusted', launcher,
new RetentionStrategy.Always(), [])
j.addNode(node)
+72
View File
@@ -0,0 +1,72 @@
"""Apply only the prepared Assignment 8 proxy additions, preserving the bind inode."""
import argparse
import hashlib
import json
import os
import shutil
import socket
import subprocess
from datetime import datetime, timezone
from pathlib import Path
parser = argparse.ArgumentParser()
parser.add_argument('--candidate', required=True, type=Path)
parser.add_argument('--backup', required=True, type=Path)
parser.add_argument('--apply', action='store_true')
args = parser.parse_args()
live = Path('/root/gitea/Caddyfile')
marker = '# Assignment 8: apply after both DNS names resolve to The-Ocean.'
candidate = args.candidate.read_text()
before = live.read_bytes()
prefix, additions = candidate.split(marker, 1)
expected = '''# Assignment 8: apply after both DNS names resolve to The-Ocean. Containers
# publish no host ports; the existing proxy reaches their private aliases.
staging.yebilly.me {
\treverse_proxy pricing-staging:8000
}
app.yebilly.me {
\treverse_proxy pricing-production:8000
}'''
assert (marker + additions).strip() == expected, 'Unexpected proxy additions'
assert prefix.strip() == before.decode().replace('\r\n', '\n').strip(), 'Live earlier routes differ; inspect instead of overwriting'
for host in ('staging.yebilly.me', 'app.yebilly.me'):
addresses = {item[4][0] for item in socket.getaddrinfo(host, 443, socket.AF_INET)}
assert addresses == {'147.182.178.136'}, (host, addresses)
temp = '/tmp/ssw590-assignment8-https.Caddyfile'
subprocess.run(['docker', 'cp', str(args.candidate), 'gitea-caddy-1:' + temp], check=True)
try:
subprocess.run(['docker', 'exec', 'gitea-caddy-1', 'caddy', 'validate', '--config', temp, '--adapter', 'caddyfile'], check=True)
if not args.apply:
print('Candidate validated; no active configuration changed.')
raise SystemExit(0)
args.backup.mkdir(mode=0o700, parents=True, exist_ok=True)
backup = args.backup / 'Caddyfile.before'
assert not backup.exists(), 'Existing backup: inspect state before retrying'
shutil.copy2(live, backup)
prior_stat = live.stat()
try:
with live.open('wb') as stream:
stream.write(candidate.encode())
stream.flush()
os.fsync(stream.fileno())
assert live.stat().st_ino == prior_stat.st_ino, 'Bind-mounted inode changed'
subprocess.run(['docker', 'exec', 'gitea-caddy-1', 'caddy', 'reload', '--config', '/etc/caddy/Caddyfile', '--adapter', 'caddyfile'], check=True)
except Exception:
with live.open('wb') as stream:
stream.write(before)
stream.flush()
os.fsync(stream.fileno())
subprocess.run(['docker', 'exec', 'gitea-caddy-1', 'caddy', 'reload', '--config', '/etc/caddy/Caddyfile', '--adapter', 'caddyfile'], check=True)
raise
report = {'applied_at': datetime.now(timezone.utc).isoformat(),
'before_sha256': hashlib.sha256(before).hexdigest(),
'after_sha256': hashlib.sha256(live.read_bytes()).hexdigest(),
'inode_preserved': live.stat().st_ino == prior_stat.st_ino,
'prior_routes_preserved': True, 'applications_deployed': False,
'new_hosts': ['staging.yebilly.me', 'app.yebilly.me'],
'backup': str(backup), 'result': 'reloaded; certificate verification pending'}
(args.backup / 'applied.json').write_text(json.dumps(report, indent=2))
print(json.dumps(report, indent=2))
finally:
subprocess.run(['docker', 'exec', 'gitea-caddy-1', 'rm', '-f', temp], check=True)
+4
View File
@@ -1,9 +1,13 @@
param(
[switch]$AllowLaptopFallback,
[string]$Droplet = '147.182.178.136',
[string]$IdentityFile = (Join-Path $env:USERPROFILE '.ssh/digitalocean')
)
$ErrorActionPreference = 'Stop'
$PSNativeCommandUseErrorActionPreference = $true
if (-not $AllowLaptopFallback) {
throw 'The delivery node now runs on The-Ocean. Start a laptop fallback only after stopping the remote copy, then pass -AllowLaptopFallback. Never connect both copies of the same node.'
}
$repoPath = (Resolve-Path (Join-Path $PSScriptRoot '../..')).Path
$sshArguments = @('-i', $IdentityFile, '-o', 'IdentitiesOnly=yes', '-o', 'BatchMode=yes',
'-o', 'StrictHostKeyChecking=yes', '-o', 'ConnectTimeout=10', "root@$Droplet")
+32
View File
@@ -0,0 +1,32 @@
#!/bin/bash
# Run as root from /opt/ssw590-delivery-agent after stopping the laptop copy.
# Copy compose.droplet.yaml and ssh_config.droplet here first; load the verified
# agent image. Never copy any identity file into this directory or into Git.
set -euo pipefail
test "$(id -u)" = 0
cd /opt/ssw590-delivery-agent
export DOCKER_GID
DOCKER_GID=$(stat -c '%g' /var/run/docker.sock)
# Numeric group only, not a credential. Keep it available for later Compose use.
printf 'DOCKER_GID=%s\n' "$DOCKER_GID" > .env
chmod 644 .env
docker image inspect ssw590-delivery-agent:20261114 >/dev/null
docker compose -f compose.droplet.yaml config --quiet
docker exec -u jenkins gitea-jenkins-1 test -s /var/jenkins_home/delivery-bootstrap/agent-secret
docker volume create ssw590-delivery-identity >/dev/null
docker exec -u jenkins gitea-jenkins-1 cat /var/jenkins_home/delivery-bootstrap/agent-secret |
docker run --rm -i --network none --user 0:0 --entrypoint sh \
--mount type=volume,source=ssw590-delivery-identity,target=/identity \
ssw590-delivery-agent:20261114 -c \
'set -eu; umask 077; cat > /identity/agent-secret; test -s /identity/agent-secret; chown 1000:1000 /identity /identity/agent-secret; chmod 700 /identity; chmod 400 /identity/agent-secret'
docker compose -f compose.droplet.yaml up -d --pull never
agent=ssw590-delivery-agent-1
# BuildKit's own container must be limited too: the socket mount does not make
# child build containers inherit the agent's resource caps.
if ! docker exec "$agent" docker buildx inspect ssw590-delivery-limited >/dev/null 2>&1; then
docker exec "$agent" docker buildx create --name ssw590-delivery-limited \
--driver docker-container \
--driver-opt image=moby/buildkit@sha256:c5f8862f52499773af85bc07695b2379ef08e8002352b0df2c4864c91d78dabe,memory=256m,memory-swap=384m,cpu-period=100000,cpu-quota=50000,restart-policy=unless-stopped
fi
docker exec "$agent" docker buildx inspect ssw590-delivery-limited --bootstrap
docker compose -f compose.droplet.yaml ps
@@ -0,0 +1,41 @@
"""Read-only, non-secret runtime checks; run as root on The-Ocean."""
import json
import subprocess
from datetime import datetime, timezone
from pathlib import Path
def run(*args):
return subprocess.check_output(args, text=True).strip()
report = {"observed_at": datetime.now(timezone.utc).isoformat(), "containers": []}
names = ["ssw590-delivery-agent-1", "buildx_buildkit_ssw590-delivery-limited0"]
for name in names:
info = json.loads(run("docker", "inspect", name))[0]
config, state = info["HostConfig"], info["State"]
events = Path("/sys/fs/cgroup/system.slice", "docker-" + info["Id"] + ".scope", "memory.events")
report["containers"].append({
"name": name, "running": state["Running"], "oom_killed": state["OOMKilled"],
"restart_count": info["RestartCount"], "restart_policy": config["RestartPolicy"]["Name"],
"memory_bytes": config["Memory"], "memory_swap_bytes": config["MemorySwap"],
"nano_cpus": config["NanoCpus"], "cpu_quota": config["CpuQuota"],
"cpu_period": config["CpuPeriod"], "port_bindings": config["PortBindings"],
"memory_events": events.read_text().strip() if events.exists() else "unavailable",
})
assert state["Running"] and not state["OOMKilled"], name
report["private_http"] = {}
for url in ["http://jenkins:8080/login", "http://gitea:3000/", "http://monitoring-grafana-1:3000/login"]:
code = run("docker", "exec", names[0], "curl", "--silent", "--show-error", "--max-time", "15",
"-o", "/dev/null", "-w", "%{http_code}", url)
report["private_http"][url] = code
assert code == "200", (url, code)
ssh = run("docker", "exec", names[0], "ssh", "-G", "147.182.178.136")
report["deployment_ssh_route"] = [line for line in ssh.splitlines() if line.startswith(("hostname ", "hostkeyalias "))]
assert "hostname host.docker.internal" in ssh.splitlines()
assert "hostkeyalias 147.182.178.136" in ssh.splitlines()
report["memory"] = run("free", "-m")
report["disk"] = run("df", "-h", "/")
report["running_containers"] = run("docker", "ps", "--format", "{{.Names}} {{.Status}}")
report["result"] = "passed"
print(json.dumps(report, indent=2))
+6 -1
View File
@@ -19,7 +19,12 @@ else
cat "$reports/manifest-check.log" >&2
exit 1
fi
docker build --platform linux/amd64 --build-arg "APP_COMMIT=$commit" -t "$image:$commit" delivery/app
if [ -n "${DELIVERY_BUILDER:-}" ]; then
docker buildx build --builder "$DELIVERY_BUILDER" --load --platform linux/amd64 \
--build-arg "APP_COMMIT=$commit" -t "$image:$commit" delivery/app
else
docker build --platform linux/amd64 --build-arg "APP_COMMIT=$commit" -t "$image:$commit" delivery/app
fi
python3 delivery/ci/security.py image --image "$image:$commit" --reports "$reports/image-gate"
docker push "$image:$commit"
docker pull "$image:$commit"
@@ -0,0 +1,64 @@
# Delivery agent migration — preparation evidence
Vincent selected The-Ocean instead of the laptop to avoid the previously
observed campus SSH restriction. This work occurred on November 14 Eastern;
the host's UTC timestamps below fall on November 15, 2026.
- Existing host: 1 CPU, 1,967 MiB RAM, original 25 GB plan disk, 2 GiB swap.
At 03:29 UTC, 811 MiB RAM was available and swap used was 129 MiB.
- Transferred the existing agent image, without rebuilding its toolchain:
`sha256:0752666650a3afe7b61854c1df4dca21f4ef381fab1f4fb9b042adaa203c58a8`.
Transfer archive SHA-256 matched on both machines:
`f987fdb285757aabe91fffd21a3a58da00bec975efcce7ee8ef3f127b27d0696`.
- Stopped the laptop container before connecting its replacement. Existing
node name `ssw590-vince-delivery`, label `delivery-trusted`, one exclusive
executor, folder credentials and disabled pricing job were retained.
- Remote agent: 512 MiB RAM / 768 MiB RAM+swap, 0.5 CPU, 96 MiB JVM heap,
no published port, existing `gitea_web` network, private WebSocket connection.
Socket group detected as 987; initial group-0 mismatch was corrected.
- Builder: BuildKit v0.34.2 image pinned by index digest in the start helper;
256 MiB RAM / 384 MiB RAM+swap, CPU quota 50000/100000, no published port.
The pipeline explicitly selects this builder when `DELIVERY_BUILDER` is set.
- Deployment SSH: `ssh -G` reports `hostname host.docker.internal` and
`hostkeyalias 147.182.178.136`. The existing Jenkins known-hosts credential
remains authoritative; host verification was not bypassed.
- [Jenkins prerequisite build 2](https://ci.yebilly.me/job/secure-delivery/job/agent-preflight/2/)
passed at 03:47 UTC, including real credential binding, deploy login, pinned
host key and sudo. See [inventory](agent-preflight-2.txt).
- 03:50:16–03:51:43 UTC: the separate capacity preparation trial passed 12
control tests and 3 app tests, source-secret/dependency gates, capped image
build, full image gate (zero HIGH/CRITICAL), and a temporary 64 MiB app smoke.
Health v1, identity `uncommitted-remote-preflight`, total 30 for quantity 3,
and HTTP 400 for invalid quantity were verified. The smoke container was
removed. No image was pushed and no assessed environment was deployed.
- The trial used a non-secret local snapshot of `delivery/app`, `delivery/ci`,
the scanner rule and the trial script, not a reviewed full repository checkout.
Snapshot archive SHA-256:
`2cd5d23062ff9904b48a23dfd5d9f2b9c67929cb86db006e7b2677060da3afa0`.
Gate reports retain actual timestamps and tool/database metadata.
- Observed available RAM exceeded 700 MiB; swap used increased from 263 to
372 MiB during the sampled trial. At 03:54 UTC, 861 MiB was available, swap
used was 370 MiB and root disk was 56% used (11 GiB available, rounded by df).
Agent cgroup memory-limit events were nonzero; agent and builder `oom` and
`oom_kill` counters were zero, and both reported `OOMKilled=false`.
- Gitea, Jenkins login and Grafana login returned HTTP 200 through private
Docker routes after the trial. Seven previous containers remained running.
- Restarted only the agent; logs recorded a fresh WebSocket connection and
`Connected` at 03:57:57 UTC. `unless-stopped` is configured for both agent and
builder; an entire-host reboot was not performed as part of this migration.
Raw reports, partial resource-output capture, runtime JSON and screenshot:
ignored `build/evidence/assignment8-agent-migration/`. Protected server reports:
`/root/ssw590-delivery-bootstrap/agent-migration/`. The short trial used swap
and does not prove full release, recovery or campus presentation performance.
No firewall rule, credential scope, TLS verification, peer-review requirement
or human production approval changed. Co-located Docker authority gives trusted
jobs administrative access to the shared host; this is an explicit course-lab
trade-off. The older Gitea Actions PDF runner remains on the laptop. No new
instance or cloud plan change was made. Migration changes are uncommitted;
DNS, reviewed releases, production approvals and recovery exercises remain pending.
Subsequently Vincent requested moving that Actions runner too. The statement
above describes the end of the delivery-agent migration, not current placement.
See the [later runner record](../../gitea/droplet-runner/EVIDENCE.md).
+32
View File
@@ -0,0 +1,32 @@
Sun Nov 15 03:47:13 UTC 2026
uid=1000(jenkins) gid=1000(jenkins) groups=1000(jenkins),987
Python 3.13.5
ansible [core 2.21.6]
config file = None
configured module search path = ['/home/jenkins/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /opt/delivery-tools/lib/python3.13/site-packages/ansible
ansible collection location = /opt/ansible-collections
executable location = /opt/delivery-tools/bin/ansible
python version = 3.13.5 (main, Aug 10 2026, 12:06:59) [GCC 14.2.0] (/opt/delivery-tools/bin/python3)
jinja version = 3.1.6
pyyaml version = 6.0.3 (with libyaml v0.2.5)
# /opt/ansible-collections/ansible_collections
Collection Version
---------------------------------------- -------
community.docker 5.4.0
community.library_inventory_filtering_v1 1.1.5
Docker version 29.9.3, build 5457199
Docker Compose version v5.7.1
Version: 0.76.2
pip-audit 2.10.1
uid=1000(deploy) gid=1000(deploy) groups=1000(deploy)
Python 3.12.3
Docker version 29.9.3, build 5457199
Docker Compose version v5.7.1
total used free shared buff/cache available
Mem: 1967 1205 106 3 832 762
Swap: 2047 265 1782
1
Filesystem Size Used Avail Use% Mounted on
/dev/vda1 24G 12G 13G 49% /
+36
View File
@@ -0,0 +1,36 @@
# DNS and HTTPS readiness — 15 November 2026
Billy added A records for `staging.yebilly.me` and `app.yebilly.me` pointing to
`147.182.178.136`. At 06:14 UTC, Google and Cloudflare DNS-over-HTTPS both returned
that A record and no AAAA answer for each name. No DNS account was accessed or
changed by Codex.
At 06:09:34 UTC, the prepared `deploy/Caddyfile` additions were validated with
installed Caddy 2.11.4, backed up and gracefully reloaded. The helper checked
that earlier routes matched before changing anything and preserved the existing
bind-mounted inode. The first comparison stopped because of CRLF versus LF;
normalizing only that comparison allowed the matching routes to pass.
- Before SHA-256: `0197f100c5a1f2a21c6a293964fada27f61fe6f4ddf0b0c6d1ed6455f2cfbcc5`.
- After SHA-256: `7adbd9469b1e0ebcb8d6b62c8576eb4fb8b51efc70409607f604f453f8ac8187`.
- Backup: `/root/ssw590-delivery-bootstrap/https-20261115/Caddyfile.before`.
- Existing Gitea/Jenkins/Grafana routes, allowlist placeholders, volumes and
certificate storage were preserved. No firewall or published port changed.
Normal Windows curl and Ubuntu Python TLS checks passed without insecure mode.
Both hostnames negotiated TLS 1.3 with trusted hostname-matching certificates.
HTTP returned 308 with the corresponding HTTPS Location. HTTPS returned 502:
the staging/production pricing containers do not exist yet. This proves DNS,
TLS and redirects, not app health or a completed release.
All ten prior service/agent/builder containers remained running. Gitea, Jenkins
login and Grafana login returned private HTTP 200 after the reload. Production
monitoring was not enabled while the pricing service was absent.
Actual DNS answers, certificate issuer/SAN/validity/fingerprints and HTTP results
are in ignored `build/evidence/assignment8-https/verification.json`; application
and existing-service checks remain separate. No reviewed release, registry
publication, promotion, rollback, password reset or account-permission change
was performed during this work. The source changes remain uncommitted.
Caddy behavior: [Automatic HTTPS](https://caddyserver.com/docs/automatic-https).