Files
mrcharles 10e2b7c7ed feat: add FX Cloudron package (DevOps-Tools) [#640]
FX 0.9.48 ("poor man's function as a service") as the 13th package:
pre-compiled goreleaser release binary with sha256 pin on
cloudron/base:4.0.0. fx is a CLI with no user concept, so the package
is a workstation: pinned binary + persistent workspace
(functions/ssh/kube) driven from the Cloudron web terminal, with an
auth-proxied landing page as the only HTTP surface (httpAuth proxy).
Deploys target remote Docker hosts over key-based SSH or Kubernetes
via FX_KUBECONF. Build green; runtime smoke (landing page, workspace
seeding, fx -v) green. Docs gardened to 13 packages.

Ticket: https://projects.knownelement.com/issues/640
2026-09-01 19:39:53 -05:00

41 lines
1.6 KiB
Bash
Executable File

#!/bin/bash
set -euo pipefail
# fx is a CLI, not a daemon: it has nothing to serve. The long-running
# process of this package is therefore the auth-proxied landing page on
# the Cloudron HTTP port (health check + usage guide). The fx binary and
# the persistent workspace below are driven interactively from the
# Cloudron web terminal (App -> terminal, or `cloudron exec`).
#
# Workspace layout seeded on first run:
# /app/data/functions/ function sources (two starter functions)
# /app/data/ssh/ SSH keys for remote Docker targets
# /app/data/kube/ kubeconfig for Kubernetes targets
mkdir -p /app/data/functions /app/data/ssh /app/data/kube
# Starter functions, exactly the upstream example shapes (Koa-style ctx
# for JavaScript, plain callable for Python).
if [[ ! -f /app/data/functions/hello.js ]]; then
cat > /app/data/functions/hello.js <<'EOF'
module.exports = (ctx) => {
ctx.body = 'hello world'
}
EOF
fi
if [[ ! -f /app/data/functions/hello.py ]]; then
cat > /app/data/functions/hello.py <<'EOF'
def fx(request):
return "hello world"
EOF
fi
echo "fx $(/usr/local/bin/fx -v) ready - open the app's web terminal to use it."
echo "Workspace: /app/data/functions (sources), /app/data/ssh (keys), /app/data/kube (kubeconfig)"
echo "Deploy example: fx up --host <user>@<host> --ssh_key /app/data/ssh/id_rsa --name hello /app/data/functions/hello.js"
# Landing page (health check + auth-proxied usage guide) is the only
# long-running process - fx itself runs on demand from the terminal.
exec python3 -m http.server "${CLOUDRON_HTTP_PORT:-8000}" --directory /app/code/status