|
1 | | -# Obelisk deployment tool - fly.io |
| 1 | +# Obelisk deployment app for fly.io |
2 | 2 |
|
3 | 3 | An [Obelisk](https://obeli.sk) [workflow](workflow/deployer-workflow/impl-flyio/src/lib.rs) |
4 | | -that deploys the [Stargazers Demo app](https://github.com/obeli-sk/demo-stargazers) on fly.io. |
| 4 | +that deploys an Obelisk app on fly.io. |
5 | 5 |
|
6 | | -## Usage |
| 6 | +## Setting up |
7 | 7 | Set up environment variables based on [.envrc-example](.envrc-example). |
8 | 8 |
|
| 9 | +Set up dependencies based on [dev-deps.txt](dev-deps.txt). |
| 10 | + |
| 11 | +If `direnv` is available: |
| 12 | +```sh |
| 13 | +cp .envrc-example .envrc |
| 14 | +$EDITOR .envrc # change FLY_APP_NAME and FLY_API_TOKEN |
| 15 | +direnv allow |
| 16 | +``` |
| 17 | + |
| 18 | +## Starting the server |
| 19 | + |
9 | 20 | Start Obelisk server |
10 | 21 | ```sh |
11 | 22 | just build serve |
12 | 23 | # or just `obelisk server run -c obelisk-oci.toml` without building the WASM components locally. |
13 | 24 | ``` |
14 | 25 |
|
| 26 | +## Starting the workflow |
| 27 | + |
| 28 | +### Deploying the deployment app itself |
| 29 | + |
15 | 30 | Run the [`app-init`](workflow/deployer-workflow/wit/obelisk-flyio_workflow@1.0.0-beta/workflow.wit) function: |
16 | 31 | ```sh |
17 | | -just app-init |
| 32 | +just app-init "$(./scripts/json-app-init-itself.sh)" |
18 | 33 | ``` |
19 | 34 |
|
20 | | -While the workflow is running, push the [stargazers secrets](https://github.com/obeli-sk/demo-stargazers/blob/main/.envrc-example) to the fly.io app - |
| 35 | +While the workflow is running, push the secrets of your `.envrc` to the fly.io app - |
21 | 36 | either using `fly` command, fly.io's dashboard or using following [script](scripts/secrets-send.sh): |
22 | 37 |
|
23 | | -Point the script at stargazers' `.envrc` file. |
24 | 38 | ```sh |
25 | | -./scripts/secrets-send.sh ../stargazers/.envrc |
| 39 | +./scripts/secrets-send.sh .envrc |
26 | 40 | ``` |
27 | 41 |
|
28 | | -When all required secrets are present, the `app-init` workflow will continue with creating the final VM and health checks. |
| 42 | +The following secrets are required by the app: |
| 43 | +* FLY_API_TOKEN |
| 44 | + |
| 45 | +When all required secrets are present, the workflow will continue with creating the final VM and health checks. |
| 46 | + |
29 | 47 |
|
30 | 48 | Sample output: |
31 | 49 | ``` |
@@ -59,28 +77,63 @@ After testing delete the app and its resources: |
59 | 77 | fly apps delete $FLY_APP_NAME |
60 | 78 | ``` |
61 | 79 |
|
62 | | -## Using Fly.io activities directly |
| 80 | +#### Inception - deploying the app one more time using the deployer on fly.io |
63 | 81 |
|
64 | | -Check out the [components-flyio](https://github.com/obeli-sk/components-flyio) repo on how to interact with Fly.io, including: |
65 | | -* Apps |
66 | | -* Volumes |
67 | | -* VMs |
68 | | -* Secrets |
| 82 | +Pick a name for the inner app, we will use `inception`. |
| 83 | + |
| 84 | +Kill the local Obelisk server. |
| 85 | + |
| 86 | +Proxy the gRPC port 5005 of the `obelisk` VM: |
| 87 | +```sh |
| 88 | +flyctl proxy 5005 $(fly machine list | grep obelisk | awk '{print $6}') |
| 89 | +``` |
| 90 | + |
| 91 | +Verify the port tunneling works: |
| 92 | +```sh |
| 93 | +obelisk client component list |
| 94 | +``` |
69 | 95 |
|
70 | | -Launch a VM: |
| 96 | +Now run `app-init` with a new fly app name: |
71 | 97 | ```sh |
72 | | -export VOLUME_ID=.. |
73 | | -MACHINE_ID=$(obelisk client execution submit -f --json obelisk-flyio:activity-fly-http/machines@1.0.0-beta.create -- \ |
74 | | -\"$FLY_APP_NAME\" \"$FLY_MACHINE_NAME\" "$(./scripts/json-machine-create.sh)" \"$FLY_REGION\" \ |
75 | | -| jq -r '.[-1].ok') |
| 98 | +just app-init "$(FLY_APP_NAME=inception ./scripts/json-app-init-itself.sh)" |
76 | 99 | ``` |
77 | 100 |
|
78 | | -Execute a process: |
| 101 | +Push the secret to the outer webhook: |
79 | 102 | ```sh |
80 | | -obelisk client execution submit -f \ |
81 | | -obelisk-flyio:activity-fly-http/machines@1.0.0-beta.exec \ |
82 | | --- \ |
83 | | -\"$FLY_APP_NAME\" \ |
84 | | -\"$MACHINE_ID\" \ |
85 | | -'["obelisk", "server", "verify", "-c", "/volume/obelisk.toml"]' |
| 103 | +URL="https://${FLY_APP_NAME}.fly.dev" FLY_APP_NAME=inception ./scripts/secrets-send.sh .envrc |
86 | 104 | ``` |
| 105 | + |
| 106 | +To show the web console, proxy the port 8080 as well. |
| 107 | + |
| 108 | +Don't forget to delete the inner app afterwards: |
| 109 | +```sh |
| 110 | +fly apps delete inception |
| 111 | +``` |
| 112 | + |
| 113 | +### Stargazers |
| 114 | +Similar to the process above, but deploying the [Stargazers Demo app](https://github.com/obeli-sk/demo-stargazers) requires setting up, see the project's readme for details. |
| 115 | + |
| 116 | +Run the [`app-init`](workflow/deployer-workflow/wit/obelisk-flyio_workflow@1.0.0-beta/workflow.wit) function: |
| 117 | +```sh |
| 118 | +just app-init "$(./scripts/json-app-init-stargazers.sh)" |
| 119 | +``` |
| 120 | + |
| 121 | +Push the secrets using stargazers' `.envrc` file. |
| 122 | +```sh |
| 123 | +./scripts/secrets-send.sh ../stargazers/.envrc |
| 124 | +``` |
| 125 | + |
| 126 | +The follwing secrets are required by the app: |
| 127 | +* OPENAI_API_KEY |
| 128 | +* GITHUB_TOKEN |
| 129 | +* TURSO_TOKEN |
| 130 | +* TURSO_LOCATION |
| 131 | +* GITHUB_WEBHOOK_SECRET |
| 132 | + |
| 133 | +# Using Fly.io activities directly |
| 134 | + |
| 135 | +Check out the [components-flyio](https://github.com/obeli-sk/components-flyio) repo on how to interact with Fly.io, including: |
| 136 | +* Apps |
| 137 | +* Volumes |
| 138 | +* VMs |
| 139 | +* Secrets |
0 commit comments