|
1 |
| -# Deploy Coder on Fly.io |
| 1 | +--- |
| 2 | +--- |
2 | 3 |
|
3 |
| -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 and creating workspaces as Fly.io (firecracker) machines. |
| 4 | +# Deploy Coder on Railway.app |
4 | 5 |
|
5 |
| -## Prerequisites |
| 6 | +## Quickstart |
6 | 7 |
|
7 |
| -- A Fly.io [account](https://fly.io/signup). |
8 |
| -- [Fly CLI](https://fly.io/docs/getting-started/installing-flyctl/) installed on your machine. |
| 8 | +### 1. Fill the environment variables |
9 | 9 |
|
10 |
| -## Deploy Coder |
| 10 | +The current version of the template allows you to set an optional environment variable `CODER_WILDCARD_ACCESS_URL` which will allow you to forward ports from your workspace to a custom wildcard subdomain of the URL you provide. This is useful if you want to access a service running in your workspace from a browser. For example, if you set `CODER_WILDCARD_ACCESS_URL` to `*.coder.example.com`, you can access a service running on port 8080 in your workspace by visiting `8080--<username>--<workspace-name>.coder.example.com`. |
11 | 11 |
|
12 |
| -1. Log in to Fly.io with the CLI: |
| 12 | +### 2. Attach a custom domain |
13 | 13 |
|
14 |
| -```bash |
15 |
| -flyctl auth login |
16 |
| -``` |
| 14 | +Your Coder deployment will always be accessible at `https://<app-name>.up.railway.app`. If you want to use a custom domain, you can do so by going to Dashboard > Coder (Service) > Settings > Domains and adding your domain and optionally a wildcard subdomain if you specified `CODER_WILDCARD_ACCESS_URL` in the previous step. |
17 | 15 |
|
18 |
| -2. Create a new fly postgres database: |
| 16 | +### 3. Create your first user |
19 | 17 |
|
20 |
| -```bash |
21 |
| -flyctl postgres create --name <postgres-app-name> |
22 |
| -``` |
| 18 | +Create your first user by going to `https://<app-name>.up.railway.app` or your custom domain. |
23 | 19 |
|
24 |
| -3. Create a new fly app: |
| 20 | + |
25 | 21 |
|
26 |
| -```bash |
27 |
| -flyctl apps create --name <coder-app-name> |
28 |
| -``` |
| 22 | +### 3. Create your first template |
29 | 23 |
|
30 |
| -4. Connect to the database with the coder fly app: |
| 24 | +[**Templates**](https://coder.com/docs/v2/latest/templates): Templates are written in Terraform and describe the infrastructure for workspaces. Coder provides a set of starter templates to help you get started. |
31 | 25 |
|
32 |
| -```bash |
33 |
| -flyctl postgres attach --app <coder-app-name> <postgres-app-name> |
34 |
| -``` |
| 26 | +Choose a template to set up your first workspace. You can also [create your own templates](https://coder.com/docs/v2/latest/templates) to define your custom infrastructure with your preferred cloud provider. |
| 27 | + |
35 | 28 |
|
36 |
| -**Important** Copy the connection string that is displayed in the terminal. You'll need it in the next step. |
| 29 | +### 4. Create your first workspace |
37 | 30 |
|
38 |
| -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. |
| 31 | +[**Workspaces**](https://coder.com/docs/v2/latest/workspaces): Workspaces contain the IDEs, dependencies, and configuration information needed for software development. You can create workspaces from templates. Here wea are showing the workspaces created from the Fly.io starter template in action. |
| 32 | + |
39 | 33 |
|
40 |
| -``` |
41 |
| -flyctl secrets set CODER_PG_CONNECTION_URL=<connection-string> --app <coder-app-name> |
42 |
| -``` |
| 34 | +## Documentation |
43 | 35 |
|
44 |
| -6. Edit the `fly.toml` file and update as per the example below: |
| 36 | +Browse our [**docs**](https://coder.com/docs/v2) or visit a specific section below: |
45 | 37 |
|
46 |
| -```toml |
47 |
| -app = "<app-name>" # Replace <app-name> with the name of your app |
48 |
| -kill_signal = "SIGINT" |
49 |
| -kill_timeout = 5 |
50 |
| -primary_region = "ams" # See a list of regions here: https://fly.io/docs/reference/regions/ |
| 38 | +[**Templates**](https://coder.com/docs/v2/latest/templates) | [**Workspaces**](https://coder.com/docs/v2/latest/workspaces) | [**IDEs**](https://coder.com/docs/v2/latest/ides) | [**Administration**](https://coder.com/docs/v2/latest/admin) | [**Enterprise**](https://coder.com/docs/v2/latest/enterprise) |
51 | 39 |
|
52 |
| -[experimental] |
53 |
| - auto_rollback = true |
54 |
| - private_network = true # Allows Coder to connect to the database |
| 40 | +## Community and Support |
55 | 41 |
|
56 |
| -[build] |
57 |
| - image = "ghcr.io/coder/coder:latest" |
| 42 | +Feel free to [open an issue](https://github.com/coder/coder/issues/new) if you have questions, run into bugs, or have a feature request. |
58 | 43 |
|
59 |
| -[env] |
60 |
| - CODER_ACCESS_URL = "https://<coder-app-name>.fly.dev" # Replace <app-name> with the name of your app |
61 |
| - CODER_HTTP_ADDRESS = "0.0.0.0:3000" |
62 |
| - #CODER_VERBOSE = "true" # Uncomment this if you want to see more logs |
63 |
| - CODER_TELEMETRY_INSTALL_SOURCE = "fly.io" |
| 44 | +[Join our Discord](https://discord.gg/coder) to provide feedback on in-progress features, and chat with the community using Coder! [](https://discord.gg/coder) |
64 | 45 |
|
65 |
| -[[services]] |
66 |
| - protocol = "tcp" |
67 |
| - internal_port = 3000 |
68 |
| - processes = ["app"] |
| 46 | +## Related |
69 | 47 |
|
70 |
| - [[services.ports]] |
71 |
| - port = 80 |
72 |
| - handlers = ["http"] |
73 |
| - force_https = true |
| 48 | +We are always working on new integrations. Feel free to open an issue to request an integration. Contributions are welcome in any official or community repositories. |
74 | 49 |
|
75 |
| - [[services.ports]] |
76 |
| - port = 443 |
77 |
| - handlers = ["tls", "http"] |
78 |
| - [services.concurrency] |
79 |
| - type = "connections" |
80 |
| - hard_limit = 25 |
| 50 | +### Official |
81 | 51 |
|
82 |
| -``` |
| 52 | +- [**VS Code Extension**](https://marketplace.visualstudio.com/items?itemName=coder.coder-remote): Open any Coder workspace in VS Code with a single click |
| 53 | +- [**JetBrains Gateway Extension**](https://plugins.jetbrains.com/plugin/19620-coder): Open any Coder workspace in JetBrains Gateway with a single click |
83 | 54 |
|
84 |
| -7. Deploy the app: |
| 55 | +### Community |
85 | 56 |
|
86 |
| -Run the following command to deploy the app from the directory where the `fly.toml` file is located: |
87 |
| - |
88 |
| -```bash |
89 |
| -flyctl deploy --app <coder-app-name> |
90 |
| -``` |
91 |
| - |
92 |
| -8. Scale the Coder app to 1GB of memory: |
93 |
| - |
94 |
| -```bash |
95 |
| -flyctl scale memory 1024 --app <coder-app-name> |
96 |
| -``` |
97 |
| - |
98 |
| -8. Congratulations! You've deployed Coder on Fly.io!. Go to the URL of your app and create your first user! |
99 |
| - |
100 |
| -> 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/). |
101 |
| ->  |
102 |
| -
|
103 |
| -## Create your first template |
104 |
| - |
105 |
| -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. |
106 |
| - |
107 |
| -1. Install Coder locally by following the instructions [here](https://coder.com/docs/v2/latest/install) or if you are on linux/macOS, you can run the following command: |
108 |
| - |
109 |
| -```bash |
110 |
| -curl -fsSL https://coder.com/get-coder.sh | bash |
111 |
| -``` |
112 |
| - |
113 |
| -2. Login to Coder: |
114 |
| - |
115 |
| -```bash |
116 |
| -coder login <coder-url> |
117 |
| -``` |
118 |
| - |
119 |
| -3. Create a new template by running the following command and following the prompts: |
120 |
| - |
121 |
| -```bash |
122 |
| -coder templates init |
123 |
| -``` |
124 |
| - |
125 |
| -4. Choose the `fly-docker-image` template and cd into the `fly-docker-image` directory. |
126 |
| - |
127 |
| -5. Create the new template by running the following command from the `fly-docker-image` directory: |
128 |
| - |
129 |
| -```bash |
130 |
| -coder templates push fly-docker-image --variable fly_api_token=$(flyctl auth token) |
131 |
| -``` |
132 |
| - |
133 |
| - |
134 |
| - |
135 |
| -> 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` |
136 |
| -> |
137 |
| -> ```bash |
138 |
| -> flyctl secrets set FLY_API_TOKEN=$(flyctl auth token) |
139 |
| -> ``` |
140 |
| -
|
141 |
| -6. Go to the Coder UI and create a new workspace using the `fly-docker-image` template. |
142 |
| -
|
143 |
| - |
144 |
| - |
145 |
| -
|
146 |
| -7. 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. |
147 |
| -
|
148 |
| - |
149 |
| -
|
150 |
| -## Update Coder |
151 |
| -
|
152 |
| -To update the Coder version, run `flyctl deploy --aap <coder-app-name>` again and it will pull the latest version of Coder. |
153 |
| -
|
154 |
| -## Next Steps |
155 |
| -
|
156 |
| -> To modify or write your first coder template, check out the [template docs](https://coder.com/docs/v2/latest/templates). |
| 57 | +- [**Coder GitHub Action**](https://github.com/marketplace/actions/update-coder-template): A GitHub Action that updates Coder templates |
| 58 | +- [**Various Templates**](https://github.com/coder/coder/examples/templates/community-templates.md): Hetzner Cloud, Docker in Docker, and other templates the community has built. |
0 commit comments