Deploy Coder on Fly.io
Fly.io is a platform for deploying applications to the edge. It’s a great fit for Coder because it’s easy to deploy and scale, and it’s easy to manage. In this guide, we’ll walk through deploying Coder on Fly.io.
Prerequisites
Deploy Coder
- Log in to Fly.io with the CLI:
flyctl auth login
- Create a new fly postgres database:
flyctl postgres create DATABASE-NAME
- Create a new fly app:
flyctl apps create APP-NAME
- Connect to the database with the coder fly app:
flyctl postgres connect DATABASE-NAME --app APP-NAME
This will print out a connection string. Copy the connection string and save it to be used in the next step.
- Edit the
fly.toml
file and update as per the example below:
app = "APP-NAME"
kill_signal = "SIGINT"
kill_timeout = 5
primary_region = "ams" # See a list of regions here: https://fly.io/docs/reference/regions/
[experimental]
auto_rollback = true
private_network = true # This is needed for Coder to connect to the database
[build]
image = "ghcr.io/coder/coder:latest"
[env]
CODER_ACCESS_URL = "https://APP-NAME.fly.dev" # make sure to replace APP-NAME with your app name
CODER_HTTP_ADDRESS = "0.0.0.0:3000"
CODER_PG_CONNECTION_URL = "ADD YOUR POSTGRES CONNECTION STRING HERE"
#CODER_VERBOSE = "true" # Uncomment this if you want to see more logs
CODER_TELEMETRY_INSTALL_SOURCE = "fly.io"
[[services]]
protocol = "tcp"
internal_port = 3000
processes = ["app"]
[[services.ports]]
port = 80
handlers = ["http"]
force_https = true
[[services.ports]]
port = 443
handlers = ["tls", "http"]
[services.concurrency]
type = "connections"
hard_limit = 25
- Deploy the app:
Run the following command to deploy the app from the directory where the fly.toml
file is located:
flyctl deploy
- Scale the to use more memory:
flyctl scale memory 1024 --app APP-NAME
- Go to the URL of your app and start using Coder!
If you want to use a custom domain, you can do so by following the instructions here.
Update Coder
To update the Coder version, run flyctl deploy --aap APP-NAME
again and it will pull the latest version of Coder.
Congratulations! You’ve deployed Coder on Fly.io!
Next Steps
To write your first coder template, check out the template docs.
We have an official fly.io template that you can use as a starting point.