Deployment
The project is set up to be easily deployed to Fly.io, so this guide will explain this workflow.
Prerequisites
- Create an account at Fly.io (opens in a new tab).
- Download flyctl (opens in a new tab): Fly.io command line tool
- Authenticate with
flyctl auth login
- 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 thefly.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 to8080
.
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:
-
Get Deploy API Token: Navigate to the newly created application in the Fly.io dashboard and get a deploy token.
-
Set Secrets: Configure necessary secrets in your 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
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" \
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" \
MEMBERS_SIGNUP_ACCESS="all" \
RAPID_READ="post" \
ANTHROPIC_API_KEY="somekey" \
IMAGE_OUTPUT_DIRECTORY="/var/www/ghost/content/images/"
Deploy
Deploy your application with environment variables:
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
.
Caching Strategies
GhostRemix employs a two-pronged caching approach to optimize performance:
-
Remix Application Caching:
- Utilizes an in-memory cache for dynamic content.
- Handles its own cache invalidation for up-to-date data.
-
Nginx Static Asset Handling:
- Serves static assets directly from the filesystem.
- Bypasses the Ghost server for serving images, leveraging Nginx's efficiency in handling static files.
This dual strategy ensures efficient handling of both dynamic content and static assets, significantly reducing strain on the Remix application server.