Hosting Static Content with DigitalOcean

· klm's blog

Steps to host static content on DigitalOcean: 1. connect either GitHub or GitLab repo, 2. Any change in the repo or settings triggers a new build a...

Original post is here: eklausmeier.goip.de

I wrote about hosting static sites on various platforms:

  1. Hosting Static Content with surge.sh
  2. Hosting Static Content with now.sh, now.sh renamed themself to vercel.app
  3. Hosting Static Content with netlify.app
  4. Hosting Static Content with Cloudflare
  5. Hosting Static Content with Neocities
  6. Hosting Static Content with GitLab
  7. Hosting Static Content with GitHub

DigitalOcean offers what they call "App Platform". It is a "Platform-as-a-Service (PaaS)". They have "apps" for React, Django, Go, Jekyll, Next.js, Python, Ruby, Hugo, TypeScript, Hexo, PHP, Node.js, Gatsby, and some others.

Here, I confine myself to the "Sample App for Static HTML Assets". I only show how to use GitHub as source for static files. GitLab would be totally similar.

1. Steps to setup. Here are the steps to create a static site on DigitalOcean.

  1. Go to "App Platform"
  2. Click "Create App"
  3. Select one of the repositories, GitHub in this case

  1. Provide access to your GitHub account, if you haven't done so
  2. Choose proper GitHub repo

Whenever changes in the GitHub repo, or you change the settings in DigitalOcean, you initiate a new build.

Unfortunately, the name used for DNS, here eklausmeier-5257s.ondigitalocean.app cannot be changed. It is partly autogenerated.

2. Build configuration. The default build configuration for static sites is:

 1lerts:
 2- rule: DEPLOYMENT_FAILED
 3- rule: DOMAIN_FAILED
 4features:
 5- buildpack-stack=ubuntu-22
 6ingress:
 7  rules:
 8  - component:
 9      name: eklausme-github-io
10    match:
11      path:
12        prefix: /
13name: eklausmeier
14region: fra
15static_sites:
16- environment_slug: html
17  github:
18    branch: master
19    deploy_on_push: true
20    repo: eklausme/eklausme.github.io
21  name: eklausme-github-io
22  source_dir: /

3. Limitations. DigitalOcean does have some annoying limitations. My blog cannot be fully hosted on the DigitalOcean app. If I remove all images then DigitalOcean can host it. So it seems there is some undocumented limit on the number of files.

In the free version you can only have up to three apps.