Ghost Easy Deploy
Easily deploy Ghost to Fly.io
Find the code here (opens in a new tab).
Table of Contents
Dependencies
- NPM (opens in a new tab)
- Docker (opens in a new tab)
- Tilt (opens in a new tab)
- flyctl (opens in a new tab)
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:
- Navigate to the Ghost Easy Deploy repository (opens in a new tab).
- Click the "Use this template" button.
- Choose a name for your new repository and select whether it should be public or private.
- 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:
- Navigate to the GhostRemix repository (opens in a new tab).
- Click the "Fork" button in the top-right corner.
- Choose where to fork the repository (your personal account or an organization).
- Optionally, you can change the name of the forked repository.
- 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:
-
Add the original repository as an upstream remote:
git remote add upstream https://github.com/mikan-laboratory/ghost-easy-deploy.git
-
Fetch the latest changes from the upstream repository:
git fetch upstream
-
Merge the changes into your local main branch:
git checkout main git merge upstream/main
-
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.
-
Create Mailgun (opens in a new tab) account.
-
Navigate to Sending -> Domains. You should see a test domain that looks like
sandbox1234567890abcdef1234567890ab.mailgun.org
-
Add your email as an authorized recipient.
-
Scroll down and select API Keys. Create a new API key and copy the key.
-
Find the correct base URL here (opens in a new tab).
Basics
-
Create
.env
file in root directory, using.env.example
as a template. -
Use
tilt up
to install dependencies, generate a prisma client, and start services. -
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.
-
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
-
Build image and run container with
make all
. -
Clean image and container with
make clean-all
.
Deploy to Fly.io
Prerequisites
-
Create Fly.io (opens in a new tab) account.
-
Authenticate with
flyctl auth login
. -
Create app with
flyctl launch --no-deploy
.
GitHub Actions
-
Navigate to the newly created application in the Fly.io dashboard and get a deploy token.
-
Set secrets in GitHub repository settings.
-
Manually trigger by going to Actions tab and selecting
Fly Deploy
. ClickRun workflow
and enter the branch name to deploy.- You can update this action to trigger on push to
main
by changing theon
section of the workflow file topush: [main]
- You can update this action to trigger on push to
Command Line
- 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"
- Deploy
flyctl deploy
Custom Domains and SSL
More details here (opens in a new tab)
-
List your app ip addreses with
flyctl ips list
. -
Create SSL certificates.
flyctl certs create mysite.com
flyctl certs create www.mysite.com
- 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
.