Deployment Guide for Java Learning Platform¶
Overview¶
This guide outlines the complete process for deploying the Java Learning Platform to a production environment. The platform is deployed as a static documentation site using GitHub Pages with custom domain configuration and CDN integration.
Prerequisites¶
Before proceeding with deployment, ensure you have:
- GitHub Account: With permissions to access the repository
- Git: Installed locally for repository management
- Python Environment: For local testing (Python 3.8+ with pip)
- Domain: If using a custom domain name
- Cloudflare Account: For CDN setup (optional but recommended)
Deployment Architecture¶
The deployment architecture consists of:
┌────────────────┐
│ Cloudflare │
│ CDN/Cache │
└───────┬────────┘
│
▼
┌────────────────┐ ┌────────────────────────┐
│ GitHub │──Build──────▶ GitHub Pages Hosting │
│ Repository │ Actions │ │
└───────┬────────┘ └────────────┬───────────┘
│ │
│ │
│ ▼
┌───────▼────────┐ ┌────────────────────────┐
│ Local │ │ Custom Domain │
│ Development │ │ (Optional) │
└────────────────┘ └────────────────────────┘
GitHub Pages Deployment Process¶
Step 1: Configure Repository Settings¶
- Navigate to your repository on GitHub
- Go to Settings > Pages
- Configure source:
- Select "GitHub Actions" as the deployment method
- Set the branch to
main
or your preferred deployment branch
Step 2: Create GitHub Actions Workflow¶
Create a file at .github/workflows/deploy.yml
:
name: Deploy Documentation
on:
push:
branches:
- main
workflow_dispatch:
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Build documentation
run: mkdocs build
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./site
cname: your-custom-domain.com # Remove if not using custom domain
Step 3: Set Up Custom Domain (Optional)¶
- Purchase a domain from a domain registrar
- In your repository, go to Settings > Pages
- Under "Custom domain", enter your domain name
- Save the configuration
- Update DNS settings at your domain registrar:
- Add a CNAME record pointing to
mshemeel.github.io
- Or, for apex domains, add A records pointing to GitHub's IP addresses:
185.199.108.153 185.199.109.153 185.199.110.153 185.199.111.153
Step 4: Configure HTTPS¶
- In GitHub Pages settings, check "Enforce HTTPS"
- This will generate a free SSL certificate through Let's Encrypt
- Wait for the certificate to be issued (may take up to 24 hours)
Cloudflare CDN Integration (Optional)¶
Step 1: Set Up Cloudflare Account¶
- Create an account on Cloudflare
- Add your website to Cloudflare
- Update your domain's nameservers to those provided by Cloudflare
Step 2: Configure Cloudflare Settings¶
- SSL/TLS Settings:
- Set to "Full" mode
-
Enable "Always Use HTTPS"
-
Caching Configuration:
- Set caching level to "Standard"
-
Create a page rule to cache everything:
- URL pattern:
yoursite.com/*
- Setting: Cache Level: "Cache Everything"
- URL pattern:
-
Performance Settings:
- Enable Auto Minify for HTML, CSS, and JavaScript
- Enable Brotli compression
- Enable HTTP/2 and HTTP/3
Local Build and Testing¶
Before deploying, test your documentation locally:
# Clone the repository (if you haven't already)
git clone https://github.com/mshemeel/java-learning.git
cd java-learning
# Install dependencies
pip install -r requirements.txt
# Run the local development server
mkdocs serve
# Build the documentation locally
mkdocs build
The local site will be available at http://127.0.0.1:8000/
.
Continuous Deployment Workflow¶
The typical workflow for updating the documentation:
- Make changes to documentation content in a feature branch
- Test locally using
mkdocs serve
- Push changes to GitHub and create a pull request
- Review changes in the PR preview (if configured)
- Merge the PR to the main branch
- GitHub Actions will automatically build and deploy the changes
Deployment Verification¶
After deployment, verify:
- Content: Ensure all content is correctly displayed
- Links: Check that all internal and external links work
- Search: Test the search functionality
- HTTPS: Verify the site loads securely with HTTPS
- Mobile: Test the site on mobile devices
- Performance: Use tools like Google PageSpeed Insights to check performance
Maintenance and Updates¶
Regular Maintenance Tasks¶
- Content Updates:
- Commit and push content changes
-
GitHub Actions will automatically redeploy
-
Dependency Updates:
- Periodically update Python dependencies in
requirements.txt
-
Update MkDocs theme and plugins as needed
-
SSL Certificate:
- If using GitHub Pages with a custom domain, certificates auto-renew
- If using Cloudflare, certificates are managed automatically
Monitoring¶
- GitHub Actions: Monitor deployment workflows for any failures
- Cloudflare Analytics: Review traffic patterns and cache performance
- Error Tracking: Set up external monitoring for any site outages
Troubleshooting¶
Common Issues and Solutions¶
- Deployment Failures:
- Check GitHub Actions logs for detailed error messages
- Verify Python dependencies are correctly specified
-
Ensure the MkDocs configuration is valid
-
Custom Domain Issues:
- Verify DNS records are correctly configured
- Check the CNAME file in the repository
-
Allow up to 24 hours for DNS propagation
-
SSL Certificate Problems:
- Ensure "Enforce HTTPS" is enabled
- Check for mixed content warnings
-
Verify the certificate is issued for the correct domain
-
Performance Issues:
- Check image sizes and formats
- Verify Cloudflare caching settings
- Review JavaScript and CSS minification
Rollback Procedure¶
If a deployment causes issues:
- Identify the last known good commit
- Revert to that commit:
git revert <commit-hash> git push origin main
- Alternatively, manually roll back through GitHub interface:
- Go to repository Actions
- Find the last successful deployment
- Use the "Re-run jobs" option
Security Considerations¶
- Access Control:
- Limit write access to the repository
- Use branch protection rules for the main branch
-
Require pull request reviews before merging
-
Sensitive Information:
- Do not store API keys or secrets in the repository
- Use GitHub Secrets for sensitive information
-
Regularly audit repository content
-
External Dependencies:
- Regularly update dependencies to patch security vulnerabilities
- Consider using Dependabot for automated updates
Additional Resources¶
- MkDocs Deployment Guide
- GitHub Pages Documentation
- Cloudflare Documentation
- GitHub Actions Documentation
Conclusion¶
Following this deployment guide will result in a fully functional, secure, and performant documentation platform accessible to all users. The automated deployment pipeline ensures that content updates are quickly and reliably published, while the CDN integration provides optimal performance for users worldwide.