Automating Documentation Site Deployment with AI Coding Tools
A public documentation site needs reliable deployment without overloading a small production server or giving hosted CI runners access to production. This article explains how an idle cloud instance became a self-managed build and deployment hub, using a private repository mirror, dependency caching, restricted deployment permissions, atomic release switching, and rollback. It also describes where AI coding tools helped with planning, configuration, and troubleshooting—and where human judgment remained essential.
1. The Starting Point: Deployment Was the Bottleneck
I maintain a public documentation site for a new product, with its source code hosted in a public repository. My daily workflow is straightforward: edit the documentation on a desktop or laptop, preview it locally, then commit and push. The only awkward part was deployment.
Initially, deployment was manual: log in to the production server, pull the latest code, build the site, and copy the output into place. It worked, but every release required intervention and left room for missed steps. Three practical constraints stood in the way of automation:
- The production server had limited resources. It could handle the live site, but adding dependency installation, frontend builds, and pipeline orchestration would introduce CPU and memory spikes that could affect availability.
- There was no existing CI infrastructure. I did not have a persistent continuous integration server, and setting one up would add maintenance overhead.
- Production had strict security boundaries. Externally hosted pipelines were not allowed to hold deployment permissions. Network access and account privileges were explicitly restricted.
Meanwhile, I had an idle cloud instance available through a provider’s free allowance, with 4 CPU cores and 24 GB of memory. That reframed the problem: could this unused machine become an automated deployment hub while the existing production server continued serving traffic?
2. Why Not Connect Hosted CI Directly to Production?
For a public documentation site, the repository platform’s hosted CI service would normally be the simplest option. In this case, however, the obstacle was not functionality—it was the trust boundary.
Hosted pipeline execution environments are managed by the platform, and deployment requires making target-host credentials available to that environment. Giving those runners access to production would place production entry permissions in the hands of a third-party execution environment, conflicting with the existing security policy.
The goal was therefore not to choose the most popular CI solution. It was to reuse available resources within a controlled security boundary, while preserving my existing editing and commit workflow.
3. Define the Constraints Before Choosing Tools
Making the constraints explicit provided the basis for every subsequent technical decision:
- Keep the source code in the public repository so the collaboration workflow remains unchanged.
- Run no dependency installation or build tasks on production; it should only serve static files.
- Use the idle, higher-capacity cloud instance for the control plane: repository mirroring, pipeline scheduling, build caching, and deployment orchestration.
- Deploy through a dedicated, low-privilege account that can write only to the designated static-content directory, with no privilege escalation or shell login.
- Make the infrastructure reusable so other small projects can share it.
- Keep deployments observable and reversible, without exposing a partially updated site when a release fails.
4. Architecture: Separate Build and Deployment Control from Serving
The resulting workflow was:
Local documentation edits → Public repository → Private mirror repository→ Build runner → Artifact synchronization → Production activation→ Deployment notification
The architecture has two planes:
- Control plane—the idle, higher-capacity instance: Hosts the private repository mirror, pipeline service, and build runner. All resource-intensive work happens here, including dependency resolution, site builds, cache reuse, and deployment orchestration.
- Serving plane—the production server: Serves static content without participating in builds. It exposes only a restricted deployment channel.
This separation decouples frequent, potentially untrusted changes from a production environment with a deliberately small attack surface. If the control plane is compromised, its production access is still limited to the restricted deployment account. Production retains its minimal service footprint.
The following pipeline definition is illustrative. Its fields and commands are generic; actual platform names may differ.
stages: [mirror, build, sync, activate, notify]build:stage: buildcache:key: docs-depspaths: [cache/]script:- install_dependencies --frozen- build_site --output ./distartifacts:paths: [dist/]activate:stage: activatescript:- sync_artifacts --to "$PROD_HOST:/srv/site_releases/$BUILD_ID"- switch_symlink --target "$BUILD_ID"- verify_http_status --path /
5. Four Key Implementation Details
Private Repository Mirroring and Build Triggers
A private mirror sits between the public repository and the private pipeline. Changes detected on the mirror side trigger builds.
This preserves the public repository’s role as the collaboration entry point while keeping deployment triggers inside infrastructure I control. Trigger credentials remain on the control plane; production does not need to interact with the upstream repository platform.
Dependency Caching and Resource Isolation
Dependency installation accounts for much of the build time. Keeping the dependency cache on a persistent volume and using the dependency lockfile hash as the cache key avoids repeated downloads for most builds.
The build runners also have concurrency and memory limits. These prevent projects sharing the same host from competing unchecked for resources.
A Least-Privilege Deployment Channel
Production has a dedicated deployment account with write access limited to the designated static-content directory. Interactive login and port forwarding are disabled.
Deployment uses an allowlist of restricted commands rather than accepting arbitrary remote commands:
# Control plane: synchronize artifacts without running arbitrary remote scriptssync_artifacts --to "$PROD_HOST:/srv/site_releases/$BUILD_ID"# Production exposes only a controlled release-switching commandactivate_release --id "$BUILD_ID"
Atomic Release Switching and Rollback
Each deployment uploads its artifacts into a new directory identified by the build number. The release becomes active by switching a symbolic link to that directory.
The live site therefore points to a complete release rather than a directory that is still being updated. If validation fails, the old link is retained and an alert is raised. Rolling back means pointing the link to the previous release, which takes only seconds.
6. Where AI Coding Tools Helped
Rather than manually building the environment from scratch, I used an AI coding tool for much of the work between refining the design and implementing it. It helped in three areas:
- Evaluating trade-offs: It helped make decisions explicit, including why hosted CI was unsuitable and why the control plane needed to be separate. This surfaced overlooked requirements such as restricted deployment accounts and atomic release switching.
- Generating configuration: From the stated constraints, it produced initial pipeline definitions, service orchestration configuration, and synchronization scripts, reducing the amount of boilerplate I had to write.
- Diagnosing failures: When builds failed, I supplied both logs and configuration for analysis. Most issues—such as ineffective cache keys, insufficient permissions, or inconsistent paths—could be narrowed down in a single exchange.
The distinction matters: the tool took over information organization and boilerplate generation, not responsibility for architecture or security boundaries. Those decisions remained mine.
7. Reuse and Future Improvements
This structure is reusable for projects with similar constraints: externally hosted source code, insufficient production build resources, and restricted production access.
Three general cloud capabilities could extend it:
- Centralized logging to collect build and deployment logs.
- Monitoring and alerting with thresholds for deployment success rates and site availability.
- Object storage to archive historical artifacts for longer-term rollback.
These additions can build on the same separation between deployment infrastructure and production serving.
8. Lessons Learned
- Start automation by documenting constraints, not by selecting tools.
- Separating build and deployment control from production serving is a practical approach when production resources are limited.
- Minimize deployment privileges. An extra controlled activation step is preferable to giving a pipeline broad access.
- Atomic releases and fast rollback contribute more to reliability than deployment speed alone.
- AI coding tools are useful for exploring designs and generating implementation scaffolding, but critical architectural and security decisions still require human review.
