devOpsManual/devopsGitea.tex

332 lines
16 KiB
TeX

\setcounter{chapter}{1}
\chapter{Startup Foundation with Gitea}
\ChapterLabel{Gitea}
\index{Gitea}
\index{AWS Lightsail}
\index{Caddy}
\index{SQLite}
This chapter documents the production Gitea work hub and its deployment,
security controls, and team workflow. It separates observed configuration
from recommended operating procedures. The eight sections follow the Chapter~2
rubric.
\section{Student Pack Domain and DNS}\label{sec:gitea-domain}
The domain \texttt{590hcm.dev} was registered through Name.com using its
offer in the GitHub Student Developer Pack, which provides benefits for
verified students. AWS Lightsail hosts the production Gitea instance at
\texttt{git.590hcm.dev}. The offer includes an eligible domain registration
and Domain Safe at no cost for the first year. Track the renewal amount,
currency, and expiration date in the Name.com account and set a calendar
reminder~\cite{GitHubStudentPack,NameComStudentOffer}. Gitea is available at
\href{https://git.590hcm.dev}{\texttt{https://git.590hcm.dev}}.
See \autoref{Figure:GiteaDNSLookup} for the DNS lookup result.
\begin{figure}[htbp]
\centering
\includegraphics[width=0.95\linewidth]{prism-uploads/gitea-dns-nslookup.png}
\caption{Terminal output resolving \texttt{git.590hcm.dev} to \texttt{184.193.0.32}; DNS lookup screenshot.}\label{Figure:GiteaDNSLookup}
\end{figure}
\section{Pinned Gitea Deployment}\label{sec:gitea-deployment}
The production instance runs Ubuntu 24.04.4 LTS with kernel
\texttt{7.0.0-1012-aws} on AWS Lightsail. Record its bundle, region, and Docker
Engine build from \texttt{docker version} in the operations inventory.
The Compose configuration pins these images:
\texttt{gitea/gitea:1.22} and \texttt{caddy:2.8.4}. Update either tag after
compatibility testing. Both services use restart policies and named persistent
volumes; Gitea has no published backend port. Docker volumes persist
independently of individual containers~\cite{DockerVolumes,GiteaDockerDocs}.
\begin{minted}{yaml}
services:
caddy:
image: caddy:2.8.4
restart: unless-stopped
ports:
- "80:80"
- "443:443"
volumes:
- ./Caddyfile:/etc/caddy/Caddyfile:ro
- caddy_data:/data
- caddy_config:/config
networks:
- frontend
- backend
depends_on:
- gitea
gitea:
image: gitea/gitea:1.22
restart: unless-stopped
environment:
USER_UID: "1000"
USER_GID: "1000"
GITEA__database__DB_TYPE: sqlite3
GITEA__database__PATH: /data/gitea/gitea.db
GITEA__server__ROOT_URL: https://git.590hcm.dev/
GITEA__server__HTTP_PORT: "3000"
volumes:
- gitea_data:/data
expose:
- "3000"
networks:
- backend
volumes:
gitea_data:
caddy_data:
caddy_config:
networks:
frontend:
backend:
internal: true
\end{minted}
The matching proxy configuration contains no credentials:
\begin{minted}{text}
git.590hcm.dev {
encode zstd gzip
reverse_proxy gitea:3000
}
\end{minted}
For repeatability, store the reviewed Compose and Caddy files in a restricted,
version-controlled deployment repository. Do not commit secrets. From the
server, with Docker Engine and the Compose plugin installed, run:
\begin{minted}{bash}
mkdir -p ~/gitea-stack
cd ~/gitea-stack
# Place the reviewed compose.yaml and Caddyfile here using a secure process.
docker compose config --quiet
docker compose pull
docker compose up -d
docker compose ps
docker version
\end{minted}
The setup-time web configuration wizard must use the SQLite path shown above;
set no administrator password in a listing or shell history. Keep the resolved Gitea image digest with the tag in the deployment record
for reproducibility.
\begin{tabularx}{\linewidth}{L{3.3cm}Y}
\caption{Lightsail Deployment Parameters\label{Table:GiteaDeployment}}\\
\toprule \textbf{Parameter} & \textbf{Configuration}\\ \midrule
Provider / role & AWS Lightsail; Gitea work hub, source control, and issue tracking.\\
Operating system & Ubuntu 24.04.4 LTS; kernel \texttt{7.0.0-1012-aws}.\\
Gitea / Caddy & \texttt{gitea/gitea:1.22}; Caddy \texttt{2.8.4}.\\
Restart / storage & \texttt{unless-stopped}; named volumes \texttt{gitea\_data}, \texttt{caddy\_data}, and \texttt{caddy\_config}.\\
\bottomrule
\end{tabularx}
\section{Database and Persistence}\label{sec:gitea-persistence}
SQLite is selected for this single-instance deployment. Its database file is
\path{/data/gitea/gitea.db}; the named \texttt{gitea\_data} volume mounted at
\texttt{/data} also retains Gitea configuration, repositories, attachments,
and other application data. This one-volume design avoids an unnecessary
separate database service and makes the application data boundary explicit
~\cite{GiteaDockerDocs}. A database user/password is not applicable to this
SQLite configuration.
To test container replacement without deleting data, first create a harmless
test repository and issue, record their identifiers, then capture the initial
state. Recreate only containers; do not use \texttt{down --volumes}, \texttt{-v},
or manually remove named volumes:
\begin{minted}{bash}
docker compose ps
docker compose logs --no-color --tail=100 gitea
# After recording the test repository and issue in the UI:
docker compose down
docker compose up -d
docker compose ps
docker compose logs --no-color --tail=100 gitea
\end{minted}
After recreation, verify that the same repository and issue remain available
and retain sanitized before/after UI or log evidence. The container
replacement test demonstrates volume persistence only. It does not establish
backup integrity, off-host retention, recovery-point objectives, or successful
disaster recovery; those require a separately tested backup and restore plan.
\begin{tabularx}{\linewidth}{L{3.2cm}Y}
\caption{Container-Recreation Persistence Checks\label{Table:GiteaPersistence}}\\
\toprule \textbf{Checkpoint} & \textbf{Verification}\\ \midrule
Before replacement & Record the test repository and issue identifiers.\\
Recreation & Run \texttt{docker compose down}, then \texttt{docker compose up -d}; preserve named volumes.\\
After replacement & Confirm the same repository and issue remain available.\\
Backup / restore & Container recreation is not a backup; perform and document a separate off-host backup and restore test.\\
\bottomrule
\end{tabularx}
\section{HTTPS and Certificate Renewal}\label{sec:gitea-https}
Caddy is selected as the TLS-terminating reverse proxy because it obtains and
renews certificates automatically when DNS, ports, and site configuration
meet its requirements. Nginx with Certbot is also viable, but requires a
separate ACME client, renewal scheduling, and reload/verification wiring.
TLS terminates at Caddy; the proxy forwards requests to Gitea on the private
Compose network. Caddy's automatic HTTPS and renewal behavior are documented
by the project; Let's Encrypt certificates have finite validity and should be
renewed automatically before expiry~\cite{CaddyAutomaticHTTPS,CertbotRenewal,LECerts}.
From an external client, check the HTTP-to-HTTPS redirect and inspect the
certificate with these commands; certificate details are shown in
\autoref{Figure:GiteaCertificate}.
\begin{minted}{bash}
curl -I http://git.590hcm.dev/
echo | openssl s_client -servername git.590hcm.dev -connect git.590hcm.dev:443 2>/dev/null | openssl x509 -noout -subject -issuer -dates
\end{minted}
\begin{minted}{bash}
docker compose exec caddy caddy validate --config /etc/caddy/Caddyfile --adapter caddyfile
\end{minted}
For Caddy renewal-path testing, run the syntax check above, then use a separate staging hostname and isolated Caddy instance configured with the Let's Encrypt staging ACME directory. Confirm successful staging issuance and inspect sanitized Caddy logs; staging certificates are not production certificates. Caddy does not use Certbot's renew command, and configuration validation alone does not prove renewal~\cite{CaddyStaging}. Track the certificate expiration date and review sanitized Caddy logs during
renewal checks.
\begin{figure}[htbp]
\centering
\includegraphics[width=0.72\linewidth]{prism-uploads/gitea-certificate-details.png}
\caption{Browser certificate details for \texttt{git.590hcm.dev}; issued by Let's Encrypt (CN \texttt{YE2}), issued October 7, 2026 at 7:47:41 PM and expiring January 5, 2027 at 6:47:40 PM. }\label{Figure:GiteaCertificate}
\end{figure}
\section{Firewall and External Exposure}\label{sec:gitea-firewall}
The intended exposure policy allows HTTP \texttt{80/TCP}, HTTPS \texttt{443/TCP},
and SSH \texttt{22/TCP} only from approved administrator networks. The Lightsail screenshot in
\autoref{Figure:GiteaLightsailFirewall} shows HTTP allowed from any IPv4 or
IPv6 source, HTTPS from any IPv4 source, and SSH from any IPv4 or IPv6 source.
Thus SSH is currently unrestricted, contrary to the intended policy. Backend
ports \texttt{3000/TCP} and \texttt{5432/TCP} must not be internet-accessible.
Publish only ports 80 and 443 from the Compose proxy. Gitea uses Compose
network-only \texttt{expose: 3000}; SQLite means no PostgreSQL listener is
needed. Restrict SSH to approved administrator source CIDRs in Lightsail;
the SSH source CIDRs should be limited to administrator networks. Review IPv4 and IPv6 cloud firewall
rules, and disable IPv6 exposure unless deliberately configured and tested.
AWS Lightsail firewall rules control instance traffic, while Docker port
publishing creates host-level exposure paths; verify both layers
~\cite{LightsailFirewall,DockerPortPublishing}.
\begin{figure}[htbp]
\centering
\includegraphics[width=\linewidth]{prism-uploads/gitea-lightsail-firewall.png}
\caption{Lightsail firewall snapshot supplied by the user; screenshot filename indicates October 7, 2026 at 9:20:45 PM. It documents unrestricted SSH and IPv4/IPv6 scope for HTTP.}\label{Figure:GiteaLightsailFirewall}
\end{figure}
\begin{devopsNote}[Action required: restrict SSH]
The snapshot shows SSH allowed from any IPv4 or IPv6 address and Lightsail
browser SSH enabled. Restrict SSH to approved administrator source ranges,
review browser SSH against policy, and repeat the external tests. The image
records the rule state at its capture time.
\end{devopsNote}
Run these tests from outside the Lightsail instance; retain the sanitized
outputs with source network and UTC time:
\begin{minted}{bash}
nc -zv git.590hcm.dev 80 443 22 3000 5432
nmap -Pn -p 22,80,443,3000,5432 git.590hcm.dev
\end{minted}
HTTPS protects confidentiality and integrity in transit, but does not decide
which ports or source networks may connect. The cloud firewall and host/Docker
exposure controls are separate defense-in-depth layers; neither substitutes
for careful authentication and patching.
\begin{figure}[htbp]
\centering
\begin{minted}{text}
Browser (public)
| HTTPS :443; HTTP :80 only for redirect / ACME
v
AWS Lightsail Cloud Firewall
allow: 80/TCP, 443/TCP, restricted 22/TCP
deny: 3000/TCP, 5432/TCP; review IPv4 and IPv6
v
Caddy TLS Proxy (public listener)
| private Compose network: gitea:3000
v
Gitea (no published host port)
| /data/gitea/gitea.db and repository data
v
Named persistent volume: gitea_data
\end{minted}
\caption{Reported Gitea deployment trust boundaries and data path. The diagram shows the intended configuration; validate the live firewall against it.}\label{Figure:GiteaNetwork}
\end{figure}
\section{Startup Team Workflow}\label{sec:gitea-workflow}
Create a Gitea organization for the startup and a product repository. Its
\texttt{README.md} should describe the product, local setup, tests, contribution
and review expectations, and support ownership. Use the workflow plan below
to add member accounts and issue-linked pull requests. Give two
team members individual accounts and least-privilege roles; do not share
accounts or include credentials. Suggested actionable backlog items are:
\begin{enumerate}[label=\arabic*.]
\item Add a reproducible local setup and configuration example to \texttt{README.md}.
\item Add automated tests for the product's primary user workflow.
\item Add dependency and container-image vulnerability scanning to CI.
\item Document a release and rollback procedure for the production service.
\item Add an uptime, TLS-expiry, and disk-capacity monitoring runbook.
\end{enumerate}
For each of two issues, use the sequence: create an issue, create an issue-linked
branch, open a pull request referencing the issue, obtain a peer review, merge
only after approval/checks, then verify issue closure. Use actual Gitea object URLs and dates when carrying out the workflow.
\begin{tabularx}{\linewidth}{L{3.0cm}Y}
\caption{Startup Organization, Backlog, and Pull-Request Evidence\label{Table:GiteaWorkflow}}\\
\toprule \textbf{Deliverable} & \textbf{Record to complete from Gitea}\\ \midrule
Organization / product repository & Create a startup organization and product repository; link the README.\\
Two members and roles & Assign one member as organization owner/maintainer and the other as developer/peer reviewer; use individual accounts.\\
Five issues & Create actionable issues for setup documentation, product tests, vulnerability scanning, release/rollback, and service monitoring.\\
Flow 1 & Create a README setup issue; branch as \texttt{docs/issue-<id>-setup}; open a PR with \texttt{Closes \#<id>}; obtain Member B review; merge and confirm issue closure.\\
Flow 2 & Create a security-scanning issue; branch as \texttt{ci/issue-<id>-security-scan}; open a PR with \texttt{Closes \#<id>}; obtain Member A review; merge and confirm issue closure.\\
\bottomrule
\end{tabularx}
\section{Architecture and Operation}\label{sec:gitea-operations}
A browser resolves \texttt{git.590hcm.dev} to the reported IPv4 endpoint and
connects through the Lightsail firewall. Caddy accepts public HTTP/HTTPS,
redirects HTTP to HTTPS, manages the public certificate, and reverse-proxies
to Gitea over the private Compose network. Gitea serves the application and
stores the SQLite database and repositories in \texttt{/data}, backed by the
named volume. The public trust boundary ends at the proxy; Gitea and its data
volume are private to the instance. Confirm IPv6 follows the same intended
policy rather than assuming IPv4 rules cover it.
Routine operation and first checks:
\begin{minted}{bash}
cd ~/gitea-stack
docker compose ps
docker compose logs --since=15m --no-color caddy gitea
docker compose restart caddy gitea
docker compose ps
docker compose logs --since=5m --no-color caddy gitea
\end{minted}
If the service is unavailable, first check DNS and external ports, then
Lightsail firewall attachment, Compose health/state, Caddy logs and certificate
status, Gitea logs, disk capacity, and volume mounts. Avoid deleting volumes
as a troubleshooting step. The persistence test in \autoref{Table:GiteaPersistence} checks container
recreation only. Separately maintain protected off-host backups, documented
retention, and a verified restore procedure.
\section{Manual Quality and Controls}\label{sec:gitea-controls}
This revision records the reported host values and a reproducible
configuration plan. Log operational results after each check is run. The change history links to this chapter and both inventory
chapters. Record the setup date, image digest, renewal date, and test results
in the operations record. Keep a concise record of any failed configuration and
its corrective action. Listings contain no password,
token, private key, or other credential. Apply the same strict redaction to
captured logs, screenshots, DNS output, and firewall exports before including
them.
\clearpage
\begin{tabularx}{\linewidth}{L{3.5cm}Y}
\caption{Manual Quality and Evidence Controls\label{Table:GiteaManualQuality}}\\
\toprule \textbf{Control} & \textbf{Current record}\\ \midrule
Version and change date & Version 1.8; October 8, 2026.\\
Hostname and host inventory & User-supplied values recorded in \autoref{Table:DevelopmentHosts}; include the instance bundle, region, and Docker Engine build in the host inventory.\\
Credential inventory & Three Gitea-related rows added to \autoref{Table:PasswordRules}; vault references only, no secret values.\\
Evidence & DNS, certificate, and firewall screenshots are captioned; run the documented redirect, external-port, persistence, and workflow checks during deployment.\\
Failed configurations & Record each failed attempt with its corrective action and retest result.\\
Redaction & Listings contain no credentials; review every future log and figure for secrets before inclusion.\\
Backup / restore & Test backup and restore separately from container-persistence verification.\\
\bottomrule
\end{tabularx}