Skip to content

Commit

Permalink
Rework Fly.io without web terminal
Browse files Browse the repository at this point in the history
  • Loading branch information
psonnera committed Dec 14, 2023
1 parent 59358ee commit d574e9c
Show file tree
Hide file tree
Showing 25 changed files with 114 additions and 218 deletions.
1 change: 0 additions & 1 deletion .gitattribute

This file was deleted.

3 changes: 2 additions & 1 deletion docs/_static/fly.toml
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,15 @@ BOLUS_RENDER_OVER=1

# DO NOT MODIFY ANYTHING BELOW
# //////////////////////////////////////////////////////////////////////////////////////////////
PORT = "3000"

[experimental]
allowed_public_ports = []
auto_rollback = true

[[services]]
http_checks = []
internal_port = 1337
internal_port = 3000
processes = ["app"]
protocol = "tcp"
script_checks = []
Expand Down
41 changes: 0 additions & 41 deletions docs/_static/flyboot.sh

This file was deleted.

170 changes: 54 additions & 116 deletions docs/troubleshoot/fly.io.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,16 @@

</br>

If you've got IT knowledge you can install the [`flyctl`](https://fly.io/docs/hands-on/install-flyctl/) utility on your computer.

If it's too complex for you the web terminal is an easy alternative.

## Use a web terminal

```{warning}
The web terminal feature was removed from Fly.io.
Documentation will be updated to use a computer and flyctl.
You need a computer with flyctl.
```

a) In a new browser tab, [sign-in](https://fly.io/app/sign-in) with your fly.io account,then open a web [terminal](https://fly.io/terminal).
If you just closed the terminal, you might need to wait some time (20 minutes) before you can open a new session (the message below appears).

<img src="/vendors/fly.io/img/FlyIO07.png" width="600px" />

</br>

b) Click on the image with code (`Launch Web CLI`).

<img src="/vendors/fly.io/img/FlyIO06.png" width="500px" />

</br>

c) Wait until the web terminal is ready.
Follow [these instructions](https://fly.io/docs/hands-on/install-flyctl/) to install `flyctl` on your computer.

<img src="/vendors/fly.io/img/FlyIO08.png" width="600px" />
*Note for Windows: do not use Git Bash on your PC, prefer a PowerShell terminal.*

</br>

d) A command prompt will open.

<img src="/vendors/fly.io/img/FlyIO09.png" width="600px" />

</br>
</br></br>

## Cleanup

Expand Down Expand Up @@ -91,134 +66,97 @@ You don't have a local repository.

</br>

## Make your migrated app maintainable

If you migrated Nightscout from Heroku using Fly.io migration utility you need to fix your deployment to update it.

Open a [web terminal](#use-a-web-terminal).

a) Type (or copy and paste) the following command in the terminal:</br>

`curl https://nightscout.github.io/_static/flyboot.sh | bash`</br>

<img src="/vendors/fly.io/img/FlyIO01.png" width="600px" />

</br>

b) Navigate to the Nightscout code directory copied locally by typing:

`cd cgm-remote-monitor`

<img src="/vendors/fly.io/img/FlyIO02.png" width="600px" />

</br>

c) Deploy your site with Fly.io.
Type the following command:

`flyctl launch`

<img src="/vendors/fly.io/img/FlyIO13.png" width="600px" />

</br>
## Downscale your app

To the question `Would you like to copy its configuration to the new app?` answer `Y` (yes).
```{warning}
The web terminal feature was removed from Fly.io.
You need a computer with flyctl.
```

To the question: `App Name (leave blank to use an auto-generated name):` answer with **the name of your current Nightscout app**.
Follow [these instructions](https://fly.io/docs/hands-on/install-flyctl/) to install `flyctl` on your computer.

<img src="/vendors/fly.io/img/FlyIO14.png" width="600px" />
*Note for Windows: do not use Git Bash on your PC, prefer a PowerShell terminal.*

</br>

The app should already exist, confirm you want to launch into it.

<img src="/vendors/fly.io/img/FlyIO16.png" width="600px" />

</br>
March 31st 2023, apps deploy in V2 and V1 apps are automatically migrated too.
This causes some issues as V2 automatically deploys in a more than one machine, your Nightscout site might not work correctly.

d) In the terminal type:
Type the following command in the terminal (replace ***`app_name`*** with your own app name):

`flyctl deploy`
Authenticate in Fly.io:

You app will deploy. It will take time (about 10 minutes).
`flyctl auth login`

<img src="/vendors/fly.io/img/FlyIO17.png" width="600px" />
Downscale your app:

</br>
`flyctl scale --app `***`app_name`***` count 1`

Do not interrupt the process.
<img src="/vendors/fly.io/img/FlyT08.png" width="600px" />

</br>
Your app should now only be running on one machine. Check [here](https://fly.io/dashboard/personal/machines).

When deploy completes you should see your full Nightscout site name.
***Note:*** *the builder app is normal, it is stopped: don't worry about it.*

<img src="/vendors/fly.io/img/FlyIO18.png" width="600px" />
<img src="/vendors/fly.io/img/FlyT09.png" width="600px" />

</br>

e) Last but not least: make sure to downscale your app with the following command:

`flyctl scale count 1`

<img src="/vendors/fly.io/img/FlyIO19.png" width="600px" />

Enter `y` to confirm.

<img src="/vendors/fly.io/img/FlyIO20.png" width="600px" />
## Obtain a free shared IP

</br>
```{warning}
The web terminal feature was removed from Fly.io.
You need a computer with flyctl.
```

f) Exit the terminal typing `exit` or pressing `Ctrl D` (`⌘ D` with a Mac).
Follow [these instructions](https://fly.io/docs/hands-on/install-flyctl/) to install `flyctl` on your computer.

Keep in mind you'll need some time to reopen it if you need to (as explained in step 2 above).
Close the browser tab.
*Note for Windows: do not use Git Bash on your PC, prefer a PowerShell terminal.*

</br>

## Downscale your app

March 31st 2023, apps deploy in V2 and V1 apps are automatically migrated too.
This causes some issues as V2 automatically deploys in a more than one machine, your Nightscout site might not work correctly.

Type the following command in a [web terminal](#use-a-web-terminal) (replace ***`app_name`*** with your own app name):

`flyctl scale --app `***`app_name`***` count 1`

<img src="/vendors/fly.io/img/FlyT08.png" width="600px" />

Your app should now only be running on one machine. Check [here](https://fly.io/dashboard/personal/machines).
Apps migrated from Heroku will use a dedicated IP billed $1.90/month.

***Note:*** *the builder app is normal, it is stopped: don't worry about it.*
If you want to run your Nightscout site in Fly.io for free, you will need to release the IP and request a shared IP.

<img src="/vendors/fly.io/img/FlyT09.png" width="600px" />
Follow the instructions below. The IP `137.66.11.78` and the site name `example-ns` are examples, yours will be different. Use your own IP and site name.

</br>
Open a browser and authenticate:

## Obtain a free shared IP
`flyctl auth login`

Apps migrated from Heroku will use a dedicated IP billed $1.90/month.
List the apps to see the name of your Nightscout project:

If you want to run your Nightscout site in Fly.io for free, you will need to release the IP and request a shared IP.

Follow the instructions below. The IP 137.66.11.78 and the site name `example-ns` are examples, yours will be different. Use your own IP and site name.
`flyctl app list`

```
$ flyctl auth login # This will open a browser and ask me to authenticate
$ flyctl app list
NAME OWNER STATUS PLATFORM LATEST DEPLOY
NAME OWNER STATUS PLATFORM LATEST DEPLOY
example-ns personal deployed machines 2023-05-26T07:24:51Z
```

List the IPs used by your app (replace *`example-ns`* by your own):

`flyctl ips list -a example-ns`

$ flyctl ips list -a example-ns
```
VERSION IP TYPE REGION CREATED AT
v4 137.66.11.78 public global 2022-09-13T14:17:58Z
v6 3b09:8280:1::3:723c public global 2022-09-13T14:18:00Z
```

Release the dedicated IP you found above (example: 137.66.11.78):

`flyctl ips release 137.66.11.78 -a example-ns`

$ flyctl ips release 137.66.11.78 -a example-ns
```
Released 137.66.11.78 from example-ns
```

Assign a shared IP to your Nightscout site:

$ flyctl ips allocate-v4 --shared -a example-ns
`flyctl ips allocate-v4 --shared -a example-ns`

```
v4 <new-ip-assigned> shared global
```

Expand Down
Binary file removed docs/vendors/fly.io/img/FlyIO01.png
Binary file not shown.
Binary file removed docs/vendors/fly.io/img/FlyIO02.png
Binary file not shown.
Binary file modified docs/vendors/fly.io/img/FlyIO05.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/vendors/fly.io/img/FlyIO06.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/vendors/fly.io/img/FlyIO07.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/vendors/fly.io/img/FlyIO08.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/vendors/fly.io/img/FlyIO09.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/vendors/fly.io/img/FlyIO10.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/vendors/fly.io/img/FlyIO11.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/vendors/fly.io/img/FlyIO12.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/vendors/fly.io/img/FlyIO13.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed docs/vendors/fly.io/img/FlyIO13b.png
Binary file not shown.
Binary file modified docs/vendors/fly.io/img/FlyIO14.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/vendors/fly.io/img/FlyIO15.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed docs/vendors/fly.io/img/FlyIO16.png
Binary file not shown.
Binary file modified docs/vendors/fly.io/img/FlyIO17.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/vendors/fly.io/img/FlyIO18.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/vendors/fly.io/img/FlyIO21.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/vendors/fly.io/img/FlyIO22.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/vendors/fly.io/img/FlyIOA2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit d574e9c

Please sign in to comment.