Compare commits
36 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 24df5d9c5a | |||
| 291c38bfd0 | |||
| 3cc6f3b0d4 | |||
| db8f5fe27b | |||
| c9006bb314 | |||
| 8e2fe554d3 | |||
| 9fdfd00fa6 | |||
| 927df037b0 | |||
| dae5b47373 | |||
| 944ca0f203 | |||
| 1841a7d4ab | |||
| 12226285c6 | |||
| 7b73df19bd | |||
| d6787727f8 | |||
| 69f1fe05cf | |||
| c5172fca86 | |||
| 90c5d9a3b1 | |||
| f14abad27b | |||
| c46f127e8c | |||
| 05d3c58c3a | |||
| 3fcd04010a | |||
| ad37d148ed | |||
| c864ddd0d2 | |||
| 8979d92c00 | |||
| 17750b844b | |||
| fb2bac752a | |||
| 3b79b7e07a | |||
| 60019db7da | |||
| 2a35f97071 | |||
| d8a5d2717b | |||
| 5e17a009dc | |||
| 7e76950690 | |||
| 27f8f20275 | |||
| 98f86092a2 | |||
| 459838dfcd | |||
| 6553b4400c |
@@ -1 +1,2 @@
|
|||||||
__pycache__/
|
__pycache__/
|
||||||
|
security-reports/
|
||||||
@@ -7,16 +7,50 @@
|
|||||||
// which holds the Docker socket and the registry/deploy credentials.
|
// which holds the Docker socket and the registry/deploy credentials.
|
||||||
// TODO before submission: remove the feature branch from TRUSTED_BRANCH so
|
// TODO before submission: remove the feature branch from TRUSTED_BRANCH so
|
||||||
// only reviewed code on main can deliver.
|
// only reviewed code on main can deliver.
|
||||||
|
//
|
||||||
|
// Release version: major.minor.changelist = 1.0.<Jenkins build number>,
|
||||||
|
// shown as the build name and used for the image tag, ZIP, and manual PDF.
|
||||||
|
//
|
||||||
|
// Two kinds of run:
|
||||||
|
// * Normal run (DEPLOY_RECORD empty): test, scan, build once, publish, deploy
|
||||||
|
// staging, prove idempotence, human approval, promote the SAME digest.
|
||||||
|
// * Redeploy run (DEPLOY_RECORD = a committed release record, e.g.
|
||||||
|
// releases/v1-production.yml): no build; redeploys exactly that record with
|
||||||
|
// this commit's Ansible files. Used for rollback and failed-deploy recovery.
|
||||||
|
// Production redeploys need the same approval.
|
||||||
|
|
||||||
def TRUSTED_BRANCH = 'main|feature/issue-24-delivery'
|
def TRUSTED_BRANCH = 'main|feature/issue-24-delivery'
|
||||||
|
// Jenkins user IDs allowed to approve production. Anonymous users cannot.
|
||||||
|
def APPROVERS = 'samahk,kaylah7'
|
||||||
|
// Semantic version: bump MAJOR_MINOR by hand for a feature or breaking release;
|
||||||
|
// the changelist part is the Jenkins build number, so every build is unique.
|
||||||
|
def MAJOR_MINOR = '1.0'
|
||||||
|
|
||||||
|
def deployRecord(String record) {
|
||||||
|
withCredentials([sshUserPrivateKey(credentialsId: 'deploy-ssh', keyFileVariable: 'DEPLOY_KEY')]) {
|
||||||
|
withEnv(["RECORD=${record}"]) {
|
||||||
|
sh '''
|
||||||
|
export PATH=/opt/ansible-venv/bin:$PATH
|
||||||
|
ansible-playbook -i ansible/inventory.ini ansible/deploy.yml --syntax-check
|
||||||
|
ansible-playbook -i ansible/inventory.ini ansible/deploy.yml \
|
||||||
|
--private-key "$DEPLOY_KEY" -e @"$RECORD"
|
||||||
|
'''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pipeline {
|
pipeline {
|
||||||
agent none
|
agent none
|
||||||
|
|
||||||
|
parameters {
|
||||||
|
string(name: 'DEPLOY_RECORD', defaultValue: '',
|
||||||
|
description: 'Leave EMPTY for a normal release. For rollback/recovery, the path of a committed release record, e.g. releases/v1-production.yml')
|
||||||
|
}
|
||||||
|
|
||||||
options {
|
options {
|
||||||
skipDefaultCheckout()
|
skipDefaultCheckout()
|
||||||
disableConcurrentBuilds() // no competing releases
|
disableConcurrentBuilds() // no competing releases
|
||||||
timeout(time: 30, unit: 'MINUTES')
|
timeout(time: 60, unit: 'MINUTES')
|
||||||
buildDiscarder(logRotator(numToKeepStr: '50'))
|
buildDiscarder(logRotator(numToKeepStr: '50'))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -40,7 +74,11 @@ pipeline {
|
|||||||
|
|
||||||
// ---------------- Chapter 6 delivery (trusted branches, agent) ---------
|
// ---------------- Chapter 6 delivery (trusted branches, agent) ---------
|
||||||
stage('Delivery') {
|
stage('Delivery') {
|
||||||
when { beforeAgent true; branch pattern: TRUSTED_BRANCH, comparator: 'REGEXP' }
|
when {
|
||||||
|
beforeAgent true
|
||||||
|
branch pattern: TRUSTED_BRANCH, comparator: 'REGEXP'
|
||||||
|
expression { (params.DEPLOY_RECORD ?: '').trim() == '' }
|
||||||
|
}
|
||||||
agent { label 'delivery' }
|
agent { label 'delivery' }
|
||||||
stages {
|
stages {
|
||||||
stage('Checkout') {
|
stage('Checkout') {
|
||||||
@@ -49,8 +87,12 @@ pipeline {
|
|||||||
script {
|
script {
|
||||||
env.APP_COMMIT = sh(script: 'git rev-parse HEAD', returnStdout: true).trim()
|
env.APP_COMMIT = sh(script: 'git rev-parse HEAD', returnStdout: true).trim()
|
||||||
env.IMAGE_TAG = "${env.IMAGE}:${env.APP_COMMIT}"
|
env.IMAGE_TAG = "${env.IMAGE}:${env.APP_COMMIT}"
|
||||||
|
env.SEMVER = "${MAJOR_MINOR}.${env.BUILD_NUMBER}"
|
||||||
|
env.SEMVER_TAG = "${env.IMAGE}:${env.SEMVER}"
|
||||||
|
currentBuild.displayName = "#${env.BUILD_NUMBER} v${env.SEMVER}"
|
||||||
}
|
}
|
||||||
echo "Source commit: ${env.APP_COMMIT}"
|
echo "Source commit: ${env.APP_COMMIT}"
|
||||||
|
echo "Release version: ${env.SEMVER}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,38 +109,45 @@ pipeline {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 6.4.5 (kholmes): dependency + secret checks on the source.
|
// LaTeX: compile the IT manual on the Droplet, in the same TeX Live
|
||||||
stage('Security scan: source') {
|
// image the Gitea Actions workflow uses (manual/ci/Dockerfile).
|
||||||
|
// The agent talks to the host's Docker daemon, so files are copied
|
||||||
|
// into and out of the container instead of bind-mounted.
|
||||||
|
stage('Compile manual (LaTeX)') {
|
||||||
steps {
|
steps {
|
||||||
sh '''
|
sh '''
|
||||||
if [ -x security/scan.sh ]; then
|
docker image inspect ssw590/manual-latex:1 >/dev/null 2>&1 || docker build -q -t ssw590/manual-latex:1 manual/ci
|
||||||
security/scan.sh source
|
cid=$(docker create -w /work ssw590/manual-latex:1 latexmk devopsAssignment.tex)
|
||||||
else
|
docker cp manual/. "$cid":/work
|
||||||
echo "security/scan.sh not added yet (6.4.5)"
|
if docker start -a "$cid"; then rc=0; else rc=$?; fi
|
||||||
fi
|
docker cp "$cid":/work/devopsAssignment.pdf "manual-$SEMVER.pdf" || true
|
||||||
|
docker rm "$cid" > /dev/null
|
||||||
|
[ "$rc" -eq 0 ] && [ -s "manual-$SEMVER.pdf" ] || { echo "Manual build failed"; exit 1; }
|
||||||
|
echo "Manual compiled: manual-$SEMVER.pdf"
|
||||||
'''
|
'''
|
||||||
|
archiveArtifacts artifacts: "manual-${env.SEMVER}.pdf", fingerprint: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 6.4.5: dependency and secret checks on the source. Fails closed:
|
||||||
|
// a missing script, a scanner error, or a finding stops the run.
|
||||||
|
stage('Security scan: source') {
|
||||||
|
steps { sh 'bash security/scan.sh source' }
|
||||||
|
post { always { archiveArtifacts artifacts: 'security-reports/**', allowEmptyArchive: true } }
|
||||||
|
}
|
||||||
|
|
||||||
stage('Build image') {
|
stage('Build image') {
|
||||||
steps {
|
steps {
|
||||||
dir('pricing') {
|
dir('pricing') {
|
||||||
sh 'docker build --build-arg APP_COMMIT="$APP_COMMIT" -t "$IMAGE_TAG" .'
|
sh 'docker build --build-arg APP_COMMIT="$APP_COMMIT" -t "$IMAGE_TAG" -t "$SEMVER_TAG" .'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 6.4.5 (kholmes): image vulnerability scan before publishing.
|
// 6.4.5: image vulnerability scan before publishing. Fails closed.
|
||||||
stage('Security scan: image') {
|
stage('Security scan: image') {
|
||||||
steps {
|
steps { sh 'bash security/scan.sh image "$IMAGE_TAG"' }
|
||||||
sh '''
|
post { always { archiveArtifacts artifacts: 'security-reports/**', allowEmptyArchive: true } }
|
||||||
if [ -x security/scan.sh ]; then
|
|
||||||
security/scan.sh image "$IMAGE_TAG"
|
|
||||||
else
|
|
||||||
echo "security/scan.sh not added yet (6.4.5)"
|
|
||||||
fi
|
|
||||||
'''
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
stage('Publish') {
|
stage('Publish') {
|
||||||
@@ -111,7 +160,8 @@ pipeline {
|
|||||||
sh '''
|
sh '''
|
||||||
printf '%s' "$REG_TOKEN" | docker login "$REGISTRY" -u "$REG_USER" --password-stdin
|
printf '%s' "$REG_TOKEN" | docker login "$REGISTRY" -u "$REG_USER" --password-stdin
|
||||||
docker push "$IMAGE_TAG"
|
docker push "$IMAGE_TAG"
|
||||||
docker image rm "$IMAGE_TAG"
|
docker push "$SEMVER_TAG"
|
||||||
|
docker image rm "$IMAGE_TAG" "$SEMVER_TAG"
|
||||||
docker pull "$IMAGE_TAG"
|
docker pull "$IMAGE_TAG"
|
||||||
docker logout "$REGISTRY"
|
docker logout "$REGISTRY"
|
||||||
docker image inspect "$IMAGE_TAG" --format '{{index .RepoDigests 0}}' > image-digest.txt
|
docker image inspect "$IMAGE_TAG" --format '{{index .RepoDigests 0}}' > image-digest.txt
|
||||||
@@ -119,7 +169,9 @@ pipeline {
|
|||||||
'''
|
'''
|
||||||
}
|
}
|
||||||
script { env.IMAGE_DIGEST = readFile('image-digest.txt').trim() }
|
script { env.IMAGE_DIGEST = readFile('image-digest.txt').trim() }
|
||||||
writeFile file: 'build-record.txt', text: """source_commit: ${env.APP_COMMIT}
|
writeFile file: 'build-record.txt', text: """version: ${env.SEMVER}
|
||||||
|
source_commit: ${env.APP_COMMIT}
|
||||||
|
version_tag: ${env.SEMVER_TAG}
|
||||||
image_tag: ${env.IMAGE_TAG}
|
image_tag: ${env.IMAGE_TAG}
|
||||||
image_digest: ${env.IMAGE_DIGEST}
|
image_digest: ${env.IMAGE_DIGEST}
|
||||||
jenkins_build: ${env.BUILD_URL}
|
jenkins_build: ${env.BUILD_URL}
|
||||||
@@ -128,33 +180,43 @@ jenkins_build: ${env.BUILD_URL}
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Deployment-ready ZIP named with the semantic version.
|
||||||
|
stage('Package') {
|
||||||
|
steps {
|
||||||
|
sh '''
|
||||||
|
rm -rf dist && mkdir -p "dist/pricing-$SEMVER"
|
||||||
|
cp pricing/app.py pricing/requirements.txt pricing/Dockerfile "dist/pricing-$SEMVER/"
|
||||||
|
cp -r ansible "dist/pricing-$SEMVER/ansible"
|
||||||
|
cp build-record.txt "dist/pricing-$SEMVER/"
|
||||||
|
printf '%s\n' "$SEMVER" > "dist/pricing-$SEMVER/VERSION"
|
||||||
|
cd dist && python3 -m zipfile -c "pricing-$SEMVER.zip" "pricing-$SEMVER"
|
||||||
|
python3 -m zipfile -l "pricing-$SEMVER.zip"
|
||||||
|
'''
|
||||||
|
archiveArtifacts artifacts: "dist/pricing-${env.SEMVER}.zip", fingerprint: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 6.4.6: deploy the digest just published to staging with Ansible,
|
// 6.4.6: deploy the digest just published to staging with Ansible,
|
||||||
// then rerun unchanged and require changed=0 (idempotence).
|
// then rerun unchanged and require changed=0 (idempotence).
|
||||||
stage('Deploy staging') {
|
stage('Deploy staging') {
|
||||||
steps {
|
steps {
|
||||||
script {
|
script {
|
||||||
// Expected behaviour comes from the source, not from config.
|
// Expected behaviour comes from the source, not from config.
|
||||||
def version = sh(script: "sed -n 's/^VERSION = \"\\(.*\\)\"/\\1/p' pricing/app.py", returnStdout: true).trim()
|
env.APP_VERSION = sh(script: "sed -n 's/^VERSION = \"\\(.*\\)\"/\\1/p' pricing/app.py", returnStdout: true).trim()
|
||||||
def unit = sh(script: "sed -n 's/^UNIT_PRICE = //p' pricing/app.py", returnStdout: true).trim()
|
def unit = sh(script: "sed -n 's/^UNIT_PRICE = //p' pricing/app.py", returnStdout: true).trim()
|
||||||
env.APP_VERSION = version
|
env.EXPECTED_TOTAL = "${3 * (unit as Integer)}"
|
||||||
writeFile file: "release-${version}-staging.yml", text: """target_env: staging
|
writeFile file: "release-${env.APP_VERSION}-staging.yml", text: """target_env: staging
|
||||||
release_image: ${env.IMAGE_DIGEST}
|
release_image: ${env.IMAGE_DIGEST}
|
||||||
expected_version: ${version}
|
expected_version: ${env.APP_VERSION}
|
||||||
expected_commit: ${env.APP_COMMIT}
|
expected_commit: ${env.APP_COMMIT}
|
||||||
expected_total: ${3 * (unit as Integer)}
|
expected_total: ${env.EXPECTED_TOTAL}
|
||||||
|
release_version: ${env.SEMVER}
|
||||||
public_url: https://staging.ssw590-08.me
|
public_url: https://staging.ssw590-08.me
|
||||||
proxy_network: gitea-net
|
proxy_network: gitea-net
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
archiveArtifacts artifacts: "release-${env.APP_VERSION}-staging.yml", fingerprint: true
|
archiveArtifacts artifacts: "release-${env.APP_VERSION}-staging.yml", fingerprint: true
|
||||||
withCredentials([sshUserPrivateKey(credentialsId: 'deploy-ssh', keyFileVariable: 'DEPLOY_KEY')]) {
|
deployRecord("release-${env.APP_VERSION}-staging.yml")
|
||||||
sh '''
|
|
||||||
export PATH=/opt/ansible-venv/bin:$PATH
|
|
||||||
ansible-playbook -i ansible/inventory.ini ansible/deploy.yml --syntax-check
|
|
||||||
ansible-playbook -i ansible/inventory.ini ansible/deploy.yml \
|
|
||||||
--private-key "$DEPLOY_KEY" -e @release-$APP_VERSION-staging.yml
|
|
||||||
'''
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -172,10 +234,100 @@ proxy_network: gitea-net
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 6.4.7: restricted human approval, then promote the SAME digest.
|
||||||
|
stage('Approve production') {
|
||||||
|
steps {
|
||||||
|
script {
|
||||||
|
def scan = fileExists('security-reports/image-summary.txt') ?
|
||||||
|
readFile('security-reports/image-summary.txt').trim() : 'see security-reports'
|
||||||
|
// Only APPROVERS can approve; Abort or the timeout stops the run.
|
||||||
|
timeout(time: 30, unit: 'MINUTES') {
|
||||||
|
env.APPROVER = input(
|
||||||
|
message: """Promote ${env.APP_VERSION} (release ${env.SEMVER}) to production (https://app.ssw590-08.me)?
|
||||||
|
Source commit: ${env.APP_COMMIT}
|
||||||
|
Image digest: ${env.IMAGE_DIGEST}
|
||||||
|
Security scans: source and image gates PASSED (fixable HIGH/CRITICAL block).
|
||||||
|
${scan}
|
||||||
|
Staging: deployed, HTTPS health/version/commit/total ${env.EXPECTED_TOTAL} passed, rerun changed=0.""",
|
||||||
|
ok: 'Approve and deploy to production',
|
||||||
|
submitter: APPROVERS,
|
||||||
|
submitterParameter: 'APPROVER')
|
||||||
|
}
|
||||||
|
env.APPROVED_AT = sh(script: 'date -Is', returnStdout: true).trim()
|
||||||
|
echo "APPROVED by ${env.APPROVER} at ${env.APPROVED_AT}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 6.4.7 (kholmes): approval + production deploy.
|
stage('Deploy production') {
|
||||||
stage('Approve and deploy production') {
|
steps {
|
||||||
steps { echo 'Not implemented yet (6.4.7).' }
|
// Same digest and commit as staging; only environment and URL change. No rebuild.
|
||||||
|
writeFile file: "release-${env.APP_VERSION}-production.yml", text: """target_env: production
|
||||||
|
release_image: ${env.IMAGE_DIGEST}
|
||||||
|
expected_version: ${env.APP_VERSION}
|
||||||
|
expected_commit: ${env.APP_COMMIT}
|
||||||
|
expected_total: ${env.EXPECTED_TOTAL}
|
||||||
|
release_version: ${env.SEMVER}
|
||||||
|
public_url: https://app.ssw590-08.me
|
||||||
|
proxy_network: gitea-net
|
||||||
|
approved_by: ${env.APPROVER}
|
||||||
|
approved_at: ${env.APPROVED_AT}
|
||||||
|
"""
|
||||||
|
archiveArtifacts artifacts: "release-${env.APP_VERSION}-production.yml", fingerprint: true
|
||||||
|
deployRecord("release-${env.APP_VERSION}-production.yml")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------- Rollback / recovery: redeploy a committed record -----
|
||||||
|
stage('Redeploy release record') {
|
||||||
|
when {
|
||||||
|
beforeAgent true
|
||||||
|
branch pattern: TRUSTED_BRANCH, comparator: 'REGEXP'
|
||||||
|
expression { (params.DEPLOY_RECORD ?: '').trim() != '' }
|
||||||
|
}
|
||||||
|
agent { label 'delivery' }
|
||||||
|
stages {
|
||||||
|
stage('Load record') {
|
||||||
|
steps {
|
||||||
|
checkout scm
|
||||||
|
script {
|
||||||
|
env.RECORD = params.DEPLOY_RECORD.trim()
|
||||||
|
if (!(env.RECORD ==~ /releases\/[A-Za-z0-9._-]+\.yml/) || !fileExists(env.RECORD)) {
|
||||||
|
error "No committed release record at ${env.RECORD}"
|
||||||
|
}
|
||||||
|
env.TARGET_ENV = sh(script: 'sed -n "s/^target_env: //p" "$RECORD"', returnStdout: true).trim()
|
||||||
|
env.CONFIG_COMMIT = sh(script: 'git rev-parse HEAD', returnStdout: true).trim()
|
||||||
|
}
|
||||||
|
echo "Redeploying ${env.RECORD} to ${env.TARGET_ENV} with configuration commit ${env.CONFIG_COMMIT}"
|
||||||
|
sh 'cat "$RECORD"'
|
||||||
|
archiveArtifacts artifacts: "${env.RECORD}", fingerprint: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Approve redeploy') {
|
||||||
|
when { environment name: 'TARGET_ENV', value: 'production' }
|
||||||
|
steps {
|
||||||
|
script {
|
||||||
|
timeout(time: 30, unit: 'MINUTES') {
|
||||||
|
env.APPROVER = input(
|
||||||
|
message: "Redeploy ${env.RECORD} to PRODUCTION (configuration commit ${env.CONFIG_COMMIT})?",
|
||||||
|
ok: 'Approve redeploy',
|
||||||
|
submitter: APPROVERS,
|
||||||
|
submitterParameter: 'APPROVER')
|
||||||
|
}
|
||||||
|
echo "APPROVED by ${env.APPROVER} at ${sh(script: 'date -Is', returnStdout: true).trim()}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Redeploy') {
|
||||||
|
steps {
|
||||||
|
sh 'echo "Redeploy start: $(date -Is)"'
|
||||||
|
deployRecord(env.RECORD)
|
||||||
|
sh 'echo "Redeploy verified: $(date -Is)"'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
# Secrets and host-specific values stay on the Droplet
|
||||||
|
jenkins-agent.secret
|
||||||
|
agent.secrets.env
|
||||||
|
.env
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
# Trusted Jenkins delivery agent for Chapter 6.
|
||||||
|
# Build context is the repository root (see agent/compose.yaml).
|
||||||
|
FROM jenkins/inbound-agent:latest-jdk21
|
||||||
|
|
||||||
|
USER root
|
||||||
|
|
||||||
|
# Python 3 + venv for tests, pip-audit and Ansible; curl for checks
|
||||||
|
RUN apt-get update \
|
||||||
|
&& apt-get install -y --no-install-recommends python3 python3-venv python3-pip ca-certificates curl \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
# Docker CLI + buildx plugin (client only; the daemon is the host's, via the mounted socket)
|
||||||
|
COPY --from=docker:cli /usr/local/bin/docker /usr/local/bin/docker
|
||||||
|
COPY --from=docker/buildx-bin /buildx /usr/libexec/docker/cli-plugins/docker-buildx
|
||||||
|
|
||||||
|
# Trivy scanner (image vulnerabilities + secret scanning)
|
||||||
|
COPY --from=aquasec/trivy:latest /usr/local/bin/trivy /usr/local/bin/trivy
|
||||||
|
|
||||||
|
# Ansible in its own virtual environment, plus the community.docker collection
|
||||||
|
ENV ANSIBLE_COLLECTIONS_PATH=/opt/ansible-collections
|
||||||
|
COPY ansible/requirements.yml /tmp/ansible-requirements.yml
|
||||||
|
RUN python3 -m venv /opt/ansible-venv \
|
||||||
|
&& /opt/ansible-venv/bin/pip install --no-cache-dir ansible-core \
|
||||||
|
&& /opt/ansible-venv/bin/ansible-galaxy collection install -r /tmp/ansible-requirements.yml -p /opt/ansible-collections \
|
||||||
|
&& rm /tmp/ansible-requirements.yml
|
||||||
|
|
||||||
|
# pip-audit in a separate tools venv
|
||||||
|
RUN python3 -m venv /opt/tools-venv \
|
||||||
|
&& /opt/tools-venv/bin/pip install --no-cache-dir pip-audit
|
||||||
|
|
||||||
|
USER jenkins
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
# Trusted delivery agent. Connects to the existing Jenkins controller over the
|
||||||
|
# internal gitea-net network (WebSocket), so no new port is published.
|
||||||
|
services:
|
||||||
|
jenkins-agent:
|
||||||
|
build:
|
||||||
|
context: ..
|
||||||
|
dockerfile: agent/Dockerfile
|
||||||
|
image: ssw590/jenkins-delivery-agent:1
|
||||||
|
container_name: jenkins-agent
|
||||||
|
restart: unless-stopped
|
||||||
|
# Start agent.jar directly. The secret is read from a file (-secret @file),
|
||||||
|
# so it never appears in the process list, docker inspect, or Git.
|
||||||
|
entrypoint:
|
||||||
|
- java
|
||||||
|
- -jar
|
||||||
|
- /usr/share/jenkins/agent.jar
|
||||||
|
- -url
|
||||||
|
- http://jenkins:8080/
|
||||||
|
- -webSocket
|
||||||
|
- -name
|
||||||
|
- delivery-agent
|
||||||
|
- -workDir
|
||||||
|
- /home/jenkins/agent
|
||||||
|
- -secret
|
||||||
|
- "@/run/secrets/jenkins-agent-secret"
|
||||||
|
# Host Docker socket: needed to build/push images. This is effectively root
|
||||||
|
# on the Droplet, so only reviewed main-branch delivery jobs may use this agent.
|
||||||
|
group_add: ["${DOCKER_GID:?set DOCKER_GID in .env}"]
|
||||||
|
volumes:
|
||||||
|
- /var/run/docker.sock:/var/run/docker.sock
|
||||||
|
- ./jenkins-agent.secret:/run/secrets/jenkins-agent-secret:ro
|
||||||
|
- agent_home:/home/jenkins # workspace, known_hosts, registry login
|
||||||
|
networks: [gitea-net]
|
||||||
|
|
||||||
|
networks:
|
||||||
|
gitea-net:
|
||||||
|
external: true
|
||||||
|
name: gitea-net
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
agent_home:
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# Print tool versions inside the agent. From the repo root on the Droplet:
|
||||||
|
# docker exec -i jenkins-agent sh -s < agent/versions.sh
|
||||||
|
echo "== java"; java -version 2>&1 | head -1
|
||||||
|
echo "== python"; python3 --version
|
||||||
|
echo "== docker"; docker version --format 'client {{.Client.Version}} / server {{.Server.Version}}'
|
||||||
|
echo "== buildx"; docker buildx version
|
||||||
|
echo "== trivy"; trivy --version | head -1
|
||||||
|
echo "== pip-audit"; /opt/tools-venv/bin/pip-audit --version
|
||||||
|
echo "== ansible"; /opt/ansible-venv/bin/ansible --version | head -3
|
||||||
|
echo "== collections"; /opt/ansible-venv/bin/ansible-galaxy collection list community.docker 2>/dev/null | tail -2
|
||||||
|
echo "== os"; . /etc/os-release; echo "$PRETTY_NAME $(uname -m)"
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
- name: Deploy a selected immutable pricing release
|
||||||
|
hosts: delivery
|
||||||
|
become: true
|
||||||
|
vars:
|
||||||
|
project_dir: "/opt/startup/pricing-{{ target_env }}"
|
||||||
|
tasks:
|
||||||
|
- name: Validate release selection
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- target_env in ['staging', 'production']
|
||||||
|
- "'@sha256:' in release_image"
|
||||||
|
- expected_version in ['v1', 'v2']
|
||||||
|
- expected_total | int > 0
|
||||||
|
- public_url.startswith('https://')
|
||||||
|
- proxy_network | length > 0
|
||||||
|
- name: Create deployment directory
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: "{{ project_dir }}"
|
||||||
|
state: directory
|
||||||
|
mode: '0750'
|
||||||
|
- name: Render selected Compose configuration
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: compose.yaml.j2
|
||||||
|
dest: "{{ project_dir }}/compose.yaml"
|
||||||
|
mode: '0640'
|
||||||
|
- name: Converge application without rebuilding
|
||||||
|
community.docker.docker_compose_v2:
|
||||||
|
project_src: "{{ project_dir }}"
|
||||||
|
project_name: "pricing-{{ target_env }}"
|
||||||
|
state: present
|
||||||
|
build: never
|
||||||
|
pull: missing
|
||||||
|
wait: true
|
||||||
|
wait_timeout: 90
|
||||||
|
- name: Verify health through public TLS endpoint
|
||||||
|
ansible.builtin.uri:
|
||||||
|
url: "{{ public_url }}/health"
|
||||||
|
return_content: true
|
||||||
|
validate_certs: true
|
||||||
|
register: health
|
||||||
|
until: health.status == 200 and health.json.status == 'ok'
|
||||||
|
retries: 12
|
||||||
|
delay: 5
|
||||||
|
changed_when: false
|
||||||
|
- name: Read release identity
|
||||||
|
ansible.builtin.uri:
|
||||||
|
url: "{{ public_url }}/"
|
||||||
|
return_content: true
|
||||||
|
register: identity
|
||||||
|
changed_when: false
|
||||||
|
- name: Exercise business behavior
|
||||||
|
ansible.builtin.uri:
|
||||||
|
url: "{{ public_url }}/price?quantity=3"
|
||||||
|
return_content: true
|
||||||
|
register: price
|
||||||
|
changed_when: false
|
||||||
|
- name: Check release identity and calculation
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- identity.json.version == expected_version
|
||||||
|
- identity.json.commit == expected_commit
|
||||||
|
- price.json.total | int == expected_total | int
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
[delivery]
|
||||||
|
# Target: the existing Droplet, reached over SSH as the dedicated deploy account.
|
||||||
|
# Host key must be verified and pinned in the agent's known_hosts before first use.
|
||||||
|
startup ansible_host=147.182.179.191 ansible_user=deploy
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
collections:
|
||||||
|
- name: community.docker
|
||||||
|
version: ">=4.8.0,<6.0.0"
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
services:
|
||||||
|
app:
|
||||||
|
image: "{{ release_image }}"
|
||||||
|
restart: unless-stopped
|
||||||
|
read_only: true
|
||||||
|
tmpfs:
|
||||||
|
- /tmp
|
||||||
|
cap_drop:
|
||||||
|
- ALL
|
||||||
|
security_opt:
|
||||||
|
- no-new-privileges:true
|
||||||
|
networks:
|
||||||
|
edge:
|
||||||
|
aliases:
|
||||||
|
- "pricing-{{ target_env }}"
|
||||||
|
networks:
|
||||||
|
edge:
|
||||||
|
external: true
|
||||||
|
name: "{{ proxy_network }}"
|
||||||
|
After Width: | Height: | Size: 96 KiB |
|
After Width: | Height: | Size: 138 KiB |
|
After Width: | Height: | Size: 120 KiB |
|
After Width: | Height: | Size: 181 KiB |
|
After Width: | Height: | Size: 216 KiB |
|
After Width: | Height: | Size: 79 KiB |
|
After Width: | Height: | Size: 78 KiB |
|
After Width: | Height: | Size: 446 KiB |
|
After Width: | Height: | Size: 93 KiB |
|
After Width: | Height: | Size: 155 KiB |
|
After Width: | Height: | Size: 192 KiB |
|
After Width: | Height: | Size: 192 KiB |
|
After Width: | Height: | Size: 189 KiB |
|
After Width: | Height: | Size: 220 KiB |
|
After Width: | Height: | Size: 309 KiB |
|
After Width: | Height: | Size: 435 KiB |
|
After Width: | Height: | Size: 86 KiB |
|
After Width: | Height: | Size: 51 KiB |
|
After Width: | Height: | Size: 33 KiB |
|
After Width: | Height: | Size: 22 KiB |
|
After Width: | Height: | Size: 32 KiB |
|
After Width: | Height: | Size: 171 KiB |
|
After Width: | Height: | Size: 92 KiB |
|
After Width: | Height: | Size: 58 KiB |
|
After Width: | Height: | Size: 113 KiB |
|
After Width: | Height: | Size: 31 KiB |
|
After Width: | Height: | Size: 92 KiB |
|
After Width: | Height: | Size: 234 KiB |
|
After Width: | Height: | Size: 53 KiB |
|
After Width: | Height: | Size: 32 KiB |
|
After Width: | Height: | Size: 232 KiB |
|
After Width: | Height: | Size: 362 KiB |
|
After Width: | Height: | Size: 95 KiB |
|
After Width: | Height: | Size: 606 KiB |
|
After Width: | Height: | Size: 572 KiB |
|
After Width: | Height: | Size: 158 KiB |
|
After Width: | Height: | Size: 157 KiB |
|
After Width: | Height: | Size: 468 KiB |
|
After Width: | Height: | Size: 266 KiB |
|
After Width: | Height: | Size: 89 KiB |
|
After Width: | Height: | Size: 173 KiB |
|
After Width: | Height: | Size: 38 KiB |
|
After Width: | Height: | Size: 135 KiB |
|
After Width: | Height: | Size: 333 KiB |
|
After Width: | Height: | Size: 56 KiB |
|
After Width: | Height: | Size: 206 KiB |
|
After Width: | Height: | Size: 45 KiB |
|
After Width: | Height: | Size: 197 KiB |
|
After Width: | Height: | Size: 132 KiB |
|
After Width: | Height: | Size: 94 KiB |
|
After Width: | Height: | Size: 273 KiB |
@@ -114,4 +114,20 @@ confirmed, as the assistant did not create those two chapters.
|
|||||||
Exporter to the public hostnames is inferred from the Compose networks, not
|
Exporter to the public hostnames is inferred from the Compose networks, not
|
||||||
tested.
|
tested.
|
||||||
|
|
||||||
|
\item \textbf{Secure delivery and rollback.} Date: November 12--13, 2026.
|
||||||
|
Tool and model: Claude (configured model claude-opus-5-5). Task: split the
|
||||||
|
work; write the delivery agent Dockerfile and Compose file, the hash-locked
|
||||||
|
requirements, the Dockerfile changes, and the \texttt{Jenkinsfile} stages for
|
||||||
|
publishing, staging, idempotence, restricted approval, production promotion,
|
||||||
|
and record-based redeployment; guide the registry, deploy-account, Caddy,
|
||||||
|
rollback, failure, and monitoring steps; draft and edit Chapter 11 and the
|
||||||
|
deployment diagram. Inputs: manual Chapter 6 and its starter files; Jenkins
|
||||||
|
console output, screenshots, release records, commit hashes, and per-second
|
||||||
|
probe logs supplied by the students. Output used: the files above and
|
||||||
|
chapter text. Human review and corrections: the students ran every step on
|
||||||
|
the real services and supplied all evidence; a registry token pasted into
|
||||||
|
the chat was revoked and replaced; Jenkins times were found to be UTC and
|
||||||
|
converted to EST; the Prometheus edit was found not to be loaded and the
|
||||||
|
container was recreated. Unresolved assumptions: none.
|
||||||
|
|
||||||
\end{itemize}
|
\end{itemize}
|
||||||
@@ -41,10 +41,10 @@
|
|||||||
\newcommand{\CourseName}{DevOps}
|
\newcommand{\CourseName}{DevOps}
|
||||||
\newcommand{\Instructor}{Samah Keshiro and Kayla Holmes}
|
\newcommand{\Instructor}{Samah Keshiro and Kayla Holmes}
|
||||||
\newcommand{\Organization}{Stevens Institute of Technology}
|
\newcommand{\Organization}{Stevens Institute of Technology}
|
||||||
\newcommand{\DocumentDate}{October 29, 2026}
|
\newcommand{\DocumentDate}{November 29, 2026}
|
||||||
\newcommand{\DueDate}{[Due Date and Time]}
|
\newcommand{\DueDate}{[Due Date and Time]}
|
||||||
\newcommand{\VERSION}{Version 1.6}
|
\newcommand{\VERSION}{Version 1.8 (draft)}
|
||||||
\newcommand{\AssignmentNumber}{6}
|
\newcommand{\AssignmentNumber}{8}
|
||||||
|
|
||||||
\newcolumntype{Y}{>{\raggedright\arraybackslash}X}
|
\newcolumntype{Y}{>{\raggedright\arraybackslash}X}
|
||||||
\newcolumntype{L}[1]{>{\raggedright\arraybackslash}p{#1}}
|
\newcolumntype{L}[1]{>{\raggedright\arraybackslash}p{#1}}
|
||||||
@@ -137,6 +137,8 @@
|
|||||||
\include{devopsAutomatedManualBuild}
|
\include{devopsAutomatedManualBuild}
|
||||||
\include{devopsCI}
|
\include{devopsCI}
|
||||||
\include{devopsSRE}
|
\include{devopsSRE}
|
||||||
|
\include{devopsSecureDelivery}
|
||||||
|
\include{devopsZammad}
|
||||||
|
|
||||||
\printglossaries
|
\printglossaries
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,8 @@
|
|||||||
\toprule \textbf{Date / Version} & \textbf{Authors} & \textbf{Change} & \textbf{Changed At}\\ \midrule
|
\toprule \textbf{Date / Version} & \textbf{Authors} & \textbf{Change} & \textbf{Changed At}\\ \midrule
|
||||||
\endhead
|
\endhead
|
||||||
|
|
||||||
|
November 13, 2026 / 1.7 & SK, KH & Secure Delivery and Rollback assignment: trusted Jenkins delivery agent, locked dependencies and pinned base image, Gitea container registry, staging and production proxy routes, security gates with a blocked run, build once and publish by digest, Ansible deployment with an unchanged rerun, restricted approval and promotion of the same digest, v2 release, production rollback and staging failure recovery, production health probe, runbooks, and traceability. Updated the Hosts and Passwords tables, Glossary, Bibliography, and AI Prompt Log. & \ChapterRef{SecureDelivery}, \ChapterRef{PWDHST} \\
|
||||||
|
|
||||||
October 29, 2026 / 1.6 & SK, KH & Completed the Introduction to SRE assignment: deployed Prometheus, Grafana OSS, Node Exporter, and Blackbox Exporter as four pinned, persistent containers on the existing Droplet; published authenticated Grafana at \texttt{metrics.ssw590-08.me}; built a six-panel dashboard; defined an availability SLI and SLO; configured and tested Grafana-managed alerts with a Discord contact point; and ran a controlled Jenkins outage with a blameless review. Updated the Hosts and Passwords tables and the Glossary. & \ChapterRef{SRE}, \ChapterRef{PWDHST} \\
|
October 29, 2026 / 1.6 & SK, KH & Completed the Introduction to SRE assignment: deployed Prometheus, Grafana OSS, Node Exporter, and Blackbox Exporter as four pinned, persistent containers on the existing Droplet; published authenticated Grafana at \texttt{metrics.ssw590-08.me}; built a six-panel dashboard; defined an availability SLI and SLO; configured and tested Grafana-managed alerts with a Discord contact point; and ran a controlled Jenkins outage with a blameless review. Updated the Hosts and Passwords tables and the Glossary. & \ChapterRef{SRE}, \ChapterRef{PWDHST} \\
|
||||||
|
|
||||||
October 23, 2026 / 1.5 & SK, KH & Completed the Continuous Integration with Jenkins assignment: deployed a persistent Jenkins LTS container behind HTTPS at \texttt{ci.ssw590-08.me} with firewall-restricted access; integrated Jenkins with the Scrap-Web Gitea repository through a dedicated integration account; added a pricing module, unit tests, and a versioned \texttt{Jenkinsfile}; protected \texttt{main} with a required Jenkins status check and one required approval; and demonstrated a failed, repaired, reviewed, and merged pull request. Updated the Hosts table (Jenkins host and ports) and the Passwords table (Jenkins administrator accounts and the Gitea integration token, hints only). & \ChapterRef{ContinuousIntegration}, \ChapterRef{PWDHST} \\
|
October 23, 2026 / 1.5 & SK, KH & Completed the Continuous Integration with Jenkins assignment: deployed a persistent Jenkins LTS container behind HTTPS at \texttt{ci.ssw590-08.me} with firewall-restricted access; integrated Jenkins with the Scrap-Web Gitea repository through a dedicated integration account; added a pricing module, unit tests, and a versioned \texttt{Jenkinsfile}; protected \texttt{main} with a required Jenkins status check and one required approval; and demonstrated a failed, repaired, reviewed, and merged pull request. Updated the Hosts table (Jenkins host and ports) and the Passwords table (Jenkins administrator accounts and the Gitea integration token, hints only). & \ChapterRef{ContinuousIntegration}, \ChapterRef{PWDHST} \\
|
||||||
|
|||||||
@@ -22,3 +22,7 @@
|
|||||||
\newglossaryentry{errorbudget}{name={error budget},description={The amount of failure an SLO allows over its window; for a 99\% target, 1\% of scheduled measurements}}
|
\newglossaryentry{errorbudget}{name={error budget},description={The amount of failure an SLO allows over its window; for a 99\% target, 1\% of scheduled measurements}}
|
||||||
\newglossaryentry{probe}{name={probe},description={A synthetic request, here an HTTPS GET from Blackbox Exporter, that tests whether a service responds as expected}}
|
\newglossaryentry{probe}{name={probe},description={A synthetic request, here an HTTPS GET from Blackbox Exporter, that tests whether a service responds as expected}}
|
||||||
\newglossaryentry{contactpoint}{name={contact point},description={The Grafana destination, such as a Discord webhook or email address, that receives alert notifications}}
|
\newglossaryentry{contactpoint}{name={contact point},description={The Grafana destination, such as a Discord webhook or email address, that receives alert notifications}}
|
||||||
|
\newglossaryentry{idempotence}{name={idempotence},description={The property that running the same deployment again on an already-correct system changes nothing}}
|
||||||
|
\newglossaryentry{imagedigest}{name={image digest},description={The SHA-256 content hash that identifies one exact container image in a registry; unlike a tag, it cannot be moved to another image}}
|
||||||
|
\newglossaryentry{releaserecord}{name={release record},description={A file that ties one deployment to its image digest, source commit, expected behavior, environment, and build}}
|
||||||
|
\newglossaryentry{trustedagent}{name={trusted agent},description={A Jenkins build node that holds deployment credentials and therefore runs only reviewed code}}
|
||||||
|
|||||||
@@ -66,6 +66,21 @@ Discord webhook (Grafana contact point \texttt{team-alerts})
|
|||||||
& Webhook URL stored only in Grafana's database; re-created from the Discord channel's Integrations $\rightarrow$ Webhooks settings\\
|
& Webhook URL stored only in Grafana's database; re-created from the Discord channel's Integrations $\rightarrow$ Webhooks settings\\
|
||||||
\hline
|
\hline
|
||||||
|
|
||||||
|
Deployment account (Ansible)
|
||||||
|
& deploy
|
||||||
|
& No password; SSH key stored only in Jenkins credential \texttt{deploy-ssh}\\
|
||||||
|
\hline
|
||||||
|
Gitea container registry
|
||||||
|
& Push: Jenkins credential \texttt{gitea-registry-push}; pull: root on the Droplet
|
||||||
|
& Package-write and package-read tokens; never stored in Git, logs, or screenshots\\
|
||||||
|
\hline
|
||||||
|
Production approvers (Jenkins)
|
||||||
|
& samahk, kaylah7
|
||||||
|
& Personal Jenkins logins; passwords not recorded here. Only these users can approve production or a production rollback\\
|
||||||
|
\hline
|
||||||
|
Jenkins delivery agent
|
||||||
|
& delivery-agent
|
||||||
|
& Agent secret in a file on the Droplet beside \texttt{agent/compose.yaml}; not in Git\\
|
||||||
\end{longtable}
|
\end{longtable}
|
||||||
|
|
||||||
|
|
||||||
@@ -100,7 +115,7 @@ Jenkins Web Interface & ci.ssw590-08.me & 443 & HTTPS access to Jenkins through
|
|||||||
\hline
|
\hline
|
||||||
Jenkins Container & jenkins & 8080 & Internal Docker network web service; not published on the host \\
|
Jenkins Container & jenkins & 8080 & Internal Docker network web service; not published on the host \\
|
||||||
\hline
|
\hline
|
||||||
Jenkins Agent Port & jenkins & 50000 & Not published on the host; no separate build agent is used \\
|
Jenkins Agent Port & jenkins & 50000 & Not published on the host and not used; the delivery agent connects over WebSocket through port 8080 on \texttt{gitea-net} \\
|
||||||
\hline
|
\hline
|
||||||
Grafana Web Interface & metrics.ssw590-08.me & 443 & HTTPS access to Grafana through Caddy \\
|
Grafana Web Interface & metrics.ssw590-08.me & 443 & HTTPS access to Grafana through Caddy \\
|
||||||
\hline
|
\hline
|
||||||
@@ -112,4 +127,12 @@ Node Exporter Container & node-exporter & 9100 & Private, \texttt{monitoring} ne
|
|||||||
\hline
|
\hline
|
||||||
Blackbox Exporter Container & blackbox-exporter & 9115 & Private, \texttt{monitoring} network only; HTTPS probes of Gitea and Jenkins \\
|
Blackbox Exporter Container & blackbox-exporter & 9115 & Private, \texttt{monitoring} network only; HTTPS probes of Gitea and Jenkins \\
|
||||||
\hline
|
\hline
|
||||||
|
Staging Application & staging.ssw590-08.me & 443 & HTTPS access to the staging pricing service through Caddy \\
|
||||||
|
\hline
|
||||||
|
Production Application & app.ssw590-08.me & 443 & HTTPS access to the production-like pricing service through Caddy \\
|
||||||
|
\hline
|
||||||
|
Pricing Containers & pricing-staging, pricing-production & 8000 & Private, \texttt{gitea-net} only; Gunicorn; not published on the host; Compose projects under \texttt{/opt/startup/pricing-\{staging,production\}}; no data volume \\
|
||||||
|
\hline
|
||||||
|
Jenkins Delivery Agent & jenkins-agent & None & Container on \texttt{gitea-net}; runs Docker builds and Ansible; mounts the host Docker socket; state in volume \texttt{agent\_home} \\
|
||||||
|
\hline
|
||||||
\end{longtable}
|
\end{longtable}
|
||||||
@@ -95,3 +95,111 @@
|
|||||||
url = {https://docs.digitalocean.com/support/why-is-smtp-blocked/},
|
url = {https://docs.digitalocean.com/support/why-is-smtp-blocked/},
|
||||||
note = {Accessed: Oct. 28, 2026}
|
note = {Accessed: Oct. 28, 2026}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@misc{AnsibleCompose,
|
||||||
|
author = {{Ansible Project}},
|
||||||
|
title = {{community.docker.docker\_compose\_v2 module}},
|
||||||
|
howpublished = {Ansible Documentation},
|
||||||
|
year = {2026},
|
||||||
|
url = {https://docs.ansible.com/ansible/latest/collections/community/docker/docker_compose_v2_module.html},
|
||||||
|
note = {Accessed: Nov. 13, 2026}
|
||||||
|
}
|
||||||
|
|
||||||
|
@misc{AnsibleInstall,
|
||||||
|
author = {{Ansible Project}},
|
||||||
|
title = {{Installing Ansible}},
|
||||||
|
howpublished = {Ansible Documentation},
|
||||||
|
year = {2026},
|
||||||
|
url = {https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html},
|
||||||
|
note = {Accessed: Nov. 13, 2026}
|
||||||
|
}
|
||||||
|
|
||||||
|
@misc{GiteaContainerRegistry,
|
||||||
|
author = {{Gitea}},
|
||||||
|
title = {{Container Registry}},
|
||||||
|
howpublished = {Gitea Documentation},
|
||||||
|
year = {2026},
|
||||||
|
url = {https://docs.gitea.com/usage/packages/container},
|
||||||
|
note = {Accessed: Nov. 13, 2026}
|
||||||
|
}
|
||||||
|
|
||||||
|
@misc{DockerPullDigest,
|
||||||
|
author = {{Docker Inc.}},
|
||||||
|
title = {{docker image pull: Pull an image by digest}},
|
||||||
|
howpublished = {Docker Documentation},
|
||||||
|
year = {2026},
|
||||||
|
url = {https://docs.docker.com/reference/cli/docker/image/pull/},
|
||||||
|
note = {Accessed: Nov. 13, 2026}
|
||||||
|
}
|
||||||
|
|
||||||
|
@misc{JenkinsAgents,
|
||||||
|
author = {{Jenkins Project}},
|
||||||
|
title = {{Using Jenkins agents}},
|
||||||
|
howpublished = {Jenkins User Documentation},
|
||||||
|
year = {2026},
|
||||||
|
url = {https://www.jenkins.io/doc/book/using/using-agents/},
|
||||||
|
note = {Accessed: Nov. 13, 2026}
|
||||||
|
}
|
||||||
|
|
||||||
|
@misc{TrivyDocs,
|
||||||
|
author = {{Aqua Security}},
|
||||||
|
title = {{Trivy Documentation}},
|
||||||
|
howpublished = {Trivy project documentation},
|
||||||
|
year = {2026},
|
||||||
|
url = {https://trivy.dev/docs/latest/},
|
||||||
|
note = {Accessed: Nov. 13, 2026}
|
||||||
|
}
|
||||||
|
|
||||||
|
@misc{PipAudit,
|
||||||
|
author = {{Python Packaging Authority}},
|
||||||
|
title = {{pip-audit: Audit Python environments and requirements for known vulnerabilities}},
|
||||||
|
howpublished = {Project repository},
|
||||||
|
year = {2026},
|
||||||
|
url = {https://github.com/pypa/pip-audit},
|
||||||
|
note = {Accessed: Nov. 13, 2026}
|
||||||
|
}
|
||||||
|
|
||||||
|
@misc{JenkinsInput,
|
||||||
|
author = {{Jenkins Project}},
|
||||||
|
title = {{Pipeline: Input Step}},
|
||||||
|
howpublished = {Jenkins Pipeline Steps Reference},
|
||||||
|
year = {2026},
|
||||||
|
url = {https://www.jenkins.io/doc/pipeline/steps/pipeline-input-step/},
|
||||||
|
note = {Accessed: Nov. 13, 2026}
|
||||||
|
}
|
||||||
|
|
||||||
|
@misc{ZammadCompose,
|
||||||
|
author = {{Zammad GmbH}},
|
||||||
|
title = {{zammad-docker-compose: Zammad Docker Compose deployment}},
|
||||||
|
howpublished = {GitHub repository},
|
||||||
|
year = {2026},
|
||||||
|
url = {https://github.com/zammad/zammad-docker-compose},
|
||||||
|
note = {Accessed: Nov. 29, 2026}
|
||||||
|
}
|
||||||
|
|
||||||
|
@misc{ZammadDocker,
|
||||||
|
author = {{Zammad GmbH}},
|
||||||
|
title = {{Install with Docker Compose}},
|
||||||
|
howpublished = {Zammad System Documentation},
|
||||||
|
year = {2026},
|
||||||
|
url = {https://docs.zammad.org/en/latest/install/docker-compose.html},
|
||||||
|
note = {Accessed: Nov. 29, 2026}
|
||||||
|
}
|
||||||
|
|
||||||
|
@misc{ZammadHardware,
|
||||||
|
author = {{Zammad GmbH}},
|
||||||
|
title = {{Hardware Requirements}},
|
||||||
|
howpublished = {Zammad System Documentation},
|
||||||
|
year = {2026},
|
||||||
|
url = {https://docs.zammad.org/en/latest/prerequisites/hardware.html},
|
||||||
|
note = {Accessed: Nov. 29, 2026}
|
||||||
|
}
|
||||||
|
|
||||||
|
@misc{ZammadRoles,
|
||||||
|
author = {{Zammad GmbH}},
|
||||||
|
title = {{Roles}},
|
||||||
|
howpublished = {Zammad Admin Documentation},
|
||||||
|
year = {2026},
|
||||||
|
url = {https://admin-docs.zammad.org/en/latest/manage/roles/index.html},
|
||||||
|
note = {Accessed: Nov. 29, 2026}
|
||||||
|
}
|
||||||
|
|||||||
@@ -0,0 +1,498 @@
|
|||||||
|
\chapter{Support Ticket Management with Zammad}
|
||||||
|
\ChapterLabel{SupportDesk}
|
||||||
|
\index{Zammad}
|
||||||
|
\index{help desk}
|
||||||
|
\sloppy
|
||||||
|
|
||||||
|
% Red marker for values still to be filled in from the team's own outputs.
|
||||||
|
\providecommand{\FillIn}[1]{\textcolor{devopsRed}{\textbf{[TO FILL: #1]}}}
|
||||||
|
% Figure helper: shows a labelled box until the screenshot file exists.
|
||||||
|
\providecommand{\zfig}[4]{%
|
||||||
|
\begin{figure}[H]\centering
|
||||||
|
\IfFileExists{HW9 images/#1}{\includegraphics[width=#2\linewidth]{HW9 images/#1}}%
|
||||||
|
{\fbox{\parbox{0.8\linewidth}{\centering\vspace{1em}\textit{[Screenshot needed: HW9 images/#1]}\vspace{1em}}}}
|
||||||
|
\caption{#3}\label{#4}\end{figure}}
|
||||||
|
|
||||||
|
This chapter gives the startup's customers and operations team a shared place to
|
||||||
|
report problems, assign responsibility, and record the resolution. The official
|
||||||
|
Zammad Docker Compose stack~\cite{ZammadCompose,ZammadDocker} is deployed
|
||||||
|
unchanged as its own Compose project, three synthetic tickets are worked through
|
||||||
|
triage and resolution, one ticket is linked to an engineering issue in Gitea, and
|
||||||
|
the web service is stopped and restarted to show that tickets persist.
|
||||||
|
|
||||||
|
\textbf{Local deployment.} Zammad recommends at least two CPU cores and 6~GB of
|
||||||
|
RAM, plus 4~GB more when Elasticsearch runs on the same host~\cite{ZammadHardware}.
|
||||||
|
The team's Droplet was already short of memory after Chapter~\ref{Chapter:SecureDelivery}.
|
||||||
|
As the instructor permitted for this final assignment, Zammad was therefore deployed
|
||||||
|
with Docker on a team member's laptop instead of the Droplet. For a local
|
||||||
|
deployment the instructor waived integration with the Droplet's HTTPS proxy,
|
||||||
|
firewall, and monitoring, so Steps~5, 6, and~9 of the assignment are replaced by
|
||||||
|
the local checks in Sections~\ref{sec:z-exposure} and~\ref{sec:z-recovery}. A
|
||||||
|
video submitted in Canvas shows the running installation and every workflow,
|
||||||
|
because the TA cannot reach a local installation.
|
||||||
|
|
||||||
|
\textbf{Division of work.} \texttt{kholmes} deployed and operated Zammad on her
|
||||||
|
laptop (Sections~\ref{sec:z-baseline}--\ref{sec:z-workflow}
|
||||||
|
and~\ref{sec:z-recovery}) and recorded the video. \texttt{samahk13} created the
|
||||||
|
Gitea issue and its links (Section~\ref{sec:z-gitea}), rechecked the existing
|
||||||
|
services (Section~\ref{sec:z-retest}), and wrote this chapter.
|
||||||
|
|
||||||
|
\section{Deployment Architecture}
|
||||||
|
\label{sec:z-architecture}
|
||||||
|
|
||||||
|
\zfig{zammad-architecture.png}{0.95}{Local Zammad deployment. Blue boxes are
|
||||||
|
Zammad containers, gray boxes are named volumes. Only \texttt{zammad-nginx} is
|
||||||
|
published, and only on the laptop's loopback address; every other service is
|
||||||
|
reachable only on the Compose project's private network.}{fig:z-architecture}
|
||||||
|
|
||||||
|
\begin{itemize}
|
||||||
|
\item \textbf{Entry point:} \texttt{zammad-nginx} is published on
|
||||||
|
\texttt{127.0.0.1:8080}, so only a browser on the same laptop can reach it.
|
||||||
|
There is no TLS: traffic never leaves the machine, and the HTTPS proxy was
|
||||||
|
waived for local installs. Zammad is configured for plain HTTP
|
||||||
|
(\texttt{ZAMMAD\_HTTP\_TYPE=http}, \texttt{NGINX\_SERVER\_SCHEME=http}), which
|
||||||
|
must match the scheme the browser uses or login fails with a CSRF error.
|
||||||
|
\item \textbf{Private services:} PostgreSQL, Elasticsearch, Redis, Memcached,
|
||||||
|
the Rails server, WebSocket server, scheduler, and backup service are on the
|
||||||
|
project network only, with no published ports.
|
||||||
|
\item \textbf{Earlier services:} Gitea, Jenkins, Caddy, monitoring, and the
|
||||||
|
Chapter~\ref{Chapter:SecureDelivery} application stay on the Droplet,
|
||||||
|
unchanged. The only link is a manual one: a ticket holds a Gitea issue URL,
|
||||||
|
and the issue holds the ticket number.
|
||||||
|
\end{itemize}
|
||||||
|
|
||||||
|
\section{Capacity Baseline}
|
||||||
|
\label{sec:z-baseline}
|
||||||
|
|
||||||
|
Both team laptops have 8~GB of RAM. The Windows laptop had only about 0.9~GB
|
||||||
|
free with normal applications open, so the macOS laptop was used.
|
||||||
|
|
||||||
|
\begin{tabularx}{\linewidth}{L{4.2cm}Y}
|
||||||
|
\toprule
|
||||||
|
\textbf{Item} & \textbf{Value}\\ \midrule
|
||||||
|
Host & MacBook Pro, Apple silicon (\texttt{arm64}), 8 CPU cores\\
|
||||||
|
Memory & 8~GB total (\texttt{hw.memsize} 8{,}589{,}934{,}592 bytes); 49--50\% free before start-up\\
|
||||||
|
Docker Desktop memory limit & 5.78~GiB (the container limit shown by \texttt{docker stats})\\
|
||||||
|
Docker / Compose & Docker Desktop 4.91.0, Engine 29.8.0 (\texttt{linux/arm64}); Compose v5.5.1\\
|
||||||
|
Disk free & 24~GiB available on \texttt{/}\\
|
||||||
|
\bottomrule
|
||||||
|
\end{tabularx}
|
||||||
|
|
||||||
|
\zfig{baseline.png}{0.75}{Capacity baseline on the laptop before Zammad was
|
||||||
|
started. The only running container was the team's existing Gitea Actions LaTeX
|
||||||
|
runner (37~MiB).}{fig:z-baseline}
|
||||||
|
|
||||||
|
\section{Official Compose Stack}
|
||||||
|
\label{sec:z-deploy}
|
||||||
|
|
||||||
|
\subsection{Obtaining a Fixed Revision}
|
||||||
|
The official repository was cloned into its own directory and checked out
|
||||||
|
detached, so the exact revision is recorded~\cite{ZammadCompose}:
|
||||||
|
\begin{minted}[breaklines,breakanywhere]{bash}
|
||||||
|
mkdir -p ~/dos-support && cd ~/dos-support
|
||||||
|
git clone https://github.com/zammad/zammad-docker-compose.git
|
||||||
|
cd zammad-docker-compose
|
||||||
|
git switch --detach
|
||||||
|
git rev-parse HEAD
|
||||||
|
cp .env.dist .env && chmod 600 .env
|
||||||
|
\end{minted}
|
||||||
|
|
||||||
|
Recorded commit: \texttt{67141451b6239190f7a616231bff20b8b0ccbd8a}. The image versions are the ones fixed
|
||||||
|
by that commit and were not changed:
|
||||||
|
|
||||||
|
\begin{tabularx}{\linewidth}{L{4.4cm}Y}
|
||||||
|
\toprule
|
||||||
|
\textbf{Service} & \textbf{Image}\\ \midrule
|
||||||
|
Zammad (nginx, railsserver, websocket, scheduler, init, backup) & \texttt{ghcr.io/zammad/zammad:7.3.0-0011}\\
|
||||||
|
Elasticsearch & \texttt{elasticsearch:9.5.7}\\
|
||||||
|
PostgreSQL & \texttt{postgres:17.12-alpine}\\
|
||||||
|
Redis & \texttt{redis:8.12-alpine}\\
|
||||||
|
Memcached & \texttt{memcached:1.6.45-alpine}\\
|
||||||
|
\bottomrule
|
||||||
|
\end{tabularx}
|
||||||
|
|
||||||
|
\subsection{Configuration}
|
||||||
|
The real \texttt{.env} stays on the laptop with mode 600. A sanitized copy,
|
||||||
|
\href{https://git.ssw590-08.me/SSW-590-08/Scrap-Web/src/branch/main/support/zammad.env.example}{\texttt{support/zammad.env.example}},
|
||||||
|
is kept in Gitea:
|
||||||
|
|
||||||
|
\begin{minted}[breaklines,breakanywhere]{bash}
|
||||||
|
COMPOSE_PROJECT_NAME=dos-support
|
||||||
|
COMPOSE_FILE=docker-compose.yml:scenarios/apply-resource-limits.yml
|
||||||
|
|
||||||
|
# Local only: loopback port, plain HTTP
|
||||||
|
NGINX_EXPOSE_PORT=127.0.0.1:8080
|
||||||
|
ZAMMAD_FQDN=localhost:8080
|
||||||
|
ZAMMAD_HTTP_TYPE=http
|
||||||
|
NGINX_SERVER_SCHEME=http
|
||||||
|
|
||||||
|
# Unique generated values (openssl rand -hex 24); never committed
|
||||||
|
POSTGRES_PASS=<generated>
|
||||||
|
ELASTICSEARCH_PASS=<generated>
|
||||||
|
|
||||||
|
# Low-memory settings for an 8 GB laptop
|
||||||
|
ELASTICSEARCH_JAVA_OPTS=-Xms512m -Xmx512m
|
||||||
|
ZAMMAD_ELASTICSEARCH_RESOURCES_LIMITS_MEMORY=1G
|
||||||
|
ZAMMAD_RAILSSERVER_RESOURCES_LIMITS_MEMORY=1G
|
||||||
|
ZAMMAD_SCHEDULER_RESOURCES_LIMITS_MEMORY=1G
|
||||||
|
ZAMMAD_INIT_RESOURCES_LIMITS_MEMORY=1G
|
||||||
|
|
||||||
|
# First backup at start-up instead of only at 03:00; local time zone
|
||||||
|
BACKUP_ON_START=true
|
||||||
|
TZ=America/New_York
|
||||||
|
\end{minted}
|
||||||
|
|
||||||
|
\textbf{Deviations from the assignment's Droplet configuration.} The
|
||||||
|
external-network scenario is not loaded, because there is no proxy to join; the
|
||||||
|
host-proxy alternative's loopback port is used instead. The
|
||||||
|
\texttt{apply-resource-limits.yml} scenario and a 512~MB Elasticsearch heap are
|
||||||
|
loaded because the laptop has 8~GB in total. Both scenario files are part of the
|
||||||
|
official repository, and no image was built or replaced.
|
||||||
|
|
||||||
|
\subsection{Validation and Start-up}
|
||||||
|
Elasticsearch needs \texttt{vm.max\_map\_count=262144}~\cite{ZammadDocker}. On
|
||||||
|
macOS the setting belongs to Docker Desktop's Linux VM, not to macOS, so it was
|
||||||
|
applied there:
|
||||||
|
\begin{minted}[breaklines,breakanywhere]{bash}
|
||||||
|
docker run --rm --privileged alpine sysctl -w vm.max_map_count=262144
|
||||||
|
docker compose config --quiet
|
||||||
|
docker compose config --services
|
||||||
|
docker compose pull
|
||||||
|
docker compose up -d
|
||||||
|
docker compose ps -a
|
||||||
|
docker compose logs --tail=50 zammad-init zammad-railsserver zammad-nginx
|
||||||
|
\end{minted}
|
||||||
|
This setting lasts until Docker Desktop restarts and has to be applied again
|
||||||
|
after that.
|
||||||
|
|
||||||
|
\textbf{Start-up result.} The first start took about 15 minutes: the containers
|
||||||
|
were created 24 minutes before Figure~\ref{fig:z-ps} was taken and
|
||||||
|
\texttt{zammad-init} exited 9 minutes before it, with exit code 0. No container
|
||||||
|
restarted or was stopped for running out of memory, so no setting had to be
|
||||||
|
changed after the first start.
|
||||||
|
|
||||||
|
\zfig{compose-ps.png}{1.0}{\texttt{docker compose ps -a} in project
|
||||||
|
\texttt{dos-support}: every service up (PostgreSQL, Redis, Memcached, and the Rails
|
||||||
|
server healthy), \texttt{zammad-init} exited with code 0, and only nginx published,
|
||||||
|
on \texttt{127.0.0.1:8080}.}{fig:z-ps}
|
||||||
|
|
||||||
|
\zfig{docker-stats-after.png}{1.0}{\texttt{docker stats -{}-no-stream} after
|
||||||
|
start-up: memory used by each Zammad container against its limit.}{fig:z-stats}
|
||||||
|
|
||||||
|
\textbf{Before and after.} Before start-up, only the 37~MiB runner was running
|
||||||
|
and macOS reported 49--50\% of memory free. After start-up, the nine Zammad
|
||||||
|
containers used about 1.93~GiB together. Elasticsearch used 897~MiB, 88\% of its
|
||||||
|
1~GiB limit, and is the container closest to its cap; the Rails server (293~MiB)
|
||||||
|
and scheduler (333~MiB) stayed near a third of theirs. The 1~GiB caps were enough
|
||||||
|
for the stack to start and stay up.
|
||||||
|
|
||||||
|
\section{Network Exposure}
|
||||||
|
\label{sec:z-exposure}
|
||||||
|
|
||||||
|
Only \texttt{zammad-nginx} may be published, and only on loopback.
|
||||||
|
\begin{minted}[breaklines,breakanywhere]{bash}
|
||||||
|
docker compose ps --format "table {{.Service}}\t{{.Ports}}"
|
||||||
|
lsof -nP -iTCP -sTCP:LISTEN | grep -E ':(8080|5432|9200|6379|11211)'
|
||||||
|
\end{minted}
|
||||||
|
Only nginx has a host binding, \texttt{127.0.0.1:8080->8080/tcp}. PostgreSQL
|
||||||
|
(5432), Elasticsearch (9200, 9300), Redis (6379), and Memcached (11211) list their
|
||||||
|
ports as container ports only, and \texttt{lsof} finds a single listening socket
|
||||||
|
among the checked ports: \texttt{127.0.0.1:8080}, owned by Docker Desktop.
|
||||||
|
|
||||||
|
\zfig{exposure.png}{1.0}{Published ports: only \texttt{127.0.0.1:8080}; no
|
||||||
|
database, search, cache, or Redis port listens on the laptop.}{fig:z-exposure}
|
||||||
|
|
||||||
|
The control that enforces this is the Compose file itself: no internal service
|
||||||
|
declares a \texttt{ports} entry, and \texttt{NGINX\_EXPOSE\_PORT} binds nginx to
|
||||||
|
the loopback address. A loopback binding is not reachable from the local network
|
||||||
|
whatever the macOS firewall setting is. The Droplet's cloud firewall and Caddy
|
||||||
|
are not involved, and no rule was added to either.
|
||||||
|
|
||||||
|
\section{Support Workflow and TA Access}
|
||||||
|
\label{sec:z-workflow}
|
||||||
|
|
||||||
|
\subsection{Accounts and Roles}
|
||||||
|
Self-registration was turned off, and every account was created directly by the
|
||||||
|
administrator with an initial password set administratively, since no email
|
||||||
|
channel is configured~\cite{ZammadRoles}.
|
||||||
|
|
||||||
|
\begin{tabularx}{\linewidth}{L{3.2cm}L{2.4cm}Y}
|
||||||
|
\toprule
|
||||||
|
\textbf{Account} & \textbf{Role} & \textbf{Group access}\\ \midrule
|
||||||
|
Admin Admin & Admin & Startup Support, Users\\
|
||||||
|
Test Agent (student agent) & Agent & Startup Support\\
|
||||||
|
TA User & Agent (not Admin) & Startup Support\\
|
||||||
|
Customer User (synthetic) & Customer & none: own tickets only\\
|
||||||
|
Secondary Customer (synthetic) & Customer & none: own tickets only\\
|
||||||
|
\bottomrule
|
||||||
|
\end{tabularx}
|
||||||
|
|
||||||
|
\medskip
|
||||||
|
All names and email addresses are synthetic. No password appears in this manual
|
||||||
|
or in Gitea; the TA login is given in the Canvas submission.
|
||||||
|
|
||||||
|
\subsection{Example Tickets}
|
||||||
|
\begin{tabularx}{\linewidth}{L{1.3cm}L{3.0cm}L{1.2cm}L{1.5cm}L{2.4cm}Y}
|
||||||
|
\toprule
|
||||||
|
\textbf{Ticket} & \textbf{Title} & \textbf{State} & \textbf{Priority} & \textbf{Owner} & \textbf{Customer}\\ \midrule
|
||||||
|
\#63002 & OpenUnassigned & open & normal & none & Secondary Customer\\
|
||||||
|
\#63003 & OpenAssigned (investigating) & open & high & Test Agent & Secondary Customer\\
|
||||||
|
\#63005 & ResolvedTicket & closed & low & Admin Admin & Customer User\\
|
||||||
|
\#63004 & ClosedTicket & closed & normal & Admin Admin & Secondary Customer\\
|
||||||
|
\#63006 & TestingWorkflow (TA test) & closed & normal & TA User & Customer User\\
|
||||||
|
\bottomrule
|
||||||
|
\end{tabularx}
|
||||||
|
|
||||||
|
\zfig{tickets-overview.png}{1.0}{Ticket overview: the four example tickets and
|
||||||
|
the TA's test ticket \#63006, with their states, priorities, and
|
||||||
|
owners.}{fig:z-tickets}
|
||||||
|
|
||||||
|
\subsection{Internal Note, Customer Reply, and Visibility}
|
||||||
|
In ticket \#63002, the agent added an internal note (``This will be an internal
|
||||||
|
note, the customer cannot view'') and then a public reply through the web
|
||||||
|
interface. Logged in as Secondary Customer in a separate private window, the
|
||||||
|
customer saw the public reply but not the internal note, and the customer's
|
||||||
|
ticket list showed only that customer's own tickets, \#63002, \#63003, and
|
||||||
|
\#63004; \#63005 and \#63006 belong to Customer User and were not listed.
|
||||||
|
Self-registration is off (Figure~\ref{fig:z-selfreg}), so a customer account
|
||||||
|
exists only if the administrator creates it.
|
||||||
|
|
||||||
|
\zfig{self-registration.png}{1.0}{Demo video, 0:56 --- Security settings: new
|
||||||
|
user accounts (self-registration) set to \emph{no}.}{fig:z-selfreg}
|
||||||
|
|
||||||
|
\zfig{agent-view.png}{1.0}{Demo video, 2:32 --- agent view of ticket \#63002:
|
||||||
|
the internal note is marked internal, and a public reply is being
|
||||||
|
added.}{fig:z-agent-view}
|
||||||
|
|
||||||
|
\zfig{customer-tickets.png}{1.0}{Demo video, 2:45 --- Secondary Customer's
|
||||||
|
\emph{My Tickets}: only \#63002, \#63003, and \#63004.}{fig:z-customer-tickets}
|
||||||
|
|
||||||
|
\zfig{customer-view.png}{1.0}{Demo video, 4:48 --- ticket \#63002 in the
|
||||||
|
customer's session: the public reply is shown and the internal note is
|
||||||
|
not.}{fig:z-customer-view}
|
||||||
|
|
||||||
|
\subsection{TA Account Test}
|
||||||
|
In a separate private window, the TA account created test ticket \#63006
|
||||||
|
``TestingWorkflow'' for Customer User, replied to it (``This is my reply''), set
|
||||||
|
an owner, and closed it, all without administrator rights; the Admin settings
|
||||||
|
were not available to it.
|
||||||
|
|
||||||
|
\zfig{ta-test.png}{1.0}{Demo video, 3:48 --- TA session: replying to test
|
||||||
|
ticket \#63006 and choosing its owner; no Admin menu.}{fig:z-ta}
|
||||||
|
|
||||||
|
\subsection{TA Checklist}
|
||||||
|
\begin{enumerate}
|
||||||
|
\item \textbf{Evidence:} the video in the Canvas submission. The installation
|
||||||
|
is on a team laptop and is not reachable remotely.
|
||||||
|
\item \textbf{URL (local):} \texttt{http://localhost:8080}.
|
||||||
|
\item \textbf{Account:} TA User, role Agent, group Startup Support
|
||||||
|
with full access. The password is in the Canvas submission text, not here.
|
||||||
|
\item \textbf{Example tickets:} open \#63002, investigating \#63003, closed
|
||||||
|
\#63004 and \#63005; Gitea-linked ticket \#63003; TA test ticket \#63006.
|
||||||
|
\item \textbf{Test steps:} New Ticket $\rightarrow$ customer, group Startup
|
||||||
|
Support, title, text $\rightarrow$ Create; reply in the article box with
|
||||||
|
visibility Public $\rightarrow$ Update; set Owner $\rightarrow$ Update; set
|
||||||
|
State to closed $\rightarrow$ Update.
|
||||||
|
\end{enumerate}
|
||||||
|
|
||||||
|
\section{Link to Engineering in Gitea}
|
||||||
|
\label{sec:z-gitea}
|
||||||
|
|
||||||
|
Ticket\#63003 reports a problem that needs a software change, so it was linked
|
||||||
|
to Gitea issue
|
||||||
|
\href{https://git.ssw590-08.me/SSW-590-08/Scrap-Web/issues/30}{\#30}:
|
||||||
|
\begin{itemize}
|
||||||
|
\item \textbf{Report:} the synthetic customer Secondary Customer wrote on the
|
||||||
|
ticket: ``when I typed `abc' as the quantity, the page showed a confusing
|
||||||
|
technical error.'' \texttt{GET /price?quantity=abc} returns HTTP 400 with
|
||||||
|
Python's internal text \texttt{invalid literal for int() with base 10: 'abc'}.
|
||||||
|
\item \textbf{Issue \#30:} ``Ticket\#63003: Non-numeric quantity returns a
|
||||||
|
technical error message.'' Its description quotes the ticket. Acceptance
|
||||||
|
criterion: \texttt{GET /price?quantity=abc} returns HTTP 400 with the message
|
||||||
|
\texttt{quantity must be a whole number between 1 and 1000}, and a unit test
|
||||||
|
covers it.
|
||||||
|
\item \textbf{Ticket:} an internal note on Ticket\#63003 holds the clickable
|
||||||
|
issue URL, so agents can follow the engineering work.
|
||||||
|
\item \textbf{Fix:} in \texttt{pricing/app.py}, every rejected quantity now
|
||||||
|
returns one fixed message, \texttt{QUANTITY\_ERROR}, instead of
|
||||||
|
\texttt{str(error)}, so Python's internal text never reaches the customer.
|
||||||
|
A new unit test, \texttt{test\_non\_numeric\_quantity\_message}, requests
|
||||||
|
\texttt{/price?quantity=abc} and checks for HTTP 400 and the exact message;
|
||||||
|
the existing \texttt{test\_invalid\_quantity} still covers 0, $-1$, 1001,
|
||||||
|
\texttt{abc}, and 1.5.
|
||||||
|
\begin{minted}[breaklines]{python}
|
||||||
|
QUANTITY_ERROR = "quantity must be a whole number between 1 and 1000"
|
||||||
|
...
|
||||||
|
except ValueError:
|
||||||
|
return jsonify(error=QUANTITY_ERROR), 400
|
||||||
|
\end{minted}
|
||||||
|
\item \textbf{Release:} commit \texttt{291c38b} (``Pricing: clear message
|
||||||
|
for non-numeric quantity (fixes \#30)'') ran through Jenkins run
|
||||||
|
\FillIn{\#7 v1.0.7}: all four unit tests passed, the security gate passed,
|
||||||
|
and the release was approved and deployed.
|
||||||
|
\item \textbf{Verification and closure:} after the deploy,
|
||||||
|
\texttt{GET /price?quantity=abc} returned HTTP 400 with
|
||||||
|
\texttt{quantity must be a whole number between 1 and 1000}. Issue \#30 was
|
||||||
|
closed by the commit, and Ticket\#63003 got a public reply telling the
|
||||||
|
customer the fix was live and was then set to closed.
|
||||||
|
\end{itemize}
|
||||||
|
|
||||||
|
\zfig{ticket-issue-link.png}{1.0}{Ticket\#63003
|
||||||
|
with the customer's report and the internal note linking Gitea issue
|
||||||
|
\#30.}{fig:z-ticket-link}
|
||||||
|
|
||||||
|
\zfig{issue-ticket-link.png}{1.0}{December 2, 2026 --- Gitea issue \#30
|
||||||
|
referencing Ticket\#63003, with its acceptance criterion.}{fig:z-issue-link}
|
||||||
|
|
||||||
|
The link is manual, as the assignment requires. No webhook, API automation, or
|
||||||
|
alert-to-ticket integration was configured.
|
||||||
|
|
||||||
|
\section{Restart, Persistence, and Backup}
|
||||||
|
\label{sec:z-recovery}
|
||||||
|
|
||||||
|
\subsection{Controlled Web-Service Outage}
|
||||||
|
Ticket \#63002, with its internal note and public reply, was the reference
|
||||||
|
ticket. Because the Droplet's
|
||||||
|
Prometheus cannot reach a local installation, the destination was checked once
|
||||||
|
per second from the laptop instead of by the Blackbox probe:
|
||||||
|
\begin{minted}[breaklines,breakanywhere]{bash}
|
||||||
|
while true; do echo "$(date +%T) $(curl -s -o /dev/null -w '%{http_code}' http://localhost:8080/)"; sleep 1; done | tee ~/zammad-outage.log
|
||||||
|
docker compose stop zammad-nginx # announced test window
|
||||||
|
docker compose start zammad-nginx
|
||||||
|
docker compose ps -a
|
||||||
|
\end{minted}
|
||||||
|
|
||||||
|
\begin{tabularx}{\linewidth}{L{3.4cm}Y}
|
||||||
|
\toprule
|
||||||
|
\textbf{Time (min:s)} & \textbf{Observation}\\ \midrule
|
||||||
|
before \texttt{:21:35} & \texttt{docker compose stop zammad-nginx}; checks return 200 until then\\
|
||||||
|
\texttt{:21:35} & First failed request (curl status \texttt{000}, connection refused)\\
|
||||||
|
\texttt{:22:05} & Last failed request; \texttt{docker compose start zammad-nginx} run\\
|
||||||
|
\texttt{:22:06} & First successful request (HTTP 200) again\\
|
||||||
|
\bottomrule
|
||||||
|
\end{tabularx}
|
||||||
|
|
||||||
|
\medskip
|
||||||
|
The hour is cut off in the recording, so only minutes and seconds are shown.
|
||||||
|
There were 31 failed checks, an outage of about 31 seconds, and
|
||||||
|
\texttt{docker compose ps} showed every service healthy again, with nginx ``Up
|
||||||
|
less than a second'' (Figure~\ref{fig:z-restart}). After logging back in,
|
||||||
|
ticket \#63002 and its whole conversation were still there
|
||||||
|
(Figure~\ref{fig:z-customer-view}, taken after the restart). This is a web-service restart test, not a database
|
||||||
|
restore test: only nginx was stopped, and no volume was touched.
|
||||||
|
|
||||||
|
\zfig{restart.png}{1.0}{Demo video, 3:56 --- \texttt{docker compose stop} and
|
||||||
|
\texttt{start zammad-nginx}, then every service healthy.}{fig:z-restart}
|
||||||
|
|
||||||
|
\zfig{outage-log.png}{0.9}{Demo video, 4:26 --- per-second log: failed checks
|
||||||
|
(\texttt{000}) while nginx was stopped, then HTTP 200 again.}{fig:z-outage}
|
||||||
|
|
||||||
|
\subsection{Storage and Backup}
|
||||||
|
\begin{tabularx}{\linewidth}{L{6.0cm}Y}
|
||||||
|
\toprule
|
||||||
|
\textbf{Named volume (project \texttt{dos-support})} & \textbf{Contents}\\ \midrule
|
||||||
|
\texttt{dos-support\_postgresql-data} & Tickets, users, settings (database)\\
|
||||||
|
\texttt{dos-support\_elasticsearch-data} & Search index (can be rebuilt from the database)\\
|
||||||
|
\texttt{dos-support\_redis-data} & Sessions and job queue\\
|
||||||
|
\texttt{dos-support\_zammad-storage} & Attachments and application storage\\
|
||||||
|
\texttt{dos-support\_zammad-backup} & Backup archives written by \texttt{zammad-backup}\\
|
||||||
|
\bottomrule
|
||||||
|
\end{tabularx}
|
||||||
|
|
||||||
|
\medskip
|
||||||
|
Memcached is a disposable cache and has no volume. Volumes survive container
|
||||||
|
replacement, but they are on the same laptop, so they are not an off-machine
|
||||||
|
backup.
|
||||||
|
|
||||||
|
\begin{minted}[breaklines,breakanywhere]{bash}
|
||||||
|
docker volume ls | grep dos-support
|
||||||
|
docker compose logs --tail=20 zammad-backup
|
||||||
|
docker compose exec zammad-backup ls -lh /var/tmp/zammad
|
||||||
|
\end{minted}
|
||||||
|
All five named volumes exist, including \texttt{dos-support\_zammad-backup}
|
||||||
|
(Figure~\ref{fig:z-backup}). The \texttt{zammad-backup} service is running its
|
||||||
|
schedule: its log shows it waited for PostgreSQL and the init container, started
|
||||||
|
its backup loop, and is sleeping until the next scheduled run
|
||||||
|
(Figure~\ref{fig:z-backup-logs}). The backup directory was still empty
|
||||||
|
(\texttt{total 0}) when it was checked, because the first scheduled run had not
|
||||||
|
happened yet. So this lab shows that backups are configured and scheduled, not
|
||||||
|
that an archive has been written; the check is to run the \texttt{ls} command
|
||||||
|
again after the next scheduled time.
|
||||||
|
|
||||||
|
\zfig{backup.png}{1.0}{Demo video, 4:26 --- the five named volumes of project
|
||||||
|
\texttt{dos-support}.}{fig:z-backup}
|
||||||
|
|
||||||
|
\zfig{backup-logs.png}{1.0}{\texttt{zammad-backup} log (waiting, then sleeping
|
||||||
|
until the next run) and the still-empty backup directory.}{fig:z-backup-logs}
|
||||||
|
|
||||||
|
\textbf{Restore.} An operator would follow the backup and restore guide for the
|
||||||
|
same Zammad release~\cite{ZammadDocker}: stop the stack without removing volumes,
|
||||||
|
place the chosen backup in the \texttt{zammad-backup} volume as that guide
|
||||||
|
describes, start the stack so the backup is restored, and then check that a known
|
||||||
|
ticket and its attachments are present. No restore was performed in this lab.
|
||||||
|
|
||||||
|
\section{Earlier Services Retested}
|
||||||
|
\label{sec:z-retest}
|
||||||
|
|
||||||
|
The Droplet was not changed by this assignment. On November 29 and December 2, 2026, each
|
||||||
|
earlier service was checked again:
|
||||||
|
|
||||||
|
\begin{tabularx}{\linewidth}{L{4.0cm}Y}
|
||||||
|
\toprule
|
||||||
|
\textbf{Service} & \textbf{Result}\\ \midrule
|
||||||
|
Gitea (\url{https://git.ssw590-08.me}) & Dashboard loads; repository and recent activity shown (Figure~\ref{fig:z-gitea})\\
|
||||||
|
Jenkins (\url{https://ci.ssw590-08.me}) & \texttt{Scrap-Web} job listed; last success 14 seconds earlier, no failure; built-in node and delivery agent connected; Jenkins 2.580.1 (Figure~\ref{fig:z-jenkins})\\
|
||||||
|
Grafana (\url{https://metrics.ssw590-08.me}) & Reliability dashboard current on December 2 (last 6 hours): Gitea and Jenkins UP throughout, all six scrape targets UP including the production probe, CPU about 20\% apart from one build spike (Figure~\ref{fig:z-grafana})\\
|
||||||
|
Chapter~\ref{Chapter:SecureDelivery} application (\url{https://app.ssw590-08.me}) & Version \texttt{v2}, commit \texttt{d678772}; \texttt{/price?quantity=3} returns 36 (Figure~\ref{fig:z-app})\\
|
||||||
|
\bottomrule
|
||||||
|
\end{tabularx}
|
||||||
|
|
||||||
|
\zfig{recheck-gitea.png}{0.85}{November 29, 2026 --- Gitea dashboard.}{fig:z-gitea}
|
||||||
|
\zfig{recheck-jenkins.png}{0.85}{November 29, 2026 --- Jenkins: \texttt{Scrap-Web} last success, no failure.}{fig:z-jenkins}
|
||||||
|
\zfig{recheck-grafana-dashboard.png}{0.85}{December 2, 2026, 10:30 AM--4:30 PM
|
||||||
|
EST --- Grafana reliability dashboard: host panels, HTTPS probe durations, Gitea
|
||||||
|
and Jenkins UP, and every scrape target UP.}{fig:z-grafana}
|
||||||
|
\zfig{recheck-app.png}{0.85}{November 29, 2026 --- production pricing application:
|
||||||
|
v2 and a total of 36.}{fig:z-app}
|
||||||
|
|
||||||
|
\section{Operations Runbook}
|
||||||
|
\label{sec:z-runbook}
|
||||||
|
All commands run from \texttt{\textasciitilde/dos-support/zammad-docker-compose},
|
||||||
|
so the same \texttt{.env} and scenario files are loaded.
|
||||||
|
|
||||||
|
\begin{enumerate}
|
||||||
|
\item \textbf{Start:} open Docker Desktop; run
|
||||||
|
\texttt{docker run -{}-rm -{}-privileged alpine sysctl -w vm.max\_map\_count=262144};
|
||||||
|
then \texttt{docker compose up -d}; wait until \texttt{docker compose ps -a}
|
||||||
|
shows all services healthy and \texttt{zammad-init} exited with code 0.
|
||||||
|
\item \textbf{Check:} open \texttt{http://localhost:8080} and log in as an agent.
|
||||||
|
\item \textbf{Restart the web service:} \texttt{docker compose restart
|
||||||
|
zammad-nginx}.
|
||||||
|
\item \textbf{Investigate:} \texttt{docker compose logs -{}-tail=50
|
||||||
|
zammad-railsserver zammad-nginx}; \texttt{docker stats -{}-no-stream} for
|
||||||
|
memory pressure.
|
||||||
|
\item \textbf{Stop without losing data:} \texttt{docker compose stop}
|
||||||
|
(or \texttt{docker compose down} without \texttt{-v}).
|
||||||
|
\item \textbf{Never} run \texttt{docker compose down -v} or remove the
|
||||||
|
\texttt{dos-support\_*} volumes.
|
||||||
|
\item \textbf{After grading:} disable the TA account in Admin $\rightarrow$
|
||||||
|
Users, then stop the stack. The laptop has no recurring cost.
|
||||||
|
\end{enumerate}
|
||||||
|
|
||||||
|
\section{Limitations}
|
||||||
|
\label{sec:z-limits}
|
||||||
|
\begin{itemize}
|
||||||
|
\item Zammad runs on a laptop, not the Droplet: there is no public hostname,
|
||||||
|
TLS certificate, Caddy route, cloud-firewall check, or Prometheus/Grafana
|
||||||
|
panel for it. These were waived for local installs; no Droplet test is
|
||||||
|
claimed.
|
||||||
|
\item The laptop has 8~GB of RAM, below Zammad's recommendation, so the stack
|
||||||
|
runs with official memory-limit settings and a 512~MB Elasticsearch heap.
|
||||||
|
It is suitable for this lab, not for production load.
|
||||||
|
\item The service is only available while the laptop and Docker Desktop are
|
||||||
|
running, and the backups are on the same laptop.
|
||||||
|
\item No email channel is configured, so passwords were set administratively
|
||||||
|
and notifications are not sent.
|
||||||
|
\end{itemize}
|
||||||
|
|
||||||
|
\fussy
|
||||||
@@ -23,6 +23,7 @@ scrape_configs:
|
|||||||
- targets:
|
- targets:
|
||||||
- https://git.ssw590-08.me/user/login
|
- https://git.ssw590-08.me/user/login
|
||||||
- https://ci.ssw590-08.me/login
|
- https://ci.ssw590-08.me/login
|
||||||
|
- https://app.ssw590-08.me/health
|
||||||
relabel_configs:
|
relabel_configs:
|
||||||
- source_labels: [__address__]
|
- source_labels: [__address__]
|
||||||
target_label: __param_target
|
target_label: __param_target
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
__pycache__
|
||||||
|
.venv
|
||||||
|
.ansible-venv
|
||||||
|
.git
|
||||||
|
*.pyc
|
||||||
|
requirements.in
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
# Base image pinned by digest (python:3.13-slim, linux/amd64 for the Droplet).
|
||||||
|
FROM python:3.13-slim@sha256:e48f59cdba69a3cbd9ed2cf0f348d90d45a8d350d98134cf1070bc106ee9ed90
|
||||||
|
ARG APP_COMMIT=development
|
||||||
|
ENV APP_COMMIT=$APP_COMMIT PYTHONDONTWRITEBYTECODE=1 PYTHONUNBUFFERED=1
|
||||||
|
WORKDIR /app
|
||||||
|
COPY requirements.txt .
|
||||||
|
# Exact, hash-checked dependency versions (direct + transitive) from requirements.txt
|
||||||
|
RUN pip install --no-cache-dir --require-hashes -r requirements.txt
|
||||||
|
RUN apt-get update && apt-get install -y --only-upgrade zlib1g libzstd1 && rm -rf /var/lib/apt/lists/* \
|
||||||
|
&& pip uninstall -y pip setuptools
|
||||||
|
COPY app.py .
|
||||||
|
USER 10001:10001
|
||||||
|
EXPOSE 8000
|
||||||
|
HEALTHCHECK --interval=10s --timeout=3s --start-period=10s --retries=3 CMD python -c "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8000/health', timeout=2)"
|
||||||
|
CMD ["gunicorn", "--bind", "0.0.0.0:8000", "--workers", "1", "--worker-tmp-dir", "/tmp", "app:app"]
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
import os
|
||||||
|
from flask import Flask, jsonify, request
|
||||||
|
|
||||||
|
app = Flask(__name__)
|
||||||
|
VERSION = "v2"
|
||||||
|
UNIT_PRICE = 12
|
||||||
|
COMMIT = os.environ.get("APP_COMMIT", "development")
|
||||||
|
|
||||||
|
|
||||||
|
QUANTITY_ERROR = "quantity must be a whole number between 1 and 1000"
|
||||||
|
|
||||||
|
|
||||||
|
def total_price(quantity):
|
||||||
|
if quantity < 1 or quantity > 1000:
|
||||||
|
raise ValueError(QUANTITY_ERROR)
|
||||||
|
return UNIT_PRICE * quantity
|
||||||
|
|
||||||
|
|
||||||
|
@app.get("/")
|
||||||
|
def index():
|
||||||
|
return jsonify(service="Startup Pricing", version=VERSION, commit=COMMIT)
|
||||||
|
|
||||||
|
|
||||||
|
@app.get("/health")
|
||||||
|
def health():
|
||||||
|
return jsonify(status="ok", version=VERSION)
|
||||||
|
|
||||||
|
|
||||||
|
@app.get("/price")
|
||||||
|
def price():
|
||||||
|
try:
|
||||||
|
quantity = int(request.args.get("quantity", "1"))
|
||||||
|
total = total_price(quantity)
|
||||||
|
except ValueError:
|
||||||
|
return jsonify(error=QUANTITY_ERROR), 400
|
||||||
|
return jsonify(quantity=quantity, total=total, currency="USD")
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
Flask>=3.1,<3.2
|
||||||
|
gunicorn>=23,<24
|
||||||
@@ -0,0 +1,190 @@
|
|||||||
|
# This file was autogenerated by uv via the following command:
|
||||||
|
# uv pip compile requirements.in --universal --python-version 3.13 --generate-hashes -o requirements.txt
|
||||||
|
blinker==1.9.0 \
|
||||||
|
--hash=sha256:b4ce2265a7abece45e7cc896e98dbebe6cead56bcf805a3d23136d145f5445bf \
|
||||||
|
--hash=sha256:ba0efaa9080b619ff2f3459d1d500c57bddea4a6b424b60a91141db6fd2f08bc
|
||||||
|
# via flask
|
||||||
|
click==8.5.1 \
|
||||||
|
--hash=sha256:8bb5376d2006950386f8c6427613334a2acadc5f559cb80e638d00b4df957e37 \
|
||||||
|
--hash=sha256:9bbfada76703fd1d784b83eea012e3e8c6a001a876543ef104fa56aaaeb072b4
|
||||||
|
# via flask
|
||||||
|
flask==3.1.3 \
|
||||||
|
--hash=sha256:0ef0e52b8a9cd932855379197dd8f94047b359ca0a78695144304cb45f87c9eb \
|
||||||
|
--hash=sha256:f4bcbefc124291925f1a26446da31a5178f9483862233b23c0c96a20701f670c
|
||||||
|
# via -r requirements.in
|
||||||
|
gunicorn==23.0.0 \
|
||||||
|
--hash=sha256:ec400d38950de4dfd418cff8328b2c8faed0edb0d517d3394e457c317908ca4d \
|
||||||
|
--hash=sha256:f014447a0101dc57e294f6c18ca6b40227a4c90e9bdb586042628030cba004ec
|
||||||
|
# via -r requirements.in
|
||||||
|
itsdangerous==2.2.0 \
|
||||||
|
--hash=sha256:c6242fc49e35958c8b15141343aa660db5fc54d4f13a1db01a3f5891b98700ef \
|
||||||
|
--hash=sha256:e0050c0b7da1eea53ffaf149c0cfbb5c6e2e2b69c4bef22c81fa6eb73e5f6173
|
||||||
|
# via flask
|
||||||
|
jinja2==3.1.6 \
|
||||||
|
--hash=sha256:0137fb05990d35f1275a587e9aee6d56da821fc83491a0fb838183be43f66d6d \
|
||||||
|
--hash=sha256:85ece4451f492d0c13c5dd7c13a64681a86afae63a5f347908daf103ce6d2f67
|
||||||
|
# via flask
|
||||||
|
markupsafe==3.0.4 \
|
||||||
|
--hash=sha256:007e1ffd9bf65bb6ee96df7b258fc632a4868dd5566037986c64781f35a36e98 \
|
||||||
|
--hash=sha256:02fa4acbc6a3fc5c693c34d4dd8c1130b7fe99cc915181b0ddd6f72aeb296002 \
|
||||||
|
--hash=sha256:03470d1a8268e692ecf79ecd565593e59d44219377a7ead61f1f1b94c1f7ff6b \
|
||||||
|
--hash=sha256:04e7902ba80ee4bac1d50a549606527a1dcf0476cd81403db41099d3b60ec653 \
|
||||||
|
--hash=sha256:051417f74bcaaefa316276e0ff723f541616ca51043d070da00249d9bddd3e3c \
|
||||||
|
--hash=sha256:05295589e619b9bed252a86b532b8e27350abc372d18ba89b59375325e91ec1e \
|
||||||
|
--hash=sha256:06de8ef6331f6e822c28d577dc8bf43fe398800477c49498f38fc38b67ff33fc \
|
||||||
|
--hash=sha256:0764a13d34cae40db7bbf3a09b7e9b491bf4603e20b263a7a9d6b8e324975d0a \
|
||||||
|
--hash=sha256:077293e425f28ec737dbcad442a71752e28f8ae27cde3d68acd1fb212091cd92 \
|
||||||
|
--hash=sha256:0930db9bdc62d22944e10b066448bb65dc9abe9112880c7cab8da54db4284d5f \
|
||||||
|
--hash=sha256:0cee7cb0f9a1b6892ea482237d9403b3d1b4603aee057d0ff01f0fac2d019a97 \
|
||||||
|
--hash=sha256:0d9c47709875fdb321452056622e930c52afbc07a7d780762fbb8b4d91ce6fa4 \
|
||||||
|
--hash=sha256:11935df9bf455ed0c04eb87bcd720f02b1fe5e02128a9430f23aed6f93336fc7 \
|
||||||
|
--hash=sha256:12a606a492de952afcb43b59a14aaaaad120e708d3663dd0fdf2d738d427a691 \
|
||||||
|
--hash=sha256:14bd2d845d62ab678eaf81da89d7b621b51756c72346745c1a594c09d49207a2 \
|
||||||
|
--hash=sha256:15ba9e28640feef770374b116a6f019c21f52404aeabe516aa7f800587b98cfc \
|
||||||
|
--hash=sha256:18a801868a884f216e784d7d14db2a4077143ce7610440aee2ce8f734e7cfcde \
|
||||||
|
--hash=sha256:1c0df495a977d10460a94941799c72d5b5ab03d3858d949b55b5a66c8f371c99 \
|
||||||
|
--hash=sha256:1caa2fa5a6184fb233153b35f654e6687bd555476f6170f29d8ee9be1a8b0af9 \
|
||||||
|
--hash=sha256:1e1451fab512d1bcc3dc26988ec1edb0b82c2db909132872cd9356070a6b63df \
|
||||||
|
--hash=sha256:1f1f9477e174582b0a1b583d60b66e1f2cf5d3fe12cee985e4aedf44766600e5 \
|
||||||
|
--hash=sha256:2628d3a8cb648ecebb3c5d6b0a1052d400e4d8b7ac0fb786be8d285b50040d17 \
|
||||||
|
--hash=sha256:26e9867520db70d37f7fb421a7f0d8adb40171011fb84ce869afa1a83370dfa8 \
|
||||||
|
--hash=sha256:2a6ef68ae94aed8721934072b27a3b654ea2100b97e4ab864cf1489c90926fbc \
|
||||||
|
--hash=sha256:2b2b1e18af909b448bb3cf9e3433366f7a8726271fc214e8b10e0f62a78c724b \
|
||||||
|
--hash=sha256:2cb3dd71fc6be918ad4264346a8ed69485f9b7ed7bf35495d8e22807cd6b8bea \
|
||||||
|
--hash=sha256:2d1b7d9308288661f56672b1b157d75fc536714d3638487bbea17b6318a78248 \
|
||||||
|
--hash=sha256:2dad610540cb2e6272855c178f08ae9a1c7ac258a7fb71660553a5f104b42741 \
|
||||||
|
--hash=sha256:2e5a7cd7fdd14fcb1ae5d7d8bf23d24fbd1daefd1fbca2580132e1ea75f098b5 \
|
||||||
|
--hash=sha256:2e9ad7dd851bf45fab9f75cbff4cb493fee9979e8d8c7c9c3ee119022518edd6 \
|
||||||
|
--hash=sha256:340cbb1957ba99929cbf19a75626d36ba1ae21d1730b287d1cf7f824a20c4fc7 \
|
||||||
|
--hash=sha256:34bdde374c5932765d7dc685c4a1d191a3207852d67e8e0a9eb6ea85156181f1 \
|
||||||
|
--hash=sha256:353bd63081912ab8cfa6a0c7d185934cdf8426f04c618bba6bc4b394f2069b67 \
|
||||||
|
--hash=sha256:387d8cd30e69b3f0a72877b9ae717033396404e19095b17fe89753a981fda44f \
|
||||||
|
--hash=sha256:3882fb412298575bae3b9c46868251f15cc69307359f87bb1b382e53d6e5a2c9 \
|
||||||
|
--hash=sha256:38fc55594dab834470b6733dead2ee9e3f657fb0608c769dcafa0ba5ab52f45c \
|
||||||
|
--hash=sha256:396ec4e65cc889f69786b3b89478b471cee5a3bcf468b9d9bb03e1a30fb291fc \
|
||||||
|
--hash=sha256:39dbacefc411633db5b4378b066a9aca70a3d7e2922c9e578d825f844026eeba \
|
||||||
|
--hash=sha256:3a93d9616ddecfb393727a0041a562cf0b15a244e20f2bd25efc7949be4c4f17 \
|
||||||
|
--hash=sha256:3d23795802fc8bd72534836d64489bbf0f67c088959091bdb22e10735a5107bf \
|
||||||
|
--hash=sha256:434139499bb20b502ed3baa1f169e618f924a97e7a777fea1a49446d80106cf6 \
|
||||||
|
--hash=sha256:436e3ffc6310d3c41878c601db29098102fe5d8a467c49da4a4125254e0980f2 \
|
||||||
|
--hash=sha256:489505b03f692c3f376394e49194fa7a7f9e8558d6e293a7056a0032b0c38163 \
|
||||||
|
--hash=sha256:4a540e2d3192792fc84eced57bef37851ccb2b41f73291bb17408eea77bcd278 \
|
||||||
|
--hash=sha256:4a7cdc2a420ca01058182da4253329764d4bfa055564d1eced90e6ba1e8b1d3d \
|
||||||
|
--hash=sha256:4bced6e2a6dba6a28f7dd3c6ce14df1b2dd495923f16ea484cad03decd463b2b \
|
||||||
|
--hash=sha256:4cf3468d5ec187ffffcaca8e61929a37448f215dafc1386a12c750a72fe53634 \
|
||||||
|
--hash=sha256:4e2c4809c14559aa7ef426f27fb35afbb38104c349a903bf8f3600456764bb38 \
|
||||||
|
--hash=sha256:4ed644d75aa94a2baf7ec3a96eaa160ea58c742eb9d27c6506053c5c40fc84ed \
|
||||||
|
--hash=sha256:4f6e0852a0283b1b1fd776eeb7b766a5f440b3e2bd31ab51af3b400585f3965c \
|
||||||
|
--hash=sha256:5066b244f576f91afc8ee3ba029a89f99d39c79b1853fe9d39bea9f0afbec148 \
|
||||||
|
--hash=sha256:5086f9975abb1ab531ee6afca1761e4b59a19b446f3f6522ed776963228cfe5a \
|
||||||
|
--hash=sha256:50b5bedc9ed8a94fc8857a42ef4f84a81ea88f8d4f05dc8705fb23ee6d8dcca7 \
|
||||||
|
--hash=sha256:52704c5d36eb6dda8866493decd61111fff86244c9b1ad225ca01b9e91e5970f \
|
||||||
|
--hash=sha256:55ffd6ce583d97dc71dc92e930324c8c0d25aea7e3ade6ae54ef77cedb096811 \
|
||||||
|
--hash=sha256:569d65055d367e3dcdf30c3f41119467b73d9ee9faf332bdf40402644f5ac08e \
|
||||||
|
--hash=sha256:57f9947a7e57a081c1e3e0a2dd0d2dcf290a4531450e6f611e30084c222a7295 \
|
||||||
|
--hash=sha256:5989cb26b2e1efc6a42216a9f6b5ee495ce5ace2e5b352a9af489976b32d1ee2 \
|
||||||
|
--hash=sha256:5c22873ad1f0532ba40fa1727f3c0fc1bbbaab6d373d4cbe3f0dc74b2e2521c7 \
|
||||||
|
--hash=sha256:5e8b3d0b18fd623afa12ecb2ce8d8becef69f9b5440c6330c7972200e0bb84b0 \
|
||||||
|
--hash=sha256:61631e08084be9e21a8967ec3139c7616ed7c5e9368e05c86d1b39562c8a57b6 \
|
||||||
|
--hash=sha256:64511c54db4e4987aef4c41923235927428729e8174c5dba488429be70a998ed \
|
||||||
|
--hash=sha256:6669c1bf34080161ce49c589cc512ef24d4c704ac9d2b2d3667f519c60418378 \
|
||||||
|
--hash=sha256:672d207103e6b16ca098611b0f9efad6bc00afd47c03d6ef62186495ca677dc0 \
|
||||||
|
--hash=sha256:6768d67d1bce64270e0fdc2e69309d68b9b18ae56ddf6c711d168e9d051c2cac \
|
||||||
|
--hash=sha256:6a45c3d514f2436064db00d7fc8778d888f0236ebfed649b53d13a59e69ad51b \
|
||||||
|
--hash=sha256:6bd9e1788e15bfcf6a9082de42e30387e7b85d211ab21e57a939bb8cfaaf8d96 \
|
||||||
|
--hash=sha256:6d2a9efe686f9de00d0d1ea32a4a5a86d558a2277501bd78d964214eab625e59 \
|
||||||
|
--hash=sha256:6da83a088f8ef93b2d483a8232a4dbf4d69d3d8496b568a03c56becac43e1808 \
|
||||||
|
--hash=sha256:7018d4af1cd272e847aa5917983ab5e83e4f6579f9dbfecd4a79c0ca80b144c2 \
|
||||||
|
--hash=sha256:71f88e749ea29f67f21f3b36433c1dc54c7729ed2a6d9e2da2e0d9e0d7b224eb \
|
||||||
|
--hash=sha256:737c9c3981998eba27f11786f84fddcbabc74068b72a4a1f454ea02094b57b65 \
|
||||||
|
--hash=sha256:73e77980c7207854f00fc4e71fb1626868d5740ab4012623d55c7a99ad122a72 \
|
||||||
|
--hash=sha256:799c39bdf5e2f1292fedd3009f7b3c9e760f10b2420cb9638d56920840ff6db8 \
|
||||||
|
--hash=sha256:7a83aa6e4805df46fed18e989d3d16f86ef60cb50bbc8d9ce3a6be89165fbf6e \
|
||||||
|
--hash=sha256:7d3391b2188d18737cb2fa147028b1096236eaa7e156446c650a489fa2cadc91 \
|
||||||
|
--hash=sha256:7e1636da3d8dfc220b6dd10264db5f2b165e4888c4518594898fbe381049af8a \
|
||||||
|
--hash=sha256:805c8b84534fa10891890f0e4be39f3a99e94615d93e8836bf9fa1fdca2feeb2 \
|
||||||
|
--hash=sha256:811d02d5122171c1941357efd8f9bf4ffe907b7f0a1a4e729a880e4be3f46e3e \
|
||||||
|
--hash=sha256:8138eb83940ec7299024d92d4dee45f601b9e6c5ffde9d25f4e35e326203c707 \
|
||||||
|
--hash=sha256:83b3944fea42a8400edf92fd1770fb8d0d4f7de651353bd2d8525a92dba69a21 \
|
||||||
|
--hash=sha256:849dd2bb0e5e4ab2b71c7191726a4a8d5aa8a610daa584728cbee0b710ddc4ef \
|
||||||
|
--hash=sha256:8698d70a8081ee8c090dbb394768b5789a1da8b131b5499f89d071dd3cfaf6be \
|
||||||
|
--hash=sha256:8781a792a070cf2bd1b86d3aa943894115faaba6e88122a7bf32d62072742453 \
|
||||||
|
--hash=sha256:88d59b473bfb03259722600839af9bbd7fa13a2eb514beefeedb95997882f69a \
|
||||||
|
--hash=sha256:8909c2f1c6dd65e054ac4b573a91c8384d1492281e55d82d159d653f7a13adf6 \
|
||||||
|
--hash=sha256:8965520ac587c94a4ac48b729be3d8b8de00af39699b17585dfb599babe77977 \
|
||||||
|
--hash=sha256:8b5d563170ff8ba3181caa967c99a3c804d1dedb702c7cb93a6a7c32247da978 \
|
||||||
|
--hash=sha256:8e124f974786f831d6043728e38296969d3579db8896fe004682f5758e613581 \
|
||||||
|
--hash=sha256:8f0fac8b13d14bb06c68195f849371924ae53dd7b1c00fed24650f704383b692 \
|
||||||
|
--hash=sha256:9240187afb63d2f9ddc3e032c670356fe941f6e20662ea168a5dc3f1f317e1b3 \
|
||||||
|
--hash=sha256:925f929d6b59a8b3f8b8c6ac363cd0af7eecc81efb3071770b3c6717c450a369 \
|
||||||
|
--hash=sha256:9348cbb300d224fe3b89793262cb093504d4ae927004468463f745188a193e4a \
|
||||||
|
--hash=sha256:9388003072b95f2f1e3fd908604194d653ba21330d811961a78b7da1a77e9e36 \
|
||||||
|
--hash=sha256:9438a2648b2195980cb2dd8e53ed7b8df91319e2d0b70ae61a9e1d1bc8d3bec9 \
|
||||||
|
--hash=sha256:94e4c421742086aeee4c32a506eec8859d7634aad943f7e6aacf70f813478768 \
|
||||||
|
--hash=sha256:94f5407f7bc64fa6463906b896f9904beeeb7dd8dc116ee8e9056c8714ff9916 \
|
||||||
|
--hash=sha256:971a3bbb75d97ae4e2e8f7d4834236f86f85f0c85e04ab2e191db1123b04f80b \
|
||||||
|
--hash=sha256:9e227f3dbe6bde7491cf0a9965d00b88c6b1a4a95d11480ddf88bb96d397c19f \
|
||||||
|
--hash=sha256:9e25feb9e330b63edb0278a0acdf85e50d0cb0fbf49c3084abbe4e24ae195346 \
|
||||||
|
--hash=sha256:9f098115c247e11d138ab83a28fa0323c77015007ea2df73ba5fd714dfefd67c \
|
||||||
|
--hash=sha256:a18f38cafc329bac5e3c2b96c765b4c96d3d103421ed22ab7988c1e3fce27464 \
|
||||||
|
--hash=sha256:a4bbd2d87dd233b9fc5812160c3d0ffbe42edc22a26ce0469f58479ede633fe9 \
|
||||||
|
--hash=sha256:a5fcffb37e602b0b3c1638a97746b9b96125caa9bcf6fa41d337a9261de231ee \
|
||||||
|
--hash=sha256:a8e9f292fcda89b324f2f5c91d13f1424a153e40fc2756f38ee23b15835ff300 \
|
||||||
|
--hash=sha256:a9f54054101545a9a9cccefddf54316aa6e4491611fcbef9e91b3b6bebec04f6 \
|
||||||
|
--hash=sha256:aa2c838cc024642cc04c6854232f32b43e5e22833dd11119c1766c7873b8370d \
|
||||||
|
--hash=sha256:ac0c7c9f1609b0c4c114feb1d7a3409564c7fb77e360bed9e97e5d25dfeaf868 \
|
||||||
|
--hash=sha256:add96447a86d205ab616665d53b2950ee81083757f56e6ea833c8b2917646b46 \
|
||||||
|
--hash=sha256:ae9dcb8fbe244cb82f8a6458b455b927a03685e383d9bacf1ea5ce180b96dc97 \
|
||||||
|
--hash=sha256:b4a635a0487774f841cb1fb62e907e7195cc95bc761e053184b8acc3ceb20733 \
|
||||||
|
--hash=sha256:b4d12837e0203bbace818ff4a7461afdcd78bcd782351cea148139180d7bcffe \
|
||||||
|
--hash=sha256:b61687d0828e72bf5cda24a2690188f37170bd31c9359ac97e4e66569f120a16 \
|
||||||
|
--hash=sha256:b807e598953730f82e4eae3bd30f6a122cf6b31c398c6b504c0e04c13c170429 \
|
||||||
|
--hash=sha256:b8cd1f918b26fd7b1832ece557cc18f2d8747309ff8b3f0ef9d4250c5ad67a39 \
|
||||||
|
--hash=sha256:b91cc9d336957239ff200f30097e6fea2dc6d6fb3c81e853eaa09eac904fd894 \
|
||||||
|
--hash=sha256:bd3ce56ae2cbae3ba82b683bc425cd7e48d2ed8b10f3e818186b6f5646d9271c \
|
||||||
|
--hash=sha256:be6cb0c799abb0e2ba3e618e6d28ddddf7e485f6c2ce938dfa237daf3905072c \
|
||||||
|
--hash=sha256:befb4158af32106b9a93db8d6d1d1cbbd418c0d5aca0cabb7b1780abf0c89169 \
|
||||||
|
--hash=sha256:bf053da3c97a4bc5ecfbb218cdd2983febd91c617be8367d139882aa11e490aa \
|
||||||
|
--hash=sha256:c02e8f18bdedba082cef725942ac823b9b60656db07f7e265cb31618dfd00d77 \
|
||||||
|
--hash=sha256:c1bc67752d5f21013cfe430df4062441714eab79f65a6a05e01505957e9c35fe \
|
||||||
|
--hash=sha256:c61750fadcd119d0825bcb7d7d675dd264dcc89cc05292aab5be68ebdbb374ad \
|
||||||
|
--hash=sha256:c90d5b3d4e944e065a301d741b3c1d784f6bd1f503aa68b4967e32b2ba313d85 \
|
||||||
|
--hash=sha256:c9a7f43c0b202b334cc9184af09bb8f21d3a209e038efaf106936fb69e6b026e \
|
||||||
|
--hash=sha256:cb96e6e088d6cf71c1ea977510948320234824cf226e32f6f6e044f7a9c82b34 \
|
||||||
|
--hash=sha256:cf63c214fe879a65e69a386f915e36104fc84254ab141240f8854602d8e0be2a \
|
||||||
|
--hash=sha256:d1aca03ede943eb80ab3d63bb082c84b7aab85ea83bd0fd0c200260945fb49d9 \
|
||||||
|
--hash=sha256:d2e56fd3b00222722abfb3f5f0759ddbae4b90811b5ad4343c64030ad1bde70c \
|
||||||
|
--hash=sha256:d5f93ebbeb8032d47e349328ec8662d973d9b05a70b3c35df1f91fe419b84749 \
|
||||||
|
--hash=sha256:d882a373d8093c2941e01291b7ced96e9cbe4781da9a7751ca7e6c70385e5214 \
|
||||||
|
--hash=sha256:d920abdfa61279ba1a2ef9484aab07bf03331f8c08a10120fa332353d06e6932 \
|
||||||
|
--hash=sha256:da2af0d7aebfc2074080d72efa6ab8317c62481ef1f896f65d9999c1c01f4494 \
|
||||||
|
--hash=sha256:dd8ea6ebee7aedbf7c749fa80521d9ccf1ba473e0d1e14805caafbaad281c889 \
|
||||||
|
--hash=sha256:de8b364c423ef0a4bad9069657d617f9a5d2b2062457a89b1fa16ee199c399c1 \
|
||||||
|
--hash=sha256:df1ae86ff54725a01fa1a0510b914ca53a161b7050be74f6204e24aded5971d0 \
|
||||||
|
--hash=sha256:dff05cb7016dff1e9fd68f4122c127b65dfc59de5306cfb7ad92f956f230bee2 \
|
||||||
|
--hash=sha256:e1a622f13970d81f95d0c72f9dc090dce9085fccfa4c9f2174377ee32bd15786 \
|
||||||
|
--hash=sha256:e49fb0d1ce92cfa0cb198cc5b1b11cdf9d0638658e2a2db2687e39db7c87fc78 \
|
||||||
|
--hash=sha256:e5c802729725bd07e2bc3ab7b76dc7e0bbfc53129d8f1eb1c002c24cf774717e \
|
||||||
|
--hash=sha256:e841068dc0be4cb6dfb5c890eb88cbdcff2f4a332393c7ec94e8e618bd32c1a8 \
|
||||||
|
--hash=sha256:e916035e3e9930cbdfdd10abf48861340221857f45509565898e012263f7b289 \
|
||||||
|
--hash=sha256:eba154571c16e032112afac0dc2dfe9e63c2ceb7aedd07bb7eecf2ce26d4dd4c \
|
||||||
|
--hash=sha256:f03460ff076f70ab595bb45a0205ccea1971443575b6920c52e755dec2b3fbfe \
|
||||||
|
--hash=sha256:f0ec3b750b59375eab5b0fb2b9254810c00a3375be6d789899f1055a1d556237 \
|
||||||
|
--hash=sha256:f291bcf42ae98eb5107edb162c3c998b4a89648fd8e99ed4cbd12705292788cd \
|
||||||
|
--hash=sha256:f61efe1d2fe0de16158a5fe1d1cf3c14bdb6aecd54d8938fd26512c525c1f624 \
|
||||||
|
--hash=sha256:f68edfc67aabac33708941f26f22a7b8e9f81429bc0cf249fcf7d66b23af8d19 \
|
||||||
|
--hash=sha256:fa95848c929b6a75f6848d3c9793e59db365ee436776e57db835cdbfa79ba977 \
|
||||||
|
--hash=sha256:fd9f8797427910198f95bced71ddfed61130d7e349213bfb8466c9c99e2c46a8 \
|
||||||
|
--hash=sha256:fdb4ca07ab75ffadab4a8b135ad59cdbb3156b99310f3d565370da74a15d6bd3
|
||||||
|
# via
|
||||||
|
# flask
|
||||||
|
# jinja2
|
||||||
|
# werkzeug
|
||||||
|
packaging==26.3 \
|
||||||
|
--hash=sha256:94edc256424af38762eb31306eed28beb9f0efc50a8837492c9d6fd6004aed79 \
|
||||||
|
--hash=sha256:d7193f7c8e4e93f444fde0262bf90af30e16fa0ad0ad44cb553c87339b23cd1c
|
||||||
|
# via gunicorn
|
||||||
|
werkzeug==3.1.9 \
|
||||||
|
--hash=sha256:55ca7c70a75689be937aa27f8ff4b018f06ff4838fc73045560bf0f5a1291060 \
|
||||||
|
--hash=sha256:6392e50c78460ba618e5b21f08a71f59c99ce99cdc6cf6e3dd7e6ccca8754fab
|
||||||
|
# via flask
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
import unittest
|
||||||
|
from app import app, total_price
|
||||||
|
|
||||||
|
|
||||||
|
class PricingTests(unittest.TestCase):
|
||||||
|
def setUp(self):
|
||||||
|
self.client = app.test_client()
|
||||||
|
|
||||||
|
def test_price(self):
|
||||||
|
self.assertEqual(total_price(3), 36)
|
||||||
|
response = self.client.get("/price?quantity=3")
|
||||||
|
self.assertEqual(response.status_code, 200)
|
||||||
|
self.assertEqual(response.json["total"], 36)
|
||||||
|
|
||||||
|
def test_invalid_quantity(self):
|
||||||
|
for value in ["0", "-1", "1001", "abc", "1.5"]:
|
||||||
|
self.assertEqual(self.client.get("/price?quantity=" + value).status_code, 400)
|
||||||
|
|
||||||
|
def test_non_numeric_quantity_message(self):
|
||||||
|
# Ticket#63003 / issue #30: no Python internals in the error
|
||||||
|
response = self.client.get("/price?quantity=abc")
|
||||||
|
self.assertEqual(response.status_code, 400)
|
||||||
|
self.assertEqual(response.json["error"],
|
||||||
|
"quantity must be a whole number between 1 and 1000")
|
||||||
|
|
||||||
|
def test_release_identity(self):
|
||||||
|
self.assertEqual(self.client.get("/").json["version"], "v2")
|
||||||
|
self.assertEqual(self.client.get("/health").json["status"], "ok")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
unittest.main()
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
# Release records
|
||||||
|
|
||||||
|
One file per environment and release, e.g. `v1-staging.yml`, `v1-production.yml`.
|
||||||
|
Each holds metadata only (image digest, full source commit, expected version and
|
||||||
|
total, public URL, proxy network) - never credentials. Production uses the same
|
||||||
|
image digest as staging. Keep old records for rollback.
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
# Copy to a release-specific file and replace EVERY placeholder.
|
||||||
|
target_env: staging
|
||||||
|
release_image: gitea.example.edu/team/pricing@sha256:REPLACE_DIGEST
|
||||||
|
expected_version: v1
|
||||||
|
expected_commit: REPLACE_FULL_GIT_COMMIT
|
||||||
|
expected_total: 30
|
||||||
|
public_url: https://staging.example.edu
|
||||||
|
proxy_network: REPLACE_EXISTING_PROXY_NETWORK
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
target_env: production
|
||||||
|
release_image: git.ssw590-08.me/ssw-590-08/pricing@sha256:7689c624960c3d47cc7eb0bd456b4023923a55a64e6941f621c82315b374adf5
|
||||||
|
expected_version: v1
|
||||||
|
expected_commit: 69f1fe05cf72848e250d71349a76ee1157d44df3
|
||||||
|
expected_total: 30
|
||||||
|
public_url: https://app.ssw590-08.me
|
||||||
|
proxy_network: gitea-net
|
||||||
|
approved_by: samahk
|
||||||
|
approved_at: 2026-11-14T03:04:14+00:00
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
target_env: staging
|
||||||
|
release_image: git.ssw590-08.me/ssw-590-08/pricing@sha256:7689c624960c3d47cc7eb0bd456b4023923a55a64e6941f621c82315b374adf5
|
||||||
|
expected_version: v1
|
||||||
|
expected_commit: 69f1fe05cf72848e250d71349a76ee1157d44df3
|
||||||
|
expected_total: 30
|
||||||
|
public_url: https://staging.ssw590-08.me
|
||||||
|
proxy_network: gitea-net
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
target_env: production
|
||||||
|
release_image: git.ssw590-08.me/ssw-590-08/pricing@sha256:d7aa3cfce583a68e287dc34707f11c1d664161e65c74cd709df15330b2fd8f19
|
||||||
|
expected_version: v2
|
||||||
|
expected_commit: d6787727f8ebce3f8ac0f8f6d36ddef352ba63da
|
||||||
|
expected_total: 36
|
||||||
|
public_url: https://app.ssw590-08.me
|
||||||
|
proxy_network: gitea-net
|
||||||
|
approved_by: samahk
|
||||||
|
approved_at: 2026-11-14T03:17:50+00:00
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
target_env: staging
|
||||||
|
release_image: git.ssw590-08.me/ssw-590-08/pricing@sha256:d7aa3cfce583a68e287dc34707f11c1d664161e65c74cd709df15330b2fd8f19
|
||||||
|
expected_version: v2
|
||||||
|
expected_commit: d6787727f8ebce3f8ac0f8f6d36ddef352ba63da
|
||||||
|
expected_total: 36
|
||||||
|
public_url: https://staging.ssw590-08.me
|
||||||
|
proxy_network: gitea-net
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
# Security gate policy (defined before the assessed release)
|
||||||
|
|
||||||
|
**Tools:** Trivy (repository and image scanning, secret detection) and pip-audit
|
||||||
|
(Python dependency audit). Tool and vulnerability-database versions, scan time,
|
||||||
|
commands, reports and exit codes are recorded by `security/scan.sh` and archived
|
||||||
|
by Jenkins as `security-reports/**`.
|
||||||
|
|
||||||
|
**Blocking (the pipeline fails):**
|
||||||
|
- any detected secret;
|
||||||
|
- any known vulnerability reported by pip-audit for the locked dependencies;
|
||||||
|
- any HIGH or CRITICAL vulnerability in the repository or the built image that
|
||||||
|
has a fix available;
|
||||||
|
- any scanner error, missing tool, or failure to obtain the vulnerability
|
||||||
|
database. A failed scan is not a clean scan.
|
||||||
|
|
||||||
|
**Not blocking, but recorded:** HIGH or CRITICAL vulnerabilities with no fix yet
|
||||||
|
(typically operating-system packages in the base image). They are listed in the
|
||||||
|
full image report and counted in `image-summary.txt` on every run. The accepted
|
||||||
|
set is recorded in the manual as a time-limited exception with a review date.
|
||||||
|
Nothing is silently ignored.
|
||||||
|
|
||||||
|
**Fixes:** update the dependency lockfile or the pinned base-image digest,
|
||||||
|
rebuild, and rescan. Dependency or base-image updates always trigger a rescan.
|
||||||
|
|
||||||
|
**False positives and exceptions:** a finding that has a fix but is accepted for
|
||||||
|
a stated reason goes in `security/.trivyignore` with an `exp:` date and a
|
||||||
|
comment naming the reason and the approver. Expired entries stop applying.
|
||||||
|
|
||||||
|
**Test fixture:** one blocked run uses a synthetic, scanner-supported fixture
|
||||||
|
(never a live secret) on a branch; it is removed and the run repeated.
|
||||||
@@ -0,0 +1,89 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Security gates for the delivery pipeline (manual Chapter 11, "Apply Proportionate
|
||||||
|
# Security Gates"). Usage:
|
||||||
|
# security/scan.sh source dependency audit + secret/vulnerability scan of the repo
|
||||||
|
# security/scan.sh image <image-ref> vulnerability scan of the built image
|
||||||
|
#
|
||||||
|
# Policy (full text in security/POLICY.md):
|
||||||
|
# * Detected secrets always block.
|
||||||
|
# * Dependency vulnerabilities reported by pip-audit always block.
|
||||||
|
# * HIGH/CRITICAL vulnerabilities that HAVE A FIX AVAILABLE block (--ignore-unfixed).
|
||||||
|
# * HIGH/CRITICAL vulnerabilities with no fix yet do not block, but are never
|
||||||
|
# hidden: an informational full report and a summary are saved and archived,
|
||||||
|
# and the accepted set is recorded as a dated exception in the manual.
|
||||||
|
# * A time-limited exception for a fixable finding goes in security/.trivyignore
|
||||||
|
# (with an exp: date and a reason).
|
||||||
|
# FAIL CLOSED: any scanner error, missing tool, or vulnerability-database
|
||||||
|
# download failure ends the script with a non-zero status. A failed scan is not
|
||||||
|
# a clean scan. Nothing here ends in "|| true".
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
MODE="${1:-}"
|
||||||
|
REPORT_DIR="${REPORT_DIR:-security-reports}"
|
||||||
|
SEVERITY="HIGH,CRITICAL"
|
||||||
|
IGNOREFILE="security/.trivyignore"
|
||||||
|
export PATH="/opt/tools-venv/bin:$PATH"
|
||||||
|
|
||||||
|
now() { date -u +%Y-%m-%dT%H:%M:%SZ; }
|
||||||
|
mkdir -p "$REPORT_DIR"
|
||||||
|
|
||||||
|
ignore_args=()
|
||||||
|
if [ -f "$IGNOREFILE" ]; then ignore_args=(--ignorefile "$IGNOREFILE"); fi
|
||||||
|
|
||||||
|
record_versions() {
|
||||||
|
{
|
||||||
|
echo "scan_time_utc: $(now)"
|
||||||
|
echo "--- trivy (tool and vulnerability database versions) ---"
|
||||||
|
trivy --version
|
||||||
|
echo "--- pip-audit ---"
|
||||||
|
pip-audit --version
|
||||||
|
} | tee "$REPORT_DIR/tool-versions.txt"
|
||||||
|
}
|
||||||
|
|
||||||
|
case "$MODE" in
|
||||||
|
source)
|
||||||
|
record_versions
|
||||||
|
echo "== pip-audit: dependency audit of pricing/requirements.txt =="
|
||||||
|
# --strict: a dependency that cannot be audited is a failure, not a pass.
|
||||||
|
pip-audit -r pricing/requirements.txt --strict --progress-spinner off \
|
||||||
|
2>&1 | tee "$REPORT_DIR/pip-audit.txt"
|
||||||
|
echo "RESULT pip-audit: exit=0 at $(now)"
|
||||||
|
|
||||||
|
echo "== trivy fs: secrets and $SEVERITY vulnerabilities in the repository =="
|
||||||
|
trivy fs --scanners vuln,secret --severity "$SEVERITY" --exit-code 1 \
|
||||||
|
--ignore-unfixed --no-progress --skip-dirs .git,.venv "${ignore_args[@]}" . \
|
||||||
|
2>&1 | tee "$REPORT_DIR/trivy-source.txt"
|
||||||
|
echo "RESULT trivy-fs: exit=0 at $(now)"
|
||||||
|
;;
|
||||||
|
image)
|
||||||
|
REF="${2:?usage: scan.sh image <image-ref>}"
|
||||||
|
record_versions
|
||||||
|
echo "== trivy image: fixable $SEVERITY vulnerabilities in $REF (blocking) =="
|
||||||
|
trivy image --severity "$SEVERITY" --exit-code 1 --ignore-unfixed --no-progress \
|
||||||
|
"${ignore_args[@]}" "$REF" \
|
||||||
|
2>&1 | tee "$REPORT_DIR/trivy-image.txt"
|
||||||
|
echo "RESULT trivy-image (fixable findings): exit=0 at $(now)"
|
||||||
|
|
||||||
|
echo "== trivy image: full informational report (does not gate; errors still fail) =="
|
||||||
|
# --exit-code 0 means findings alone do not fail this run; a scanner or
|
||||||
|
# database error still does. This keeps unfixed findings visible, not hidden.
|
||||||
|
trivy image --severity "$SEVERITY" --exit-code 0 --no-progress \
|
||||||
|
--format json -o "$REPORT_DIR/trivy-image-full.json" "$REF"
|
||||||
|
python3 - "$REPORT_DIR/trivy-image-full.json" <<'PY' | tee "$REPORT_DIR/image-summary.txt"
|
||||||
|
import json, sys, collections
|
||||||
|
d = json.load(open(sys.argv[1]))
|
||||||
|
c = collections.Counter()
|
||||||
|
for r in d.get("Results", []):
|
||||||
|
for v in r.get("Vulnerabilities") or []:
|
||||||
|
c[(v["Severity"], "fix available" if v.get("FixedVersion") else "no fix yet")] += 1
|
||||||
|
print("image findings at HIGH/CRITICAL (all, including unfixed):")
|
||||||
|
for k, n in sorted(c.items()):
|
||||||
|
print(" %-9s %-14s %d" % (k[0], k[1], n))
|
||||||
|
print(" total", sum(c.values()))
|
||||||
|
PY
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "usage: security/scan.sh source | image <image-ref>" >&2
|
||||||
|
exit 2
|
||||||
|
;;
|
||||||
|
esac
|
||||||