Skip to content

A template repository tailored for deploying Suri to DigitalOcean

License

Notifications You must be signed in to change notification settings

surishortlink/suri-deploy-digitalocean

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Suri

Your own short links as an easily deployed static site on DigitalOcean

You're viewing a template repository tailored for deploying Suri to DigitalOcean. Head over to the main repository to learn more about Suri, including additional deployment options.

Setup: Step By Step

Note: This is going to seem more complicated than it should be, but it's the only way to launch with a pre-configured setup that's also connected to your GitHub repository for auto-deployment. If you know of a more straight-forward way, please reach out!

  1. Hit the "Use this template" button above and then "Create a new repository". Fill in the required details to create a new repository based on this one. You must set the visibility to "Public"!
  2. Change line 8 of .do/deploy.template.yaml, replacing {{owner}} and {{repo}} in repo with the values for your new repository.
  3. On the DigitalOcean Control Panel, head to create a new app.
  4. Connect your GitHub account or edit existing permissions to grant access to your new repository. Don't hit "Next" after arriving back at DigitalOcean!
  5. Open the following URL, again replacing {{owner}} and {{repo}} with the values for your new repository: https://cloud.digitalocean.com/apps/new?repo=https://github.com/{{owner}}/{{repo}}/tree/main
  6. Hit "Skip to Review", as everything should already be set appropriately. Then hit "Create Resources" to begin the initial build and deploy.

Auto-Deploy

Any commits to the main branch of your new repository will trigger a new build and deploy. You can change this by going to the "Settings" of the suri component and editing the "Branch" and "Autodeploy" options.

Custom Domain

To use a custom domain, follow DigitalOcean's guide: How to Manage Domains in App Platform.

How It Works

Manage Links

At the heart of Suri is the links.json file, located in the src directory, where you manage your links. All of the template repositories include this file seeded with a few examples:

{
  "/": "https://www.youtube.com/watch?v=CsHiG-43Fzg",
  "1": "https://fee.org/articles/the-use-of-knowledge-in-society/",
  "gh": "https://github.com/surishortlink/suri"
}

It couldn't be simpler: the key is the "short link" path that gets redirected, and the value is the target URL. Keys can be as short or as long as you want, using whatever mixture of characters you want. / is a special entry for redirecting the root path.

Build Static Site

Suri ships with a suri executable file that generates the static site from the links.json file. The static site is output to a directory named build.

All of the template repositories are configured with a build script that invokes this executable, making the command you run simple:

npm run build

When you make a change to the links.json file, simply re-run this command to re-generate the static site, which can then be re-deployed. This template repository is configured to do this automatically.

Config

Configuration is handled through the suri.config.json file in the root directory. There is only one option at this point:

Option Description Type Default
js Whether to redirect with JavaScript instead of a <meta> refresh. Boolean false

Public Directory

Finally, any files in the public directory will be copied over to the build directory without modification when the static site is built. This can be useful for files like favicon.ico or robots.txt (that said, Suri provides sensible defaults for both).

About

A template repository tailored for deploying Suri to DigitalOcean

Resources

License

Stars

Watchers

Forks