47 lines
1.8 KiB
Bash
47 lines
1.8 KiB
Bash
#!/bin/bash
|
|
# https://www.autodidacts.io/host-a-ghost-blog-free-on-fly-io/
|
|
|
|
set -euo pipefail
|
|
set -x
|
|
|
|
#read -p "Enter App Name: " appname </dev/tty &&
|
|
appname="burd-infra-ghost"
|
|
|
|
# Inspect script first if you are leery of pipe-to-bash
|
|
command -v flyctl >/dev/null 2>&1 || { echo >&2 "Fly CLI required and not found. Installing..."; curl -L https://fly.io/install.sh | sh; }
|
|
|
|
# This will open a browser, where you can enter a username and password, and your credit card (which is required even for free tier, for fraud prevention).
|
|
flyctl auth signup
|
|
|
|
# Create a directory for the project and enter it, since the next command will output a file
|
|
#mkdir ghost-flyio && cd ghost-flyio
|
|
|
|
# Create an app -- using Ghost Dockerfile, Seattle region, and app name prompted for earlier -- but don't deploy it
|
|
flyctl launch --name $appname --image=ghost:5-alpine --region sea --no-deploy --org personal
|
|
|
|
# Provision a volume for Ghost's content and SQLite Database.
|
|
# Size can be up to 3GB and still fit in the free plan, but 1GB will be enough for starters.
|
|
flyctl volumes create ghost_data --region sea --size 3 -a $appname --auto-confirm
|
|
|
|
# Update the port to Ghost's default (2368)
|
|
sed -i 's/internal_port = 8080/internal_port = 2368/g' fly.toml
|
|
|
|
# Append info about where to find the persistent storage to fly.toml
|
|
cat >> fly.toml << BLOCK
|
|
[mounts]
|
|
source="ghost_data"
|
|
destination="/var/lib/ghost/content"
|
|
BLOCK
|
|
|
|
# Set Ghost url
|
|
flyctl secrets set url=https://$appname.fly.dev
|
|
|
|
# Since we're using SQLite, we need to set ghost to run in development mode
|
|
flyctl secrets set -a $appname NODE_ENV=development
|
|
|
|
# Put the SQLite DB somewhere where it doesn't get overwritten on redeploy...
|
|
fly secrets set database__connection__filename=/var/lib/ghost/content/data/ghost-dev.db
|
|
|
|
# Boom! We're airborne.
|
|
flyctl deploy
|
|
|