DigitalOcean App Platform
DigitalOcean App Platform offers quick build and deployment from GitHub, GitLab, or Bitbucket.
This post walks through deploying an MkDocs site with the Material theme.
There are some differences between deploying a site with the free Material theme, and one using Material Insiders (accessible to sponsors). This guide covers both.
Prerequisites
I've assumed you:
- Have an MkDocs site using the Material theme
- Are using GitHub as your remote repo (but the process should be very similar for GitLab or Bitbucket)
- Have a DigitalOcean account
- If you are using Insiders, you have set up a personal access token.
Site setup
Add these files to the root of your project:
- A
runtime.txt
to set your Python version. For example:Make sure you use one of the supported Python versions. -
Either a
requirements.txt
,Pipfile
, orsetup.py
, so that DigitalOcean can recognise your project as a Python app. For an MkDocs site, the simplest option is arequirements.txt
file.For the free theme:
For the Insiders theme, you must still create an empty
requirements.txt
, even if you have no other dependencies.
Note
If you are using a monorepo pattern, note that the files must be in the root of the entire repo, not just the root of your MkDocs project.
Deployment
- In your DigitalOcean dashboard, select Create > Apps.
- Select GitHub. If this is your first time using App Platform, it will take you through an authentication process with GitHub. Make sure you allow access to the repo you want to deploy. Once GitHub is connected, DigitalOcean shows the Choose Source screen.
- Choose the repository you want to deploy.
- Select the branch you want to deploy, and choose whether to autodeploy changes. Select Next.
- On Configure your app, enter the build settings:
- Source Directory: if your repo only contains one site, leave this as
/
. If you have a monorepo (multiple sites/apps in one repo), choose the directory containing you MkDocs site. - Type: select Static Site.
- Environment Variables: if you are using Insiders, create an environment variable named
GH_TOKEN
, with your personal access token as the value. Select Encrypt to encrypt the value, meaning no-one can access the value of the GitHub token through the dashboard. - Build Command:
- For the free theme:
mkdocs build
. - For the Insider theme:
- For the free theme:
- Output Directory:
site
, or the value ofsite_dir
if your site uses a custom output directory name. - Leave HTTP Request Routes as its default, and don't add a database.
- Source Directory: if your repo only contains one site, leave this as
- Select Next.
- Enter a name for your site. Select Next.
- DigitalOcean automatically selects the starter plan for this type of project. It's designed for testing, and allows you to create three sites for free. Sadly, it won't permit you to choose a higher plan.
- Select Launch Starter App. DigitalOcean builds and deploys your site, providing a default URL so you can immediately view the live site as soon as the build finishes.
For guidance on next steps, including adding a custom domain, refer to the documentation.