From 1794fe9dd4151d274fc6dfdcd1f0dcfb4235d00c Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Mon, 16 May 2022 14:16:26 +0200 Subject: [PATCH] fly io docs [skip ci] --- doc/fly_io/Dockerfile | 5 +++++ doc/fly_io/README.md | 18 ++++++++++++++++++ doc/fly_io/example.clj | 21 +++++++++++++++++++++ doc/fly_io/fly.toml | 41 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 85 insertions(+) create mode 100644 doc/fly_io/Dockerfile create mode 100644 doc/fly_io/README.md create mode 100644 doc/fly_io/example.clj create mode 100644 doc/fly_io/fly.toml diff --git a/doc/fly_io/Dockerfile b/doc/fly_io/Dockerfile new file mode 100644 index 00000000..8c9149ca --- /dev/null +++ b/doc/fly_io/Dockerfile @@ -0,0 +1,5 @@ +FROM babashka/babashka:0.8.2 + +COPY example.clj / + +ENTRYPOINT bb /example.clj diff --git a/doc/fly_io/README.md b/doc/fly_io/README.md new file mode 100644 index 00000000..66a22856 --- /dev/null +++ b/doc/fly_io/README.md @@ -0,0 +1,18 @@ +# Deploying a babashka app to fly.io + +[Fly.io](https://fly.io/) is a service that can run full stack apps with minimal +configuration. If you like the ease of Heroku, you might like fly.io and perhaps +even better! This document shows how to get a minimal babashka application up +and running on `fly.io`. + +In `example.clj` we start an http-kit web server which spits out some HTML. You +can run this locally by invoking `bb example.clj` from the command line. + +To get this site running on `fly.io`, you need to +[install](https://fly.io/docs/getting-started/installing-flyctl/) and [log +in](https://fly.io/docs/getting-started/log-in-to-fly/). + +Then run `flyctl launch` to create a new application. After making changes, you +can re-deploy the site with `flyctl deploy`. + +That's it! diff --git a/doc/fly_io/example.clj b/doc/fly_io/example.clj new file mode 100644 index 00000000..2250fb95 --- /dev/null +++ b/doc/fly_io/example.clj @@ -0,0 +1,21 @@ +(ns example + (:require [hiccup2.core :refer [html]] + [org.httpkit.server :refer [run-server]])) + +(def port (or (some-> (System/getenv "PORT") + parse-long) + 8092)) + +(run-server + (fn [_] + {:body + (str (html + [:html + [:body + [:h1 "Hello world!"] + [:p (str "This site is running with babashka v" + (System/getProperty "babashka.version"))]]]))}) + {:port port}) + +(println "Site running on port" port) +@(promise) diff --git a/doc/fly_io/fly.toml b/doc/fly_io/fly.toml new file mode 100644 index 00000000..6ebbdeeb --- /dev/null +++ b/doc/fly_io/fly.toml @@ -0,0 +1,41 @@ +# fly.toml file generated for shy-sound-2847 on 2022-05-16T14:12:38+02:00 + +app = "shy-sound-2847" + +kill_signal = "SIGINT" +kill_timeout = 5 +processes = [] + +[env] + PORT = "8092" + +[experimental] + allowed_public_ports = [] + auto_rollback = true + +[[services]] + http_checks = [] + internal_port = 8092 + processes = ["app"] + protocol = "tcp" + script_checks = [] + + [services.concurrency] + hard_limit = 25 + soft_limit = 20 + type = "connections" + + [[services.ports]] + force_https = true + handlers = ["http"] + port = 80 + + [[services.ports]] + handlers = ["tls", "http"] + port = 443 + + [[services.tcp_checks]] + grace_period = "1s" + interval = "15s" + restart_limit = 0 + timeout = "2s"