Render

Render is a newer general purpose cloud that offers free static hosting and transparent prorated pricing for services, databases, and cron jobs. This hosting guide will show how you could use Render to edit content in a container, commit and push it with Git, and then host a static site.

Creating a Tome static site on Render

  1. Visit https://dashboard.render.com/services and create a new web service.
  2. Select a Tome site's repository
  3. For "Environment", select "Static Site"
  4. For "Build Command", enter something like:
    php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" && php composer-setup.php && php composer.phar install && ./vendor/bin/drush tome:install -y && ./vendor/bin/drush tome:static -l https://your-site.onrender.com

    Where "your-site" is the name of your new Render service

  5. For "Publish directory", enter "html"

  6. Save the form

That should be it - now your repository will be checked out and your static site will be built. If you're not interested in editing content in Render you can stop reading now!

Creating an editing service on Render

Now we're going to create a service on Render that exists to be spun up, have Drupal content edited on it, then spun down so that you only pay for what you need. This is still new and experimental so make sure to read the notes at the bottom of the guide!

  1. Copy this example Dockerfile into the root of your repository
  2. Change the placeholders in the Dockerfile's "Set up Git" section to match your Git settings
  3. Commit and push the Dockerfile
  4. Install Tome Git on your Tome site (i.e. with "composer require drupal/tome_git && drush en tome_git")
  5. Generate an SSH key on your computer for this service, do not use a password
  6. Add the new SSH public key to your repository and give it write access. The documentation on Github is good if you use Github
  7. Visit https://dashboard.render.com/services and create a new web service
  8. Select a Tome site's repository
  9. For "Environment", select "Docker"
  10. Save the form
  11. When your service is ready, go into its settings
  12. Disable "Auto Deploy"
  13. Go to the service's "Environment" settings
  14. Add a "Secret File" with the filename "tome_id_rsa" that has the contents of your SSH private key
  15. Add a "Secret File" with the filename "tome_pass" that has a password for the administrative user of this site. Alternatively, you could use something like SSO here to login, or allow SSH to your service so that you could use "drush uli"
  16. Trigger a manual deploy for your service
  17. Visit the URL for your service and login
  18. Make a change to content, config, or files
  19. Visit "/admin/config/tome/git" and click "Sync changes"
  20. Ensure that your edits were properly synced - the Tome Git module is still in development and could have bugs
  21. Go back to the settings for your service and suspend it
  22. See that your static service for this site is already rebuilding. Yay!

This kind of functionality - being able to spin up containers on demand to make changes to content then completely spin them down - is really exciting and also really new for Drupal. Tome allows a kind of statelessness with Drupal that would otherwise not be possible.

However, there are some things to consider when using Render:

  • Your "editing" service's container is ephemeral, which means that any unpushed changes in the container will be lost when it's suspended. Tome Git is going to improve and make syncing easier, but if someone forgets to sync their changes and the container is suspended or restarted there's no getting that data back. Once Render gets a persistent filesystem offering you could checkout the repository there to prevent this, but then you wouldn't get all the advantages of prorating. I think this is less scary than it seems, but it's worth calling out.
  • As an add-on to the previous note, when you resume a suspended container, it loses any writes that previously occurred. So if you edit/push changes, suspend, and resume, you'll also need to trigger a manual build so that the latest commit is used when building the container.
  • Render's in-browser console does not allow writing to the container, so if Tome Git fails to push there's not a lot you can do to remedy that. A solution to this could be to allow SSH to your container so you can manually run Git commands if needed. Tome Git is also going to add options for handling merge conflicts in the future which should help too.

If you end up using Render please blog about it! Thanks for making it through this relatively complex guide.