See it. Understand it.
Then try the command.
Six milestones explain the whole journey. Pictures first, plain English next, and detailed command notes when you want them.
Download the complete command notes ↓All the detail is still here. Start with the pictures.
Connect to a server
How do I work on a remote computer safely?
Tell your Mac and VPS apart, connect with SSH, and understand accounts and permissions.
- 127.0.0.1 means the computer you are using.
- An SSH key is different from a website certificate.
- Check the machine and folder before changing files.
A working SSH connection to the Ubuntu VPS.
Two commands to recognize
Examples to understand, not a setup script to run from top to bottom. Check the location and current deployment state first.
ssh YOUR_USER@YOUR_SERVERConnect to your server. Replace the placeholder with its address.
whoami
hostname
pwdConfirm the account, computer, and folder before proceeding.
Go deeper, at your pace
Open only the notes you need3. Know which computer you are using
| Environment | How to recognize it | What belongs there |
|---|---|---|
| Mac Terminal | Prompt such as hari@MacBook-Air | Docker Desktop, runner management, pbcopy, SSH connection to VPS. |
| VPS terminal | Prompt such as YOUR_USER@your-server | Server project folders, sudo, host Nginx, production Docker containers. |
| CI test container | Commands appear under the validate job | Fake-provider tests, website asset checks, shell syntax checks. |
| CI build environment | Commands appear under publish-and-deploy | Registry login, AMD64 image builds, digest manifest, deployment SSH command. |
whoami
hostname
pwdWhere: either terminal. Why: establish account, machine, and working directory before changing anything. These commands are read-only.
ssh YOUR_USER@YOUR_SERVER
cd /path/to/portfolioWhere: start SSH in Mac Terminal; run cd after the remote prompt appears. Replace YOUR_VPS_IP with your server address. Why: a Linux server path exists on Ubuntu, not on the Mac. A sudo prompt in this remote session expects the VPS user's password. It does not expect the Mac password.
127.0.0.1 always means the machine on which the command runs. Opening the VPS loopback URL in the Mac browser points to the Mac instead of the VPS.
Put a website online
How does a page reach someone on the internet?
Follow a browser request through HTTPS, the reverse proxy, and the website container.
- Building an image does not start a container.
- Nginx routes requests; Docker runs the app.
- Check the old page as well as the new route.
The portfolio responds over public HTTPS.
Two commands to recognize
Examples to understand, not a setup script to run from top to bottom. Check the location and current deployment state first.
sudo nginx -tCheck the proxy configuration before reloading it.
curl -I https://harishjeeka.com/Inspect the public response headers. HTTP 200 means the page responded.
Go deeper, at your pace
Open only the notes you need7. Docker build, run, and health — different checkpoints
sudo docker build -t portfolio-chatbot:lab-20261029 .Historical, VPS chatbot lab. docker build creates an image from the Dockerfile. -t gives it a recognizable name and tag. The dot is the build context. A successful image build does not start a container.
sudo docker run -d \
--name portfolio-chatbot-check \
-p 127.0.0.1:8091:8000 \
portfolio-chatbot:lab-20261029Historical initial check. Do not rerun against the occupied port. -d runs in the background. --name gives the container a stable identifier. The mapping exposes host loopback port 8091 to application port 8000. Binding to loopback keeps direct public access away from the application port.
curl --fail http://127.0.0.1:8091/chatbot/healthzWhere: VPS. Expected: status ok JSON. What it proves: the application responds over HTTP. It does not check the key, model permissions, billing, or model output.
sudo docker ps -a
sudo docker logs --tail 50 CONTAINER_NAMEWhere: VPS. Why: inspect running/stopped state, then inspect the last 50 log lines for the specific container. Replace CONTAINER_NAME with a name from docker ps. Diagnose before stopping or rebuilding services.
12. Nginx and the visible widget
sudo cp -p /etc/nginx/sites-available/harishjeeka.com \
/etc/nginx/sites-available/harishjeeka.com.before-chatbot
sudo nano /etc/nginx/sites-available/harishjeeka.com
sudo nginx -tHistorical setup on VPS. cp -p captured the existing configuration and permissions before editing. nginx -t checks configuration syntax and referenced files. It does not itself reload the running server.
The added /chatbot/ location forwards to the backend, bounds HTTP body size and timeouts, and overwrites the visitor-IP header. It preserves the normal website location. The later deployment installer changes the destinations to named upstreams so CD can switch containers without rewriting the page routes.
sudo systemctl reload nginx
curl --fail https://harishjeeka.com/chatbot/healthz
curl -I https://harishjeeka.com/Where: VPS, after a successful configuration test. reload asks the service to use the new configuration. curl checks both new chatbot routing and the existing portfolio. -I requests headers only.
<script src="/chatbot/widget.js" defer></script>Where: portfolio index.html before the closing body tag. Why: load the separate browser widget after HTML parsing. The backend serves the script and accepts messages; the browser never reads the API key.
curl -fsS https://harishjeeka.com/ | grep -o '/chatbot/widget.js'What it proves: the delivered page includes the widget path. It does not prove the chat opens correctly, so we also checked the browser and sent a real question.
Make changes reviewable
How do I change a site without losing what works?
Separate local edits, commits, remote pushes, review, and release.
- A Git push is not a website deployment by itself.
- A branch protects the original work from accidental edits.
- The pipeline should validate before publishing.
Feature branches and pull requests preserve a reviewable change history.
Two commands to recognize
Examples to understand, not a setup script to run from top to bottom. Check the location and current deployment state first.
git status --shortSee which files changed before selecting a commit.
git diff --checkCheck for whitespace mistakes without changing the files.
Go deeper, at your pace
Open only the notes you need16. Git branch, pull request, and merge
git status --short
git diff --check
git switch -c feature/portfolio-chatbot-cicd
git add site/index.html site/styles.css site/learning.html Dockerfile \
.dockerignore .gitignore .ci .forgejo/workflows/ci.yml chatbot deploy PIPELINE.md
git commit -m "Add portfolio chatbot and verified Docker deployment pipeline"
git push -u origin feature/portfolio-chatbot-cicdHistorical integrated source preparation on VPS. status reveals pending edits. diff --check flags whitespace errors. switch -c creates a separate branch. add selects intended files. commit saves them locally. push uploads the branch; -u records its upstream for later pushes.
Existing uncommitted page and style changes were backed up and preserved rather than reset. Backup folders, credentials, environments, quotas, and Mac metadata were excluded from Git. A feature branch is a reviewable source change; it does not itself update the public website.
The pull request's validate job passed. publish-and-deploy was skipped because the workflow allows it only for a main push or a manual main run. Skipped in a PR is intentional, not a deployment error. An old PR run stays skipped after merging; open the new main run instead.
The message about no key to sign a commit concerned Git commit signing. It did not mean that HTTPS, deployment SSH, or the CI validation check had failed.
sudo docker image tag \
"$(sudo docker inspect --format '{{.Image}}' harish-portfolio)" \
harish-portfolio:before-chatbot
sudo docker compose up -d --build portfolioHistorical portfolio widget release, before CD promotion. inspect identified the image actually running. tag gave that image a rollback reference. Compose then rebuilt the intended portfolio service with the changed HTML. This is why editing source files alone did not make the widget visible. Keep this manual legacy procedure separate from the new blue/green controller.
Build an AI portfolio assistant
How can visitors ask questions without seeing my API key?
Keep model calls on the server, answer from approved facts, and control incoming requests.
- Health checks and real AI answers prove different things.
- Server limits matter even when the browser has a cooldown.
- This chatbot does not execute tools or server commands.
The visible widget returned a real AI answer. Eight backend tests passed.
Two commands to recognize
Examples to understand, not a setup script to run from top to bottom. Check the location and current deployment state first.
curl --fail http://127.0.0.1:8091/chatbot/healthzCheck whether the backend responds. This does not call the model.
python -m unittest -vRun the eight fake-provider tests without spending API credits.
Go deeper, at your pace
Open only the notes you need5. Why the model call is server-side
The browser sends one message to our own backend. The backend reads the mounted API key and calls the fixed OpenAI HTTPS endpoint. It never returns the key to the browser. The model request includes approved facts and a short instruction to say when information is missing.
We selected gpt-5.6-luna for cost-sensitive testing, disabled reasoning for that model, and capped max_output_tokens at 300. Access and billing depend on the API project. The output cap helps control each request's size; it is not an exact dollar budget.
The request sets store to false. That requests no Responses API storage; it does not establish zero retention under every provider policy. The widget tells visitors messages are sent to OpenAI and asks them to avoid sensitive information.
The widget uses textContent instead of inserting the model answer as HTML. A response containing HTML therefore displays as text instead of executing as a script.
6. Tests before containers
cd /path/to/portfolio/chatbot-lab
python3 -m venv .venv
.venv/bin/pip install -r requirements.txt
.venv/bin/python -m unittest -vWhere: VPS; this was the initial isolated lab setup. Why: a virtual environment separates project dependencies from system Python. pip installs the declared dependencies. unittest runs checks with readable case names.
Verified: eight tests passed. They cover health/widget delivery, validation, cooldown, quotas surviving a restart, per-IP and global budgets, daily budget, safe provider errors, and the two-call concurrency cap. A fake provider supplies responses, so these tests do not spend API credits.
python3 .ci/check_site.py
python3 .ci/test_deploy.py -v
bash -n deploy/portfolio-cd
bash -n deploy/install.shWhere: integrated repository; CI also runs equivalent commands. Why: check public asset references, deployment failure handling, and shell syntax before production execution. bash -n parses a script without executing it.
Verified: five controller tests passed. They prove the tested control flow with fake Docker/Nginx endpoints; they do not substitute for a real deployment and live rollback drill.
8. Secure runtime key setup
sudo install -d -m 700 /etc/portfolio-chatbot
sudo nano /etc/portfolio-chatbot/openai_api_key
sudo chown 10001:10001 /etc/portfolio-chatbot/openai_api_key
sudo chmod 400 /etc/portfolio-chatbot/openai_api_keyHistorical administrator setup on VPS. install creates the protected directory. nano lets you enter the key without putting it in a shell command or Git. chown assigns the file to the backend's numeric container user. chmod 400 allows only that owner to read the file.
The Docker engine, running as administrator on the VPS, mounts the file into the application. The application itself runs as UID 10001. A numeric UID inside a container is not a reason to grant broad permissions to a host account.
9. Compose turns runtime options into configuration
sudo docker stop portfolio-chatbot-checkHistorical transition only. This stopped the temporary check container to free port 8091 before starting the managed chatbot. It did not stop the portfolio container on port 8080.
sudo docker build -t portfolio-chatbot:lab-luna .
sudo env \
CHAT_IMAGE=portfolio-chatbot:lab-luna \
OPENAI_MODEL=gpt-5.6-luna \
OPENAI_KEY_PATH=/etc/portfolio-chatbot/openai_api_key \
docker compose -p portfolio-chatbot up -dHistorical, separate VPS chatbot lab. env supplies non-secret configuration to this command. It contains the key file's path, not the key value. Compose creates the declared service, quota volume, read-only filesystem, temporary /tmp, loopback binding, and resource limits. -p sets the Compose project name, keeping this service separate from the portfolio project.
After automated CD promotion, use the deployment controller rather than re-running these legacy Compose commands against the old ports.
10. Verify one real model response
curl -i --max-time 35 \
http://127.0.0.1:8091/chatbot/api/chat \
-H 'Origin: https://harishjeeka.com' \
-H 'X-Chat-Client-IP: 127.0.0.1' \
-H 'Content-Type: application/json' \
--data '{"message":"Who is Harish? Answer in one sentence."}'Where: VPS; this makes a small billable model request. -i shows response headers and body. --max-time bounds the client wait. --data supplies the message and makes this a POST. Content-Type declares JSON. Origin matches the website. The client-IP header is supplied here only because this is a direct trusted loopback smoke test.
Verified: HTTP 200 and an answer describing Harish's portfolio background. A 200 header by itself is less useful than inspecting the answer body too.
Through the public route, Nginx overwrites X-Chat-Client-IP with the visitor address; it must not trust a caller's arbitrary value. An Origin check is a browser restriction, not authentication: scripts outside browsers can forge it.
11. Rate limiting and throttling
| Control | Current implementation | Why |
|---|---|---|
| Per-visitor budget | 10 admitted calls per 60-second window | Restricts repeated usage from one IP identity. |
| Global minute budget | 30 admitted calls per 60-second window | Bounds total short-term consumption. |
| Global daily budget | 200 admitted calls per 24-hour window | Adds a persistent cost guardrail. |
| Cooldown | At least 3 seconds between admitted calls per IP | Slows rapid repeated requests. |
| Concurrency | Two upstream calls per backend process | Avoids an unbounded provider-call queue. |
| Input limits | 1–1000 message characters, 4 KB HTTP body limit | Bounds individual request size. |
SQLite transactions prevent concurrent requests from bypassing the request budgets. A Docker volume preserves those budgets across container restarts. The windows begin with their first admitted request; the daily window is not necessarily a midnight calendar reset.
The backend hashes the supplied IP identity for database keys. It does not persist conversation text in this limiter. Shared networks can share an IP allowance. Global budgets remain important because a determined caller may rotate IP addresses.
A rejected request returns HTTP 429 and Retry-After. The browser also waits, but server enforcement is the actual control. Two successful requests sent manually a few seconds apart do not prove throttling failed. During a blue/green transition, two backend processes briefly coexist: database budgets are shared, while the two-call concurrency semaphore is separate in each process.
Keep a single worker and instance for the steady-state design. Scaling it to multiple workers/replicas requires shared concurrency controls, not merely more containers.
Automate checks and image builds
How can every reviewed change be tested and packaged?
Connect a runner, understand PR checks, and build the right image for the VPS.
- A runner executes jobs; the Git server does not do it alone.
- Publishing is intentionally skipped for pull requests.
- A tag is a name; a digest identifies the exact image.
Validation passed. Both release images were published and pulled onto the VPS.
Two commands to recognize
Examples to understand, not a setup script to run from top to bottom. Check the location and current deployment state first.
docker version
docker buildx versionConfirm the Docker client, engine, and cross-platform builder are available.
docker compose -p portfolio-ci psCheck the runner containers. Also confirm Forgejo shows the runner online.
Go deeper, at your pace
Open only the notes you need13. Mac Docker setup and PATH
export PATH="$HOME/.docker/bin:$PATH"
docker version
docker buildx versionWhere: Mac Terminal. export tells this shell where to find Docker's installed command. It does not install Docker or restart the engine. docker version should display both Client and Server. buildx version checks the build tool used for cross-platform images.
Verified locally: Docker client/engine 29.9.2 and Buildx 0.38.1. The Mac is ARM64; the VPS is x86_64. A normal native Mac build can produce the wrong architecture for the VPS, so our publication workflow explicitly builds linux/amd64.
docker buildx build --platform linux/amd64 --push ...Pipeline pattern, not a complete command to paste. --platform selects the VPS architecture; --push publishes the result instead of relying on a locally loaded image. The workflow reads the published image digest from Buildx's metadata file.
14. Mac runner registration and operation
The runner image was prepared with the official Forgejo runner plus Node, Python, Git, OpenSSH, Docker CLI, and Buildx. This avoids installing the full build toolchain directly in the Mac's shell.
python3 register.py
docker compose -p portfolio-ci up -d
docker compose -p portfolio-ci psWhere: Mac Terminal, inside outputs/mac-forgejo-runner. First create a repository-scoped runner named mac-portfolio in Forgejo. register.py prompts for its UUID and hidden token, stores private local registration files, and never prints the token. Compose starts the TLS-protected engine and the runner. ps shows container health; the Forgejo page or runner logs confirm the runner is actually connected.
docker compose -p portfolio-ci logs --tail 40 runnerExpected evidence: mac-portfolio declared successfully, labels docker and portfolio-builder, and poller launched. Container Up alone does not prove registration worked.
The docker label runs tests in separate job containers. The portfolio-builder label executes trusted main jobs inside the runner container; it does not execute them directly in the Mac's user shell. Do not use this setup for untrusted repositories or unreviewed main-branch code.
docker compose -p portfolio-ci stop
docker compose -p portfolio-ci up -dWhere: same Mac runner folder. stop pauses the runner and its engine for a break; up -d resumes them. This does not stop the public VPS website. Keep the Mac awake during jobs. Do not delete volumes unless intentionally discarding build state.
17. What the CI/CD workflow does automatically
The validate job installs test tools, checks local website references and widget inclusion, checks JavaScript and shell syntax, runs eight chatbot tests, and runs five deployment-controller tests. These tests do not use a live OpenAI key.
The publish-and-deploy job runs after validation, only for main. It performs these steps:
- Creates a temporary directory with restrictive default permissions.
- Logs into the registry using the publishing secret through standard input.
- Writes the commit SHA into site/release.txt and makes that public file readable with mode 0644.
- Builds website and chatbot images for linux/amd64, labelled with the same commit SHA.
- Pushes the images and reads their immutable SHA-256 digests from metadata.
- Creates a small JSON release manifest containing revision and the two approved image digests.
- Stores the deployment SSH key in a temporary protected file.
- Confirms this revision still matches current main.
- Connects to the pinned VPS host and submits the manifest to the restricted deploy command.
- Removes temporary credential files when the job exits.
umask 077
printf '%s\n' "$REGISTRY_TOKEN" | docker login REGISTRY \
--username "$REGISTRY_USER" --password-stdinPipeline explanation only. umask makes newly created credential files private. --password-stdin keeps the secret out of the command arguments. Do not type real tokens into command strings or enable command tracing around secrets.
docker buildx build --platform linux/amd64 --pull --provenance=false \
--label "org.opencontainers.image.revision=$REVISION" \
--metadata-file "$temp_dir/site-meta.json" -t "$site" --push .Pipeline command. --pull checks the base image, the label records source identity, metadata-file captures the resulting digest, and --push publishes. The current workflow does not attach Buildx provenance; this simplifies the single-image artifact used in the lab and is not a claim of full supply-chain attestation. Base image updates can affect builds even with the same source; reviewed base digests and dependency locks are a later reproducibility improvement.
The deployment manifest uses image digests rather than mutable latest tags. A tag can be moved to another image; a digest identifies the specific published artifact.
Promote a release safely
How do I catch a broken release before visitors see it?
Start a candidate, verify it, switch routing only after checks, and keep the previous version.
- The first deployment stopped before promotion.
- The public marker needed 0644; secrets stayed restricted.
- Successful promotion and the live rollback drill are pending.
Candidate checks caught a permissions problem before the traffic switch. The targeted fix is verified locally.
Two commands to recognize
Examples to understand, not a setup script to run from top to bottom. Check the location and current deployment state first.
chmod 0644 site/release.txtMake only the public release marker readable by Nginx.
curl --fail https://harishjeeka.com/release.txtCompare the returned revision with the deployed main commit.
Go deeper, at your pace
Open only the notes you need18. VPS bootstrap and controlled promotion
cd /path/to/portfolio
sudo bash deploy/install.sh \
/path/to/private-deployment-key/id_ed25519.pubOne-time administrator setup, already completed. The installer checks the existing routes and mounted key, records the current quota volume, installs root-owned helpers, creates a restricted deployment account, installs its public key with a forced command, and adds narrowly specified sudo rules.
It backs up Nginx and replaces the fixed application destinations with named upstreams that initially point at the same working legacy containers. nginx -t must pass before reload. The installer did not grant the everyday account broad passwordless sudo or Docker group membership.
The controller accepts only the expected registry/image names, SHA-256 digests, and a valid revision format. It serializes attempts using flock. It pulls both images and checks their revision labels before starting candidates.
| Pair | Website loopback port | Chatbot loopback port |
|---|---|---|
| Legacy existing services | 8080 | 8091 |
| Blue candidates | 18080 | 18091 |
| Green candidates | 18081 | 18092 |
The next inactive pair is started before the active pair is replaced. Checks include release.txt content, chatbot health, and one short real model answer. That last check is billable and consumes the existing request quota. Provider or quota errors prevent promotion rather than silently bypassing the check.
Only after candidate checks does the controller change the upstream configuration, test Nginx, reload it, and verify public endpoints and the exact site revision. It retains the previous containers and routing state. On a later release it removes only the inactive containers labelled as managed by this controller, not unrelated services.
19. The HTTP 403 incident and the fix
Observed in the main deployment log: both images were built, published, and downloaded. Deployment SSH worked. The controller repeatedly received HTTP 403 for the candidate endpoint /release.txt on port 18080, then stopped before its routing-switch step.
The generated release marker was created after this command:
umask 077
printf '%s\n' "$REVISION" > site/release.txtA newly created ordinary file normally starts from permission bits 0666. Applying umask 077 removes group and other permissions, resulting in mode 0600. Docker COPY preserved the file permission, and the Nginx worker could not read the root-owned marker.
This restrictive setting was appropriate for the temporary deployment key and registry credentials. The mistake was letting a public website file inherit the same restriction.
The targeted fix is:
printf '%s\n' "$REVISION" > site/release.txt
chmod 0644 site/release.txtMode 0644 means owner read/write and group/others read. We changed only the public release marker. We did not weaken secret-file permissions or change the whole job's umask. The workflow mistake was introduced during the assistant-prepared setup; it was not a command-entry error by the user.
Verified with a real local Nginx container: the otherwise identical file at 0600 returned 403; the file at 0644 returned HTTP 200 with the expected revision. The temporary test container was removed afterward.
Still pending: publish the fix branch, pass CI, merge, and observe a successful main promotion. The local reproduction proves the identified file-read problem and correction; it is not evidence that the entire production pipeline has now completed.
A 403 means the HTTP server received the request but refused access. It is a different boundary from a 502 proxy/upstream failure or an unreachable port. The right next action here was to inspect the candidate's file access, not rotate API keys or disable HTTPS.
Other setup issues also had specific causes. Docker Desktop was running but the Mac shell could not find its CLI until its bin directory was added to PATH. A Docker download initially could not find its credential helper for the same reason. Running Ubuntu server-folder commands on the Mac produced a missing-directory error; the fix was to SSH to the VPS first. The private runner engine initially used a hostname absent from its TLS certificate; a Docker network alias matching the certificate fixed it without disabling verification. Mac transfer metadata files were removed from the source branch and ignored. None of these required exposing secrets or resetting the live site.
20. Read deployment state and exercise rollback
sudo cat /var/lib/portfolio-cd/current.json
sudo cat /var/lib/portfolio-cd/previous.jsonWhere: VPS administrator terminal. These state files identify current and previous releases. A previous release file is created after a successful promotion; its absence before that first success is expected. These are state manifests, not API-key files.
curl --fail https://harishjeeka.com/release.txt
curl --fail https://harishjeeka.com/chatbot/healthzAfter a successful new deployment: release.txt should match the deployed main SHA. Also open the site and ask one chatbot question. A health endpoint alone does not validate the visible experience.
sudo /usr/local/sbin/portfolio-cd rollbackPlanned drill, only after a successful release with a retained previous pair. This points Nginx back to the prior containers, verifies the configuration and public routes, and records the transition. It does not erase the quota volume or the API key.
Verify the site after rollback, then rerun the current successful main workflow to return to the new release. A real rollback drill is part of completing this lab. Do not claim it happened merely because a mocked test passed.
21. Remaining milestones and future agent work
The immediate milestone is to merge the release-marker fix, observe a complete main deployment, check the public release SHA and chatbot, perform the rollback drill, and restore the new version. Record real evidence before changing its status to completed.
Later improvements include reviewed immutable base images and dependency locks, monitoring, backups and off-server recovery, more realistic abuse controls for public traffic, and evaluation of chatbot factual accuracy. Revisit multi-process request controls before adding replicas.
To evolve the chatbot into an agent, add a specific read-only tool, validate its arguments and authorization in application code, constrain where it can connect, and test how failures and malicious user requests are handled. A model suggesting a shell command is not permission for the server to execute it.
Reference & vocabulary
Current status, architecture, file purposes, credential boundaries and the complete glossary.
1. What works and what is still pending
| Component | Evidence and current status |
|---|---|
| Portfolio website | Public HTTPS responds with HTTP 200. Existing content was preserved. |
| Website chatbot | Visible widget and a real API-generated answer were verified. |
| Server-side API key | Mounted into the backend at runtime; absent from browser code and image build context. |
| Request controls | Eight application tests passed, covering validation, cooldown, quotas, concurrency, and error handling. |
| Forgejo runner | Registered on the Mac with docker and portfolio-builder labels. Docker engine and runner were observed healthy. |
| Pull-request CI | The validate job passed. Publishing was deliberately skipped for pull_request events. |
| Image publishing | The main pipeline built and pushed both images. |
| Deployment authentication | The VPS accepted the restricted SSH deployment command and pulled both private images. |
| First automated promotion | Stopped before traffic changed because release.txt returned HTTP 403. |
| Permission fix | Committed on fix/ci-release-file-permissions. A real local Nginx check reproduced 403 with mode 0600 and returned 200 with mode 0644. |
| Full automated deployment | Still requires the fix to be published, merged, and successfully executed. |
| Rollback | Five isolated deployment-controller tests passed, including rollback paths. A live rollback drill is still pending. |
The chatbot is an LLM application. It answers from approved portfolio facts. It does not autonomously run commands or call tools, so we have not claimed a tool-using AI agent is complete.
2. The architecture
The public request path is:
Visitor browser
→ HTTPS on harishjeeka.com
→ host Nginx reverse proxy on the VPS
→ website container for normal pages
→ chatbot backend for /chatbot/*
→ OpenAI Responses API
→ JSON answer
→ widget renders answer as textThe delivery path is:
Code branch → Forgejo pull request → validation
Merge into main → validation → Docker builds on Mac runner
→ images pushed to Forgejo registry
→ image digests sent over restricted SSH
→ candidate containers on VPS loopback ports
→ health checks and one real AI smoke test
→ Nginx routing switch
→ public verification
→ previous release retained for rollbackThe Mac runner uses a separate Docker-in-Docker engine over TLS. Its engine has no published host ports and does not mount the Mac's Docker socket or personal folders. It is privileged inside Docker Desktop; use it for this trusted private repository. It is not an isolation guarantee against hostile main-branch code.
The website continues running if the Mac sleeps or the runner stops. New pipeline jobs wait until the runner is available.
4. Files and why they exist
| File or directory | Purpose |
|---|---|
| site/index.html | Portfolio homepage; includes the chatbot script. |
| site/learning.html | Learning journal and milestone evidence. |
| site/styles.css | Website styling. |
| chatbot/app.py | Input validation, quotas, concurrency control, and server-side model request. |
| chatbot/portfolio.txt | Approved public facts supplied to the model. |
| chatbot/widget.js | Browser chat interface; contains no API key. |
| chatbot/test_app.py | Tests using an injected fake provider, without paid API requests. |
| chatbot/requirements.txt | Flask and Gunicorn dependencies. |
| chatbot/Dockerfile | Builds the backend runtime image. |
| .dockerignore | Restricts the website build context to intended public files. |
| chatbot/.dockerignore | Restricts the chatbot build context to intended runtime files. |
| .gitignore | Excludes credentials, environments, quotas, backups, and Mac transfer metadata. |
| .forgejo/workflows/ci.yml | Defines validation, publication, and deployment jobs. |
| .ci/check_site.py | Checks local website asset links and widget inclusion. |
| .ci/test_deploy.py | Tests deployment behavior against fake infrastructure. |
| .ci/require_current_main.py | Refuses deployment from an obsolete main run. |
| .ci/known_hosts | Pins the VPS public SSH host key. |
| deploy/install.sh | One-time administrator setup for the restricted deployment gateway. |
| deploy/gateway | Permits only deploy or rollback commands for the CI SSH account. |
| deploy/portfolio-cd | Pulls verified images, starts candidates, checks them, switches routing, and recovers on failure. |
The original separate chatbot lab remains at /path/to/portfolio/chatbot-lab. The integrated repository is /path/to/portfolio. The Mac runner files are in this chat workspace's outputs/mac-forgejo-runner directory; its private registration data is under work/mac-forgejo-runner/data.
15. Keep the different credentials separate
| Credential | Lives where | Used for |
|---|---|---|
| OpenAI API key | Protected VPS runtime file | Backend model calls only. |
| Runner UUID/token | Private Mac runner data | Runner registration and job polling. |
| VPS registry token | Root-only Docker config on VPS | Pulling private release images. |
| REGISTRY_USER | Repository Actions secret | Registry account name. |
| REGISTRY_TOKEN | Repository Actions secret | Publishing the two images; package write permission. |
| DEPLOY_SSH_KEY | Repository Actions secret | Calling the restricted VPS deployment gateway. |
| VPS public SSH host key | .ci/known_hosts | Verifying that the runner reached the expected server. It is public, not a password. |
| Git push credential | Entered at Git's authentication prompt | Pushing source changes; repository write access. |
sudo env DOCKER_CONFIG=/etc/portfolio-cd/docker \
docker login git.harishjeeka.com --username HarishWhere: VPS. Paste the Forgejo registry token at the password prompt. DOCKER_CONFIG selects the root-only configuration used by the controller. The later log proves registry authentication worked because the VPS pulled both private images.
ssh YOUR_USER@YOUR_SERVER \
'cat /path/to/private-deployment-key/id_ed25519' \
| pbcopyWhere: Mac Terminal only. Why: copy the dedicated deployment key straight to the Mac clipboard for the DEPLOY_SSH_KEY secret editor without printing it. pbcopy is a Mac command, not an Ubuntu command. Never paste that clipboard value into chat or commit it.
The publishing token needs write:package. Git source pushes need write:repository instead. Forgejo's package scopes are not the same as repository-specific token permissions; avoid describing a package token as a repository-scoped Git credential. The exact scope enforcement depends on the Forgejo version and account permissions.
umask 077
mkdir -p /path/to/private-deployment-key
ssh-keygen -q -t ed25519 -N "" -C portfolio-cd \
-f /path/to/private-deployment-key/id_ed25519
chmod 700 /path/to/private-deployment-key
chmod 600 /path/to/private-deployment-key/id_ed25519Historical automated preparation on VPS; do not overwrite the existing key. ssh-keygen created a dedicated Ed25519 deployment keypair. The empty passphrase permits unattended CI; restricted server-side commands and carefully scoped secret access are therefore important. The .pub file was installed on the deployment account. The private file is copied only to the Actions secret, not to Git or the public site. The runner's registration token is a different credential entirely.
22. Quick vocabulary
| Term | Meaning in this project |
|---|---|
| Image | Packaged application and runtime, built before it runs. |
| Container | A running or stopped instance of an image. |
| Build context | Files the Docker client may send to the builder. |
| Volume | Persistent Docker-managed data, used here for quotas and build state. |
| Reverse proxy | Nginx accepts public traffic and forwards to a backend. |
| CI | Automated validation of a source change. |
| CD | Controlled delivery/deployment of a tested artifact. |
| Runner | Machine/process that executes Forgejo jobs. |
| Registry | Storage and distribution for container images. |
| Digest | Immutable content identifier for a particular image artifact. |
| Smoke test | Small check of a critical real behavior. |
| Blue/green | Candidate and current service pairs kept separate for promotion and recovery. |
| Rollback | Restore a known previous release when a new one is unsuitable. |
| Rate limit | Maximum admitted requests over a time window. |
| Throttle | Control how quickly or how many requests are processed. |
23. Reference documentation
- OpenAI Responses/text generation
- GPT-5.6 Luna model configuration
- Docker Desktop for Mac
- Docker cross-platform builds
- Dockerfile COPY
- Forgejo workflow reference for the installed server generation
- Forgejo runner registration
- Forgejo container registry
- Forgejo token scopes
- Forgejo runner security
This document records the actual lab state and commands, not a claim that every production-hardening item is complete. Replace placeholders deliberately, check which machine you are on, and use the current pipeline instead of blindly repeating historical setup commands.