Vanilla Ghost

Ghost Easy Deploy

Easily deploy Ghost to Fly.io

Find the code here (opens in a new tab).

Table of Contents

Dependencies

Local Development

Get the code

You have two options to get started with Ghost Easy Deploy: using the template or forking the repository. Here's when to use each approach:

Using the Template

Use the template when:

  • You want to create a private repository (GitHub doesn't allow forking directly to a private repo).
  • You don't plan to contribute back to the original project.
  • You want a clean start without the original project's commit history.

To use the template:

  1. Navigate to the Ghost Easy Deploy repository (opens in a new tab).
  2. Click the "Use this template" button.
  3. Choose a name for your new repository and select whether it should be public or private.
  4. Click "Create repository from template".

Alternatively, you can use the GitHub CLI:

gh repo create your-new-repo --template mikan-laboratory/ghost-easy-deploy --private
cd your-new-repo
git push --set-upstream origin main

Forking the Repository

Fork the repository when:

  • You want to contribute back to the original project.
  • You want to keep up with updates to the original project.
  • You're okay with a public repository (you can make it private later, but it starts as public).

To fork the repository:

  1. Navigate to the GhostRemix repository (opens in a new tab).
  2. Click the "Fork" button in the top-right corner.
  3. Choose where to fork the repository (your personal account or an organization).
  4. Optionally, you can change the name of the forked repository.
  5. Click "Create fork".

After forking, clone your forked repository:

git clone https://github.com/your-username/ghost-easy-deploy.git
cd ghost-easy-deploy

To keep your fork up to date with the original repository:

  1. Add the original repository as an upstream remote:

    git remote add upstream https://github.com/mikan-laboratory/ghost-easy-deploy.git
  2. Fetch the latest changes from the upstream repository:

    git fetch upstream
  3. Merge the changes into your local main branch:

    git checkout main
    git merge upstream/main
  4. Push the updated main branch to your fork:

    git push origin main

Remember, if you make changes you want to contribute back to the original project, create a new branch for your changes and submit a pull request from that branch.

Mailgun

You don't need Mailgun to get started, but you'll need for email-based workflows like member sign up.

Don't worry about the $35 a month price tag, immediately after signing up for the trial, you can downgrade to the flex plan.

  1. Create Mailgun (opens in a new tab) account.

  2. Navigate to Sending -> Domains. You should see a test domain that looks like sandbox1234567890abcdef1234567890ab.mailgun.org

  3. Add your email as an authorized recipient.

  4. Scroll down and select API Keys. Create a new API key and copy the key.

  5. Find the correct base URL here (opens in a new tab).

Basics

  1. Create .env file in root directory, using .env.example as a template.

  2. Use tilt up to install dependencies, generate a prisma client, and start services.

  3. Seed database with the button in Ghost section of the Tilt UI.

    • The production script seeds an owner and basic settings. The development script includes posts and comments.
    • If you want to inspect the database, you can manually trigger a GUI from the Tilt UI.
  4. The Node engine is set to 18.19 in package.json to match the production runtime. This follows the Ghost team's advice. You can find more information here (opens in a new tab). Using a different version locally shouldn't be an issue, but you will see a warning when you run npm install. If you want to use this version in development, you can use a tool like nvm (opens in a new tab) to manage multiple Node versions.

Test Docker Build

  1. Build image and run container with make all.

  2. Clean image and container with make clean-all.

Deploy to Fly.io

Prerequisites

  1. Create Fly.io (opens in a new tab) account.

  2. Authenticate with flyctl auth login.

  3. Create app with flyctl launch --no-deploy.

GitHub Actions

  1. Navigate to the newly created application in the Fly.io dashboard and get a deploy token.

  2. Set secrets in 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

  1. Set 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"
  1. Deploy
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.