|
| 1 | +# Deploy to Fly.io |
| 2 | + |
| 3 | +## What is Fly.io? |
| 4 | + |
| 5 | +[Fly.io](https://www.fly.io) is a platform for running applications in the cloud. Their tooling builds |
| 6 | +an image from a Dockerfile and runs it in a datacenter without you having to manage the server yourself. |
| 7 | +They have a free tier that provides more than enough power to run the SMO Online server code. |
| 8 | + |
| 9 | +Note: Fly *does* require a credit card on signup, but this is only to prevent bots from abusing their free tier. The setup listed in this guide is completely covered by their free tier, so you should not incur any charges. |
| 10 | + |
| 11 | +## Deployment Instructions |
| 12 | + |
| 13 | +1. First, follow Fly's [Installing flyctl](https://fly.io/docs/getting-started/installing-flyctl/) and |
| 14 | +[Log in](https://fly.io/docs/getting-started/log-in-to-fly/) instructions to get your computer set up |
| 15 | +to interact with Fly. |
| 16 | + * `flyctl` is Fly's tool for creating and deploying applications. |
| 17 | +2. Clone this repo using `git clone https://github.com/Sanae6/SmoOnlineServer.git` in your terminal. |
| 18 | +3. Run `cd SmoOnlineServer` to enter the repo directory. |
| 19 | +4. Run `flyctl launch`. |
| 20 | + * This is the command for creating a new application on Fly. It will ask for a name to use (must be globally unique) and a region |
| 21 | + to deploy to, you should pick a region close to you if it did not pick one automatically. |
| 22 | + * This command generates a `fly.toml` file in the repo, which is the configuration that Fly looks at when |
| 23 | + deciding how to run your application. |
| 24 | +5. By default this `fly.toml` file assumes that you are deploying a standard HTTP application, but this server operates over raw TCP. You will need to edit this file to look like the following: |
| 25 | + * ```toml |
| 26 | + app = "<your-app-name>" |
| 27 | + kill_signal = "SIGINT" |
| 28 | + kill_timeout = 5 |
| 29 | + processes = [] |
| 30 | + |
| 31 | + [env] |
| 32 | + |
| 33 | + [experimental] |
| 34 | + allowed_public_ports = [] |
| 35 | + auto_rollback = true |
| 36 | + |
| 37 | + [[services]] |
| 38 | + http_checks = [] |
| 39 | + internal_port = 1027 |
| 40 | + processes = ["app"] |
| 41 | + protocol = "tcp" |
| 42 | + script_checks = [] |
| 43 | + |
| 44 | + [services.concurrency] |
| 45 | + hard_limit = 25 |
| 46 | + soft_limit = 20 |
| 47 | + type = "connections" |
| 48 | + |
| 49 | + [[services.ports]] |
| 50 | + port = 1027 |
| 51 | + ``` |
| 52 | + * This configuration tells Fly that you are running the app over plain TCP, not HTTP, and to expose |
| 53 | + port 1027 instead of ports 80 and 443 like the default configuration will. |
| 54 | +6. Run `flyctl deploy`. |
| 55 | + * This will build the server code into a Docker image and push it to Fly, where it will then run in |
| 56 | + their datacenter in the region that you chose. This step might take a few minutes to complete. |
| 57 | +7. Now that your app is running, you can log in to Fly in your browser. Under your [Apps](https://fly.io/dashboard/personal) |
| 58 | +page you should see the application, and clicking on it will bring you to the Overview page. |
| 59 | + * The most important thing here is the "IP addresses" box near the middle of the page. When you start the |
| 60 | + modded game, this IP will be the one you want to enter (use the one with "v4" next to it). |
| 61 | + * Another useful page is the Monitoring page on the left, which will show you useful logs about when users |
| 62 | + connect, when moons are picked up, etc. |
| 63 | + |
| 64 | +And that's it! If you've made it this far, you should have the server up and running for free. By default Fly allocates |
| 65 | +one CPU core and 256MB of RAM for their free tier, which should be plenty. |
0 commit comments