Serverless websites: how we build, deploy, and host QueryTree without webservers

D4 Software
2 min readFeb 10, 2017

--

We recently re-launched our data reporting and visualization tool QueryTree with several new features and a shiny new website.

We’ve been hosting on a self-hosted Wordpress installation for some time, which makes it extremely easy to write and publish a post, but that ease comes with a lot of overhead.

The drawbacks include; a slower site as pages are generated by the application and database, security issues as the software needs to be patched and maintained, and scalability worries: a large amount of traffic might crash the Wordpress box.

The new site solves those problems, and with automated deployment is nearly as easy to edit as a Wordpress site.

The site is built, deployed and hosted — all without servers.

Of course, there are servers somewhere along the way — but thanks to virtualization, we needn’t be too concerned with provisioning or managing them.

Write

We write our posts in markdown, along with some ‘front matter’ that describes certain metadata (date & time, templates, etc).

In this way it’s pretty hard to make mistakes that break the site layout or styles, they are simply text files that are processed for formatting and rendered into templates.

Build & Deploy

We host the repo on Bitbucket and use the new Pipelines feature to build the site with Jekyll, then use s3_website gem to deploy to Amazon S3.

An s3_website.yml file sits in the root, referencing environment variables for secrets:

And we use a sed command in the bitbucket-pipelines.yml configuration file to swap out the relevant bucket name for production and development environments:

A Gemfile in the root tells Bundler which gems to install:

When a new commit to the ‘master’ or ‘develop’ branches is made, Bitbucket Pipelines goes ahead; starting a Docker image, installing gems, building the site with Jekyll and deploying using s3_website — automatically.

We can use the git workflow here — an author can make changes to ‘develop’, test, and open a pull request. Once reviewed, the pull request can be merged into master and deployed.

Host

Amazon S3 buckets can act as websites, so once deployed the S3 bucket serves the pages to visitors — but behaves like an object store to us, and a server to visitors.

The site can be edited by anyone on the team with a text editor, then committed and deployed in less than 60 seconds.

Faster, more scalable and more secure than a Wordpress installation — all without a single server configured.

Originally published at weared4.com.

--

--