Skip to content

Commit b402fa7

Browse files
committed
feat: Allow deploying the app itself
1 parent 79bf9b8 commit b402fa7

4 files changed

Lines changed: 134 additions & 41 deletions

File tree

Justfile

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
gen-obelisk-ext:
2-
scripts/obelisk-generate-extensions.sh
3-
41
clean:
52
cargo clean
63

@@ -17,14 +14,5 @@ verify:
1714
serve:
1815
obelisk server run --config ${CONFIG:-obelisk-local.toml}
1916

20-
app-init:
21-
obelisk client execution submit -f .../workflow.app-init "$(./scripts/json-app-init-stargazers.sh)"
22-
23-
app-init-no-cleanup:
24-
SKIP_CLEANUP=true obelisk client execution submit -f .../workflow.app-init "$(./scripts/json-app-init-stargazers.sh)"
25-
26-
secrets:
27-
./scripts/secrets-send.sh ../stargazers/.envrc
28-
29-
secrets-y:
30-
SEND_ALL=true ./scripts/secrets-send.sh ../stargazers/.envrc
17+
app-init params:
18+
obelisk client execution submit -f .../workflow.app-init '{{params}}'

README.md

Lines changed: 79 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,49 @@
1-
# Obelisk deployment tool - fly.io
1+
# Obelisk deployment app for fly.io
22

33
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.
55

6-
## Usage
6+
## Setting up
77
Set up environment variables based on [.envrc-example](.envrc-example).
88

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+
920
Start Obelisk server
1021
```sh
1122
just build serve
1223
# or just `obelisk server run -c obelisk-oci.toml` without building the WASM components locally.
1324
```
1425

26+
## Starting the workflow
27+
28+
### Deploying the deployment app itself
29+
1530
Run the [`app-init`](workflow/deployer-workflow/wit/obelisk-flyio_workflow@1.0.0-beta/workflow.wit) function:
1631
```sh
17-
just app-init
32+
just app-init "$(./scripts/json-app-init-itself.sh)"
1833
```
1934

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 -
2136
either using `fly` command, fly.io's dashboard or using following [script](scripts/secrets-send.sh):
2237

23-
Point the script at stargazers' `.envrc` file.
2438
```sh
25-
./scripts/secrets-send.sh ../stargazers/.envrc
39+
./scripts/secrets-send.sh .envrc
2640
```
2741

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+
2947

3048
Sample output:
3149
```
@@ -59,28 +77,63 @@ After testing delete the app and its resources:
5977
fly apps delete $FLY_APP_NAME
6078
```
6179

62-
## Using Fly.io activities directly
80+
#### Inception - deploying the app one more time using the deployer on fly.io
6381

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+
```
6995

70-
Launch a VM:
96+
Now run `app-init` with a new fly app name:
7197
```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)"
7699
```
77100

78-
Execute a process:
101+
Push the secret to the outer webhook:
79102
```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
86104
```
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

scripts/json-app-init-itself.sh

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/usr/bin/env bash
2+
3+
# Prints JSON containing arguments to `app-init` function.
4+
5+
OBELISK_VERSION=${OBELISK_VERSION:-$(obelisk -v | cut -d ' ' -f 2)}
6+
SECRETS_DEADLINE_SECS=${SECRETS_DEADLINE_SECS:-120}
7+
HEALTH_CHECK_DEADLINE_SECS=${HEALTH_CHECK_DEADLINE_SECS:-120}
8+
SKIP_CLEANUP=${SKIP_CLEANUP:-false}
9+
MINIO=${MINIO:-true}
10+
11+
cat <<EOF
12+
[
13+
"$FLY_ORG_SLUG",
14+
"$FLY_APP_NAME",
15+
"$OBELISK_VERSION",
16+
{
17+
"activity-wasm-list":[
18+
{
19+
"name": "activity_fly_http",
20+
"location-oci": "docker.io/getobelisk/components_flyio_activity_fly_http:2025-10-05@sha256:fc19825d246fae8110f0473a505bf1da727086832bb0820653ec36e940822024",
21+
"env-vars":["FLY_API_TOKEN"],
22+
"lock-expiry-seconds": 15,
23+
"max-retries": 6
24+
},
25+
{
26+
"name": "http_activity",
27+
"location-oci": "docker.io/getobelisk/test_programs_http_get_activity:2025-09-28@sha256:8131d9cafbdf06dbaf7a3b4e629791c9cf3dc1553df9418b34f25ab900b72929",
28+
"lock-expiry-seconds": 5
29+
}
30+
],
31+
"workflow-list":[
32+
{
33+
"name": "obelisk_deployer_flyio",
34+
"location-oci": "docker.io/getobelisk/components_flyio_obelisk_deployer_flyio:2025-10-05-1@sha256:f2aacd7d90e2b8349d63a6c85f79904e99cfc754210250c24c356cb315089349"
35+
}
36+
],
37+
"webhook-endpoint-list":[
38+
{
39+
"name": "webhook_fly_secrets_updater",
40+
"location-oci": "docker.io/getobelisk/components_flyio_webhook_fly_secrets_updater:2025-10-05@sha256:3190ff8d059210d29b1a58f0fc509015360bb0e6bf34deba23b9c5a8c816c8cc",
41+
"routes": [{ "methods": ["POST"], "path": "/" }],
42+
"env-vars": ["FLY_API_TOKEN"]
43+
}
44+
]
45+
},
46+
$SECRETS_DEADLINE_SECS,
47+
$HEALTH_CHECK_DEADLINE_SECS,
48+
$SKIP_CLEANUP,
49+
$MINIO
50+
]
51+
EOF

scripts/secrets-send.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
set -euo pipefail
33

44
SEND_ALL=${SEND_ALL:-false}
5+
URL=${URL:-localhost:9090}
56

67
exec 3<&0 # save stdin as FD 3
78

@@ -21,7 +22,7 @@ while IFS= read -r line; do
2122

2223
echo "Found: $key"
2324
if [ "$SEND_ALL" = "true" ] || { read -u 3 -p "Send to server? (y/n) " confirm && [[ "$confirm" == "y" ]]; }; then
24-
curl --write-out "%{url_effective} %{http_code}\n" --fail localhost:9090/ \
25+
curl --write-out "%{url_effective} %{http_code}\n" --fail $URL \
2526
-H "Content-Type: application/json" \
2627
-d '{"app_name":"'"$FLY_APP_NAME"'","name":"'"$key"'","value":"'"$val"'"}'
2728
fi

0 commit comments

Comments
 (0)