---
title: "Remote developer environments on Fly.io - Blog - Coder"
description: "Read our latest blog posts on various topics including engineering, product, and company updates."
image: "/api/dynamic-og?title=Remote+developer+environments+on+Fly.io&randomBackground=true&styles=%7B%22height%22%3A162%2C%22width%22%3A302%2C%22padding%22%3A16%2C%22titleSize%22%3A24%2C%22logo%22%3A%7B%22width%22%3A80%2C%22height%22%3A12.15%7D%7D"
canonical: "https://coder.com/blog/remote-developer-environments-on-fly-io"
---

Mar 22 20233 min read

# Remote developer environments on Fly.io

![M Atif Ali](https://www.datocms-assets.com/19109/1755768811-atif.jpeg?fit=crop&fm=jpg&h=3840&w=3840)

M Atif Ali

Share this article

Fly.io is a platform for deploying applications to the edge. It's a great fit for Coder because it's easy to deploy, scale, and manage. In this guide, we'll walk through deploying Coder on Fly.io and creating remote workspaces as Fly.io (firecracker) machines.

## Prerequisites

- A Fly.io [account](https://fly.io/signup).
- [flyctl](https://fly.io/docs/getting-started/installing-flyctl/) installed on your local machine.

## Deploy Coder

1. Log in to Fly.io with the CLI: ``` flyctl auth login ```
2. Create a new fly postgres database: ``` flyctl postgres create --name <postgres-app-name> ```
3. Create a new fly app: ``` flyctl apps create --name <coder-app-name> ```
4. Connect to the database with the coder fly app: ``` flyctl postgres attach --app <coder-app-name> <postgres-app-name> ``` **Important** Copy the connection string that is displayed in the terminal. You'll need it in the next step.
5. Create a new secret with the name `CODER_PG_CONNECTION_URL` and the value as the connection string you copied in the previous step. ``` flyctl secrets set CODER_PG_CONNECTION_URL=<connection-string> --app <coder-app-name> ```
6. Edit the `fly.toml` file and update as per the example below: ``` app = "<coder-app-name>" # Replace <coder-app-name> with the name of your app 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 # Allows Coder to connect to the database [build] image = "ghcr.io/coder/coder:latest" [env] CODER_ACCESS_URL = "https://<coder-app-name>.fly.dev" # Replace <app-name> with the name of your app CODER_HTTP_ADDRESS = "0.0.0.0:3000" #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 ```
7. Deploy the app: Run the following command to deploy the app from the directory where the `fly.toml` file is located: ``` flyctl deploy --app <coder-app-name> ```
8. Scale the Coder app to 1GB of memory: ``` flyctl scale memory 1024 --app <coder-app-name> ```
9. Congratulations! You've deployed Coder on Fly.io!. Go to the URL of your app and create your first user!

![](https://www.datocms-assets.com/19109/1679487242-welcome.png?fit=clip&fm=webp&w=3840&q=90)

> If you want to use a custom domain, you can do so by following the instructions [here](https://fly.io/docs/app-guides/custom-domains-with-fly/).

## Create your first template

> **Warning**: The following steps may not work as expected becasue Fly.io has deprecated and ended support of their terraform provider. See [https://github.com/fly-apps/terraform-provider-fly](https://github.com/fly-apps/terraform-provider-fly) for more details.

A template is a set of instructions that Coder uses to create a workspace. In this section, we'll create a template that uses a Fly.io machine as the workspace.

1. Install Coder locally by following the instructions [here](https://coder.com/docs/install) or if you are on linux/macOS, you can run the following command: ``` curl -fsSL https://coder.com/install.sh | bash ```
2. Login to Coder: ``` coder login <coder-url> ```
3. Create a new template by running the following command and following the prompts: ``` coder templates init ```
4. Choose the `fly-docker-image` template and cd into the `fly-docker-image` directory. `bash cd fly-docker-image && coder templates create `
5. Create the new template by running the following command from the `fly-docker-image` directory: ``` coder templates push fly-docker-image --variable fly_api_token=$(flyctl auth token) ```

![](https://www.datocms-assets.com/19109/1679487819-template-1.png?fit=clip&fm=webp&w=3840&q=90)

If Coder is deployed as a fly.io app, instead of setting variable `fly_api_token` you can also set a fly.io secret with the name `FLY_API_TOKEN`

```

```

Go to the Coder UI and create a new workspace using the `fly-docker-image` template.

![](https://www.datocms-assets.com/19109/1679487870-workspace-1.png?fit=clip&fm=webp&w=3840&q=90)

![](https://www.datocms-assets.com/19109/1679487885-workspace-2.png?fit=clip&fm=webp&w=3840&q=90)

This will deploy code-server on a Fly.io machine using the docker image. You can access the code-server instance by clicking on the `Code Server` button.

![A Coder workspace via Fly.io](https://www.datocms-assets.com/19109/1679487699-workspace-3.png?fit=clip&fm=webp&w=3840&q=90)

A Coder workspace via Fly.io

## Update Coder

To update the Coder version, run `flyctl deploy --aap <coder-app-name>` again and it will pull the latest version of Coder.

## Next Steps

To modify or write your first coder template, check out the [template docs](https://coder.com/docs/v2/latest/templates).

Have questions? [Contact us](https://coder.com/contact) or [join us on Discord](https://discord.gg/coder)

### Subscribe to our newsletter

Want to stay up to date on all things Coder? Subscribe to our monthly newsletter for the latest articles, workshops, events, and announcements.
