Installation on Fly.io?

Re this article

They say to merge this config into the default config.
Special config:

[env]  
  url = "https://your-project-name.fly.dev"  
  database__client = "sqlite3"  
  database__connection__filename = "content/data/ghost.db"  
  database__useNullAsDefault = "true"  
  database__debug = "false"
  
[mounts]
  source="data"
  destination="/var/lib/ghost/content"

[[services]]  
  internal_port = 2368

Default config on my installation:

app = "my-ghost"
primary_region = "lax"

[build]
  image = "ghost:5.17.2"

[http_service]
  internal_port = 8080
  force_https = true
  auto_stop_machines = true
  auto_start_machines = true
  min_machines_running = 0
  processes = ["app"]

I’m confused, because it looks like the section names have changed since the article was written.

How to merge the above configs?

You probably want something like, I have not tested it. I don’t know what ENV variables ghost requires.

Most likely it was built on Nomad or even just older versions of flyctl. Now it’s fly machines, which is the gen v2 architecture.

The below shows my-ghost which would become https://my-ghost.fly.dev. Looks like env.url will need this path for Ghost.

[http_service] is just a shortcut for web apps, [[services]] are still a thing, but requires more fields, and can be used for port 80/443 apps, but below is the “shortcut” version.

I modified the ENV to better align with convention, it could be I did it wrong.

This also assumes you setup a volume, in the same region (lax) as your app. The volume should be called data given the source= statement in [mounts]

fly.toml

app = "my-ghost"
primary_region = "lax"

[build]
  image = "ghost:5.17.2"

[env]  
  URL = "https://my-ghost.fly.dev"  
  DATABASE_CLIENT= "sqlite3"  
  DATABASE_CONNECTION_FILENAME = "content/data/ghost.db"  
  DATABASE_USENULLASDEFAULT = "true"  
  DATABASE_DEBUG = "false"

[http_service]
  internal_port = 2378
  force_https = true
  auto_stop_machines = true
  auto_start_machines = true
  min_machines_running = 0
  processes = ["app"]

[mounts]
  source="data"
  destination="/var/lib/ghost/content"

I would get this running first. But if you want to take this further, you can have 3 apps running at the smallest size on fly.io for free.

High availability would be to do this.

  1. Get your environment working.
  2. Setup LiteFS (link below) with Consul Lease
  3. (optional) LiteFS Cloud which gives 5 minute snapshot backups to your ghost.db and allows you to restore, and autobacks up offsite location. Starts at $5 dollars a month with some capacity (10GB?), and grows at $0.50 a GB after.
  4. Use “clone” feature to clone your machine in LAX (or whatever region you make your primary). This will make a new volume for the new machine as well.
  5. Use “clone” feature to clone your machine into a NEW region, like EWR (New Jersey). This will make a new volumne in that new region for the new machine as well.
  6. (optional) If you wait for VMs to spin down (see the Monitoring section in dashboard for them to be off). Make a request, see that the closest region that is healthy will spin up. If that time is too long, go ahead and set min_machines_running = 1 in fly.toml which will give you 1 minimum machine running at all times. A request can still start apps in other regions, but this gives you most requests a faster response. Depending on VM size, it can be covered (all three) in free tier, if you are using the lowest VM size. Not sure what Ghost will require.

This will give you a few things.

General Benefits

  1. You have high availability within the same region, and DR across multiple regions.
  2. The volumes have snapshot, but at a lower cadence, for DR.
  3. You have machines in another region for lower latency to users.
  4. The DB will replicate across all instances, keeping them in sync.
  5. Only your primary LiteFS node can write, but the Consul Lease, and Fly proxy will ensure write requests (POST|PUT|DELETE|PATCH) go to the primary node automatically.

If you Setup LiteFS Cloud

  1. You get point in time backups at 5 minute increments.
  2. Almost instant rollback of DB and recovery
  3. Easy ability to download the DB for local testing, or upload and replace DB
  4. Backed up off of Fly.io infra (S3 I think).
1 Like

I applied your suggested config file. Then i got this:

> flyctl deploy
==> Verifying app config
Validating C:\Users\Johny\my-blog\fly.toml
Platform: machines
✓ Configuration is valid
--> Verified app config
==> Building image
Searching for image 'ghost:5.17.2' remotely...
image found: img_nr0lpjn5jqgv5q98

Watch your deployment at https://fly.io/apps/my-ghost/monitoring

Provisioning ips for my-ghost
  Dedicated ipv6: 2a09:8280:1::f:7d4f
  Shared ipv4: 66.241.124.194
  Add a dedicated ipv4 with: fly ips allocate-v4

Creating 1GB volume 'data' for process group 'app'. Use 'fly vol extend' to increase its size
Error: input:4: createRelease We need your payment information to continue! Add a credit card or buy credit: https://fly.io/dashboard/john-weiss/billing

Is credit card required for the free site? Or is there no longer a free option?

If i navigate to
https://my-ghost.fly.dev/

i get

This site can’t be reached

if i browse to
https://fly.io/apps/my-ghost/monitoring

i see “pending” and

$ fly logs -a my-ghost
Waiting for logs...

I am not 100% sure what the issue is, I don’t work for fly. I believe if you look for other billing questions, you can find a billing email you can reach out too.

But that output does show and validate that the config is valid.

Good luck. I would recommend adding a card. You can see the billing upfront and how it’s billed.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.