The static website behind rm3l.org, hosted with Netlify, built with Gatsby, and leveraging a headless Ghost Content Management System (CMS) running in a Kubernetes cluster
⚠️ Archived! See this repo for the latest version of this website.
Read more about this migration journey in this blog post.
- Backend
- Ghost provides the headless Content Management System (CMS). It runs in my own self-hosted Kubernetes cluster
- Frontend
- Gatsby pulls data from the Ghost blog GraphQL API, and builds this static site. Initial version has been created using the gatsby-starter-ghost starter, then customized to include additional pages such as a Portfolio React component
- End-to-end tests with Cypress and start-server-and-test
- Continuously tested (CI) via GitHub Actions
- Specifically, once a deployment is successful in Netlify, a webhook triggers a Kubeless function, which in turn requests a GitHub Workflow Run that tests the newly-deployed site
- Continuously deployed (CD) on Netlify, but I am considering migrating to Cloudflare Pages.
- Deploy previews of Pull Requests via Cloudflare Pages
- Dependabot & Snyk to keep dependencies secure and up-to-date
-
Clone the repo
git clone https://github.com/rm3l/rm3l.org my-jamstack-site && cd my-jamstack-site
-
Install and use the correct version of Node using NVM
nvm install
-
Install the Gatsby CLI
npm install -g gatsby-cli
-
Install YARN package manager
Follow the instructions here: https://legacy.yarnpkg.com/en/docs/install
-
Install the project dependencies
yarn
-
Set up environment variables and customize the project
Copy the .env.template
as a .env
file in the repo and customize it accordingly:
GHOST_API_URL=https://my.healdless.ghost.entrypoint
GHOST_CONTENT_API_KEY=my-ghost-blog-content-key
CYPRESS_PROJECT_ID=my-cypress-project-id
CYPRESS_RECORD_KEY=my-cypress-record-key
CONTACT_FORM_ENDPOINT=my-contact-form-endpoint
GHOST_API_URL
: the URL to the headless Ghost blogGHOST_CONTENT_API_KEY
: the Ghost Content API Key, which allows to pull data from a Ghost CMSCYPRESS_PROJECT_ID
: the Cypress project IdentifierCYPRESS_RECORD_KEY
: the Cypress project record key, to use in a Cypress online dashboardCONTACT_FORM_ENDPOINT
: the endpoint to call in the contact form
On build servers (CircleCI and Netlify), those are just defined as project-wide environment variables.
- Change the site configuration
Edit the src/utils/siteConfig.js file accordingly.
-
Start the development server
gatsby develop
Gatsby develop
uses the development
config in .ghost.json
.
-
Generate a full static production build
# Run a production build, locally gatsby build
-
Preview the site as it will appear once deployed
# Serve a production build, locally gatsby serve
Gatsby build
uses the production
config in .ghost.json
.
This repository contains few Cypress end-to-end tests that not only make sure the website renders as expected,
but also test accessibility (also known as a11y).
To do so, the test
commands spin up the Gatsby development server and run all the Cypress test specs against the former.
You can run the tests using the following command:
# Runs the tests right away, with no user interaction
yarn test
or :
# Interactive test launcher: opens up a Cypress browser for interactively running the tests
yarn test:open
This contains 3 config files specifically for deploying with Netlify. A netlify.toml
file for build settings, a /static/_headers
file with default security headers set for all routes, and /static/_redirects
to set Netlify custom domain redirects.
To deploy to your Netlify account, hit the button below.
You need however to leverage your own Ghost Content API Keys which allow Gatsby to communicate with your Ghost headless blog. For this, I currently set Netlify ENV variables for production builds instead.
Once deployed, I also set up a Ghost + Netlify Integration to use deploy hooks from Ghost to trigger Netlify rebuilds. That way, any time data changes (e.g., new post published) in the headless Ghost CMS, my website will rebuild on Netlify.
- Armel Soro
The MIT License (MIT)
Copyright (c) 2020-2021 Armel Soro
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.