Deploy the Documentation Site¶
This guide covers how the MkDocs documentation site is deployed to AWS and how to work with the auto-deploy pipeline.
Overview¶
The docs site is a MkDocs Material static site served by Nginx on the same EC2 instance as the main app, at http://docs.2sigma.io. It has its own GitHub Actions pipeline that triggers automatically when doc changes are pushed to the staging branch.
The main app deploy workflow ignores docs/** changes entirely. Docs and app deployments are fully independent.
Architecture¶
The pipeline works like this:
- MkDocs source lives in
docs/andmkdocs.ymlin the backend repo - The GitHub Actions workflow at
.github/workflows/deploy-docs.ymltriggers on pushes tostagingwhen files underdocs/**ormkdocs.ymlchange - The workflow runs: checkout → install MkDocs dependencies →
mkdocs build --strict→ tar the output → SCP to EC2 → extract to~/docs-site/→ reload Nginx - Docker Compose bind-mounts
~/docs-site/on the EC2 host into the Nginx container at/usr/share/nginx/docs:ro - Nginx has a dedicated
serverblock fordocs.2sigma.iothat serves static files from/usr/share/nginx/docs
The result: pushing a doc change to staging gets it live within about a minute, with no manual steps.
DNS Setup¶
You need an A record pointing the docs subdomain at the EC2 Elastic IP:
| Record | Type | Value |
|---|---|---|
docs.2sigma.io |
A | 3.151.25.120 |
To verify DNS is resolving before it fully propagates, you can test the Nginx routing directly:
If Nginx is configured correctly, this returns the docs site HTML even before DNS propagates.
Deploying Docs Changes¶
The normal workflow for updating docs:
- Edit files in
docs/or updatemkdocs.yml - Commit and push to
main - Merge
mainintostagingto trigger the deploy:
- GitHub Actions builds and deploys automatically
- Verify at
http://docs.2sigma.io
Paths filter
The workflow only triggers when docs/** or mkdocs.yml files change. If you push to staging with only backend code changes, the docs pipeline won't run. This is intentional.
Building Docs Locally¶
Before pushing, preview your changes locally to catch broken links or formatting issues.
Install the required packages:
Start the live-reload dev server:
Open http://localhost:8000 in your browser. The server reloads automatically as you edit files.
To test the production build (same flags as CI):
Fix --strict failures before pushing
The CI pipeline runs mkdocs build --strict, which treats warnings as errors. Broken internal links and pages referenced in the nav but missing from docs/ will fail the build. Run this locally first to catch those issues.
The built site goes into site/. You can open site/index.html directly in a browser to inspect the output.
Manual Deployment¶
Use this if GitHub Actions is unavailable or for first-time setup.
Step 1: Build locally
Step 2: Package the output
Step 3: Transfer to EC2
scp -i ai-tutor-backend/terraform/ai-tutor-staging.pem \
/tmp/docs-site.tar.gz \
ec2-user@3.151.25.120:/tmp/docs-site.tar.gz
Step 4: Extract on EC2
SSH into the instance:
Then extract the archive:
mkdir -p ~/docs-site && rm -rf ~/docs-site/* && \
tar -xzf /tmp/docs-site.tar.gz -C ~/docs-site/ && \
rm /tmp/docs-site.tar.gz
Step 5: Reload Nginx
cd ~/ai-tutor-backend/deploy && \
docker compose --env-file .env.production exec -T nginx nginx -s reload
Exit the SSH session and verify at http://docs.2sigma.io.
Infrastructure Files¶
| File | Purpose |
|---|---|
deploy/nginx/nginx.conf |
server block for docs.2sigma.io, serves static files from /usr/share/nginx/docs |
deploy/docker-compose.yml |
Bind-mount from ~/docs-site/ on the host to /usr/share/nginx/docs:ro in the Nginx container |
.github/workflows/deploy-docs.yml |
CI/CD pipeline: build, transfer, extract, reload |
mkdocs.yml |
MkDocs configuration, nav structure, theme settings |
docs/ |
Documentation source files (Markdown) |
Troubleshooting¶
Docs not updating after push¶
Check that the GitHub Actions workflow actually ran. The paths filter means the workflow only triggers when docs/** or mkdocs.yml files are in the push. If you only changed backend code, the docs pipeline won't fire.
If the workflow ran but the deploy failed, check the Actions log for SSH connectivity errors. The EC2 instance must be reachable and the SSH key secret must be configured in the repo settings.
404 on docs.2sigma.io¶
The DNS A record may not be set or hasn't propagated yet. Test Nginx routing directly:
If this returns the docs HTML, Nginx is working and the issue is DNS only. If it returns a 404 or the main app, check the Nginx config for the docs.2sigma.io server block.
Nginx not serving docs¶
Verify the volume mount is in place and the files are there:
If the directory is empty or the command fails, the bind-mount may not be configured or ~/docs-site/ on the host is empty. Run the manual deployment steps above to populate it.
Build fails with --strict¶
The most common causes:
- A page is listed in the
mkdocs.ymlnav but the corresponding.mdfile doesn't exist - An internal link points to a page or anchor that doesn't exist
- A
mkdocstringsreference points to a Python object that can't be found
Run mkdocs build --strict locally and read the error output. It will tell you exactly which file and line caused the failure.