Easily deploy Ghost to Fly.io
Use the template to create your own repository.
- Navigate to the repository, click
Use this template
, and follow the instructions.
- Get the GitHub CLI
# Step 1: Clone the template repository
git clone https://github.com/mikab-laboratory/ghost-easy-deploy.git new-project
cd new-project
# Step 2: Create a new repository on GitHub
gh repo create username/new-project --private --source=.
# Step 3: Push the cloned contents to the new repository
git push --set-upstream origin main
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 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.
-
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. 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 to manage multiple Node versions.
-
Build image and run container with
make all
. -
Clean image and container with
make clean-all
.
-
Create Fly.io account.
-
Authenticate with
flyctl auth login
. -
Create app with
flyctl launch --no-deploy
.
-
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
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
- 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" \
MAILGUN_USER="postmaster@somedomain \
MAILGUN_PASSWORD="password" \
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
More details here
-
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
.