From 70deb7e702208c95a7499effecf01ffdd8faee92 Mon Sep 17 00:00:00 2001 From: Lee Salminen Date: Fri, 19 Aug 2022 16:29:32 -0600 Subject: [PATCH 1/6] add docs for hosting lnbits on fly.io --- docs/guide/installation.md | 73 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/docs/guide/installation.md b/docs/guide/installation.md index 6de893adb..cc44fcdec 100644 --- a/docs/guide/installation.md +++ b/docs/guide/installation.md @@ -95,6 +95,79 @@ mkdir data docker run --detach --publish 5000:5000 --name lnbits-legend --volume ${PWD}/.env:/app/.env --volume ${PWD}/data/:/app/data lnbits-legend ``` +## Option 5: Fly.io + +Fly.io is a docker container hosting platform that has a generous free tier. You can host LNBits for free on Fly.io for personal use. + +First, sign up for an account at (Fly.io)[https://fly.io] (no credit card required). + +Then, install the Fly.io CLI onto your device (here)[https://fly.io/docs/getting-started/installing-flyctl/] + +Once installed, run these commands. + +``` +git clone https://github.com/lnbits/lnbits-legend.git +cd lnbits-legend +fly auth login +[complete login process] +``` + +Now, create a new file `fly.toml` and paste in the following. Be sure to replace `${PUT_YOUR_LNBITS_ENV_VARS_HERE}` with all relevant environment variables in `.env` or `.env.example`. + +Note: Don't enter secret environment variables here. Fly.io offers secrets (via the `fly secrets` command) that are exposed as environment variables in your runtime. So, for example, if using the LND_REST funding source, you can run `fly secrets set LND_REST_MACAROON=`. + +``` +app = "lnbits" +kill_signal = "SIGINT" +kill_timeout = 30 + +[mounts] +source="lnbits_data" +destination="/data" + +[env] + HOST="127.0.0.1" + PORT=5000 + LNBITS_FORCE_HTTPS=true + + ${PUT_YOUR_LNBITS_ENV_VARS_HERE} + +[experimental] + allowed_public_ports = [] + auto_rollback = true + +[[services]] + internal_port = 5000 + protocol = "tcp" + + [services.concurrency] + hard_limit = 25 + soft_limit = 20 + type = "connections" + + [[services.ports]] + force_https = true + handlers = ["http"] + port = 80 + + [[services.ports]] + handlers = ["tls", "http"] + port = 443 + + [[services.http_checks]] + grace_period = "60s" +``` + +Next, create a volume to store the sqlite database for LNBits. + +``` +fly volumes create lnbits_data --size 1 +``` + +You're ready to deploy! Run `fly launch` and follow the steps to finish deployment. You'll select a `region` (up to you, choose the same as you did for the storage volume previously created), `postgres` (choose no), `deploy` (choose yes). + +You can use `fly logs` to view the application logs, or `fly ssh console` to get a ssh shell in the running container. + ### Troubleshooting Problems installing? These commands have helped us install LNbits. From 7d56878f55343a3f4dea76f0a9ccc5d5dac11a81 Mon Sep 17 00:00:00 2001 From: Lee Salminen Date: Fri, 19 Aug 2022 16:33:17 -0600 Subject: [PATCH 2/6] Update installation.md --- docs/guide/installation.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/guide/installation.md b/docs/guide/installation.md index cc44fcdec..e355e6081 100644 --- a/docs/guide/installation.md +++ b/docs/guide/installation.md @@ -99,9 +99,9 @@ docker run --detach --publish 5000:5000 --name lnbits-legend --volume ${PWD}/.en Fly.io is a docker container hosting platform that has a generous free tier. You can host LNBits for free on Fly.io for personal use. -First, sign up for an account at (Fly.io)[https://fly.io] (no credit card required). +First, sign up for an account at [Fly.io](https://fly.io) (no credit card required). -Then, install the Fly.io CLI onto your device (here)[https://fly.io/docs/getting-started/installing-flyctl/] +Then, install the Fly.io CLI onto your device [here](https://fly.io/docs/getting-started/installing-flyctl/). Once installed, run these commands. From d9ddd746e052c88be3efe3ec43ac6f112793dd49 Mon Sep 17 00:00:00 2001 From: Lee Salminen Date: Sun, 21 Aug 2022 11:25:39 -0600 Subject: [PATCH 3/6] Update installation.md --- docs/guide/installation.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/guide/installation.md b/docs/guide/installation.md index e355e6081..ab29bec11 100644 --- a/docs/guide/installation.md +++ b/docs/guide/installation.md @@ -101,7 +101,7 @@ Fly.io is a docker container hosting platform that has a generous free tier. You First, sign up for an account at [Fly.io](https://fly.io) (no credit card required). -Then, install the Fly.io CLI onto your device [here](https://fly.io/docs/getting-started/installing-flyctl/). +Then, install the Fly.io CLI onto your device [here](https://fly.io/docs/getting-started/installing-flyctl/). After install is complete, the command will output a command you should copy/paste/run to get `fly` into your `$PATH`. If you don't you'll have to call Fly from `~/.fly/bin/flyctl`. Once installed, run these commands. From 5c2045927a5e194132acf118dda2aa955b7df6b0 Mon Sep 17 00:00:00 2001 From: Lee Salminen Date: Sun, 21 Aug 2022 11:39:34 -0600 Subject: [PATCH 4/6] Update installation.md --- docs/guide/installation.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/guide/installation.md b/docs/guide/installation.md index ab29bec11..1ffe82b9d 100644 --- a/docs/guide/installation.md +++ b/docs/guide/installation.md @@ -129,6 +129,7 @@ destination="/data" HOST="127.0.0.1" PORT=5000 LNBITS_FORCE_HTTPS=true + LNBITS_DATA_FOLDER="/data" ${PUT_YOUR_LNBITS_ENV_VARS_HERE} From 218ccbc3a71a79c79f95bd9ff1970703f0888146 Mon Sep 17 00:00:00 2001 From: Lee Salminen Date: Sun, 21 Aug 2022 11:46:11 -0600 Subject: [PATCH 5/6] Update installation.md --- docs/guide/installation.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/guide/installation.md b/docs/guide/installation.md index 1ffe82b9d..bc0843008 100644 --- a/docs/guide/installation.md +++ b/docs/guide/installation.md @@ -114,6 +114,8 @@ fly auth login Now, create a new file `fly.toml` and paste in the following. Be sure to replace `${PUT_YOUR_LNBITS_ENV_VARS_HERE}` with all relevant environment variables in `.env` or `.env.example`. +Environment variable strings should be quoted here, so if in `.env` you have `LNBITS_ENDPOINT=https://legend.lnbits.com` in `fly.toml` you should have `LNBITS_ENDPOINT="https://legend.lnbits.com"`. + Note: Don't enter secret environment variables here. Fly.io offers secrets (via the `fly secrets` command) that are exposed as environment variables in your runtime. So, for example, if using the LND_REST funding source, you can run `fly secrets set LND_REST_MACAROON=`. ``` @@ -122,8 +124,8 @@ kill_signal = "SIGINT" kill_timeout = 30 [mounts] -source="lnbits_data" -destination="/data" + source="lnbits_data" + destination="/data" [env] HOST="127.0.0.1" From aff7e110897e95ac08ecaaa0a4714655ed89fd9b Mon Sep 17 00:00:00 2001 From: Lee Salminen Date: Sun, 21 Aug 2022 12:57:28 -0600 Subject: [PATCH 6/6] Update installation.md --- docs/guide/installation.md | 58 ++++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 30 deletions(-) diff --git a/docs/guide/installation.md b/docs/guide/installation.md index bc0843008..abe3cc59c 100644 --- a/docs/guide/installation.md +++ b/docs/guide/installation.md @@ -101,32 +101,49 @@ Fly.io is a docker container hosting platform that has a generous free tier. You First, sign up for an account at [Fly.io](https://fly.io) (no credit card required). -Then, install the Fly.io CLI onto your device [here](https://fly.io/docs/getting-started/installing-flyctl/). After install is complete, the command will output a command you should copy/paste/run to get `fly` into your `$PATH`. If you don't you'll have to call Fly from `~/.fly/bin/flyctl`. +Then, install the Fly.io CLI onto your device [here](https://fly.io/docs/getting-started/installing-flyctl/). -Once installed, run these commands. +After install is complete, the command will output a command you should copy/paste/run to get `fly` into your `$PATH`. Something like: + +``` +flyctl was installed successfully to /home/ubuntu/.fly/bin/flyctl +Manually add the directory to your $HOME/.bash_profile (or similar) + export FLYCTL_INSTALL="/home/ubuntu/.fly" + export PATH="$FLYCTL_INSTALL/bin:$PATH" +``` + +You can either run those commands, then `source ~/.bash_profile` or, if you don't, you'll have to call Fly from `~/.fly/bin/flyctl`. + +Once installed, run the following commands. ``` git clone https://github.com/lnbits/lnbits-legend.git cd lnbits-legend fly auth login [complete login process] +fly launch ``` -Now, create a new file `fly.toml` and paste in the following. Be sure to replace `${PUT_YOUR_LNBITS_ENV_VARS_HERE}` with all relevant environment variables in `.env` or `.env.example`. +You'll be prompted to enter an app name, region, postgres (choose no), deploy now (choose no). -Environment variable strings should be quoted here, so if in `.env` you have `LNBITS_ENDPOINT=https://legend.lnbits.com` in `fly.toml` you should have `LNBITS_ENDPOINT="https://legend.lnbits.com"`. +You'll now find a file in the directory called `fly.toml`. Open that file and modify/add the following settings. + +Note: Be sure to replace `${PUT_YOUR_LNBITS_ENV_VARS_HERE}` with all relevant environment variables in `.env` or `.env.example`. Environment variable strings should be quoted here, so if in `.env` you have `LNBITS_ENDPOINT=https://legend.lnbits.com` in `fly.toml` you should have `LNBITS_ENDPOINT="https://legend.lnbits.com"`. Note: Don't enter secret environment variables here. Fly.io offers secrets (via the `fly secrets` command) that are exposed as environment variables in your runtime. So, for example, if using the LND_REST funding source, you can run `fly secrets set LND_REST_MACAROON=`. ``` -app = "lnbits" -kill_signal = "SIGINT" +... kill_timeout = 30 +... +... [mounts] source="lnbits_data" destination="/data" +... +... [env] HOST="127.0.0.1" PORT=5000 @@ -134,40 +151,21 @@ kill_timeout = 30 LNBITS_DATA_FOLDER="/data" ${PUT_YOUR_LNBITS_ENV_VARS_HERE} +... -[experimental] - allowed_public_ports = [] - auto_rollback = true - +... [[services]] internal_port = 5000 - protocol = "tcp" - - [services.concurrency] - hard_limit = 25 - soft_limit = 20 - type = "connections" - - [[services.ports]] - force_https = true - handlers = ["http"] - port = 80 - - [[services.ports]] - handlers = ["tls", "http"] - port = 443 - - [[services.http_checks]] - grace_period = "60s" +... ``` -Next, create a volume to store the sqlite database for LNBits. +Next, create a volume to store the sqlite database for LNBits. Be sure to choose the same region for the volume that you chose earlier. ``` fly volumes create lnbits_data --size 1 ``` -You're ready to deploy! Run `fly launch` and follow the steps to finish deployment. You'll select a `region` (up to you, choose the same as you did for the storage volume previously created), `postgres` (choose no), `deploy` (choose yes). +You're ready to deploy! Run `fly deploy` and follow the steps to finish deployment. You'll select a `region` (up to you, choose the same as you did for the storage volume previously created), `postgres` (choose no), `deploy` (choose yes). You can use `fly logs` to view the application logs, or `fly ssh console` to get a ssh shell in the running container.