Installation guide for Cradle CMS on Fly.io
Create fly account
- Create account and login at https://fly.io.
- Setup two factor authentication under Account->Settings->2FA.
- Logout and login again using 2FA.
Install flyctl
Using homebrew
brew install flyctl
Or using installer script
curl -L https://fly.io/install.sh | sh
Login with the fly auth
cmd
fly auth login
Read more about flyctl here: https://fly.io/docs/hands-on/install-flyctl/
Create fly app
First, create a local directory for your fly application.
mkdir cradle-cms
cd cradle-cms
Then create the app.
fly app create cradle-cms
List the available fly regions and note the region id of the datacenter you want to deploy to (primary_region).
fly platform regions
Edit or create a fly.toml
configuration file with a text-editor.
You can use this simple template for the app and change the configuration options (site, frontend and admin) specified in the [env]
section.
app = 'cradle-cms'
primary_region = ''
[env]
TLS = false
PORT = 8080
ADMIN_USER = 'admin'
ADMIN_EMAIL = 'your@email.invalid'
ADMIN_PASS = 'your secret password'
[http_service]
internal_port = 8080
force_https = true
auto_stop_machines = true
auto_start_machines = true
min_machines_running = 0
processes = ["app"]
[[vm]]
memory = '512mb'
cpu_kind = 'shared'
cpus = 1
[mounts]
source="storage"
destination="/storage"
processes = ["app"]
initial_size = "3gb"
Set primary_region
to the fly datacenter you prefer i.e the one being closest to you.
NOTE: since fly terminates
https
we must specifyTLS = false
and configure the web server to listen onPORT = 8080
.
Deployment
Cradle-cms is deployed as a docker image so you need podman
or docker
installed on your computer.
With the docker
or podman
cli installed, login to our registry using your cradle-cms licence key
and your account password
.
docker login registry.cradlecms.com
NOTE: You might need to specify port
:5000
on the registry url.
Then fetch the latest
cradle-cms release.
docker pull --platform linux/amd64 registry.cradlecms.com/cradle-cms:latest
NOTE: As fly.io only supports
linux/amd64
containers you should specify--platform linux/amd64
when downloading the image.
Then authenticate against fly.io docker registry
fly auth docker
Tag the local cradle-cms
release which we will push to the fly application registry.
docker tag registry.cradlecms.com/cradle-cms:latest registry.fly.io/cradle-cms:latest
Then upload the image to the fly registry.
docker push registry.fly.io/cradle-cms:latest
Launch
Now you can start cradle-cms with the deployed image.
fly deploy --image=registry.fly.io/cradle-cms:latest
Then open a browser using the url that fly has assigned to your application.
Login to the admin with the username and password you specified in the configuration file.
NOTE: For better security you can configure the system using fly secrets instead.
Also there's a lot more configuration options available, but we've tried to keep things simple to begin with.
Logs
The system log is written to standard out in json
format so you can use tools such as jq
to filter log messages. To see the log output you need to use docker logs
as shown in the example.
docker logs -f <container id>
You can also subscribe to a log event stream using the nats
client.
nats subscribe "logs.>"
[#6] Received on "logs.frontend" {"time":"2024-09-28T08:54:26.176Z","level":"INFO","service":"frontend","msg":"render","host":"localhost:5000","site":"17427f63-e498-4654-bcaa-a6f24afabeef","path":"/","type":"index","handle":"","lang":"en"}
Use the log stream if you want to store the log on another server or monitor it in real time.