Deployment

Deployment

The project is set up to be easily deployed to Fly.io, so this guide will explain this workflow.

Prerequisites

  1. Create an account at Fly.io (opens in a new tab).
  2. Download flyctl (opens in a new tab): Fly.io command line tool
  3. Authenticate with flyctl auth login
  4. In the root of the project run flyctl launch --no-deploy. This will create prompt you to create an application on Fly.io with the information provided in the fly.toml. You will be asked if you want to update these settings. Here you can choose a server location that is more relevant. Ensure that the port is set to 8080.

Tip

You can use the following commands to generate your GHOST_CONTENT_API_KEY and JWT_SECRET

# GHOST_CONTENT_API_KEY - follows format Ghost generates
node -e "console.log(require('crypto').randomBytes(13).toString('hex'))"
# JWT_SECRET
node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"

Github Actions

For deployment through GitHub Actions:

  1. Get Deploy API Token: Navigate to the newly created application in the Fly.io dashboard and get a deploy token.

  2. Set Secrets: Configure necessary secrets in your GitHub repository settings.

  3. Manually trigger by going to Actions tab and selecting Fly Deploy. Click Run workflow and enter the branch name to deploy.

    • You can update this action to trigger on push to main by changing the on section of the workflow file to push: [main]

Command Line

For command line deployment:

Set Secrets

Configure necessary environment secrets:

flyctl secrets set GHOST_CONTENT_API_KEY="my-api-key-value" \
   OWNER_EMAIL="my-email-value" \
   OWNER_PASSWORD="my-password-value" \
   MAILGUN_DOMAIN="somedomain" \
   MAILGUN_API_KEY="somekey" \
   MAILGUN_BASE_URL="mailgunbase" \
   JWT_SECRET="somejwtsecret" \
   SITE_TITLE="My Site" \
   SITE_DESCRIPTION="My website" \
   OWNER_NAME="Admin" \
   OWNER_SLUG="admin" \
   BLOG_URL="https://mysite.com" \
   COMMENT_SETTINGS="all" \
   ANTHROPIC_API_KEY="somekey"

Deploy

Deploy your application with environment variables:

flyctl deploy

Custom Domains and SSL

More details here (opens in a new tab)

  1. List your app ip addreses with flyctl ips list.

  2. Create SSL certificates.

flyctl certs create mysite.com
flyctl certs create www.mysite.com
  1. Use the ipv4 address to create an A record in your DNS provider, and the ipv6 address to create a AAAA record. Create a CNAME record for www.

RapidRead