Profile picture Schedule a Meeting
c a n d l a n d . n e t

Bridgetown with Dynamic Routes on Dokku

Dusty Candland | | proofreader, bridgetown, ruby, dokku, jamstack, turbo, hotwire

Bridgetown is a Ruby based static site generator. Being Ruby is awesome already, but with the new dynamic routes feature and support for Turbo it could be a really powerful site builder. Static for most things, and dynamic content provided by Turbo!

To test things out, I converted an older Jeklly based site, Proofreader.io.

I'm assuming you have Dokku already setup and a Bridgetown site ready to deploy. From the projects root directory, these are the things we need.

Add a post build script for Dokku to build static files and assets.

package.json

{
  ...
  "scripts": {
    ...
    "heroku-postbuild": "bin/bridgetown deploy"
  },
  ...
}

Next, create a proc file for Dokku to run. We need to change the port to 5000, the default for Dokku.

Procfile

web: bin/bridgetown start -B tcp://0.0.0.0:5000

Then, add the build packs we need, Ruby & JavaScript.

.buildpacks

https://github.com/heroku/heroku-buildpack-ruby
https://github.com/heroku/heroku-buildpack-nodejs

Add the Linux platform for bundler.

bundle lock --add-platform x86_64-linux

Deploy to Dokku

I set my DOKKU_HOST with Direnv on a project by project basis.

.envrc

export DOKKU_HOST=dokku.host.com

Don't forget to add .envrc to .gitignore!

Create a Dokku app and add some required environment vars, add your domains, and setup TLS.

dokku apps:create proofreader
dokku config:set
dokku config:set --no-restart BRIDGETOWN_ENV=production DOKKU_LETSENCRYPT_EMAIL=<your@email>
dokku domains:add proofreader.io
dokku domains:add www.proofreader.io
dokku letsencrypt
git push dokku main

Assuming all goes well, we'll have a Bridgetown site up and running, supporting dynamic routes!

References

https://dokku.com/docs/deployment/application-deployment/ https://www.bridgetownrb.com/docs/deployment https://edge.bridgetownrb.com/docs/routes

Webmentions

These are webmentions via the IndieWeb and webmention.io. Mention this post from your site: