From c2dc171b41da37964765ad4026e3b119b5f9e9c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Colin=20Schl=C3=BCter?= Date: Tue, 20 Dec 2022 16:48:19 +0100 Subject: [PATCH 1/4] Initial fly.io tutorial and config file. --- fly.io/README.md | 61 ++++++++++++++++++++++++++++++++++++++++++++++++ fly.io/fly.toml | 40 +++++++++++++++++++++++++++++++ 2 files changed, 101 insertions(+) create mode 100644 fly.io/README.md create mode 100644 fly.io/fly.toml diff --git a/fly.io/README.md b/fly.io/README.md new file mode 100644 index 0000000..a10ffd3 --- /dev/null +++ b/fly.io/README.md @@ -0,0 +1,61 @@ +# takahe on Fly.io + +Here's a short tutorial to get [Takahe](https://jointakahe.org) running on [Fly.io](https://fly.io). +It's intentionally a very basic setup both in terms of the Fly.io configuration as well as the Takahe installation, but should get things going. + +As far as I understand Fly.io pricing, the minimal version of this should even run within the free tier. + +## Fly.io app name + +Let's set up a name for the Fly.io app: + + APP_NAME= + +## Create a Postgres database + +First, let's create a [Fly Postgres](https://fly.io/docs/postgres/) instance. (Example for the smallest instance in Frankfurt, adjust according to your needs.) + + flyctl postgres create --name $APP_NAME-postgres --region fra --initial-cluster-size 1 --vm-size shared-cpu-1x --volume-size 1 + +## Create an application + +Next, we create the (empty) Fly.io app. + + flyctl apps create --name $APP_NAME + +## Attach database to application + +Now, we can attach the Postgres instance to the app and set the correct environment variable for the connection URL for Takahe. This also creates the database and the database user. + + flyctl postgres attach $APP_NAME-postgres -a $APP_NAME --database-name takahe --database-user takahe --variable-name TAKAHE_DATABASE_SERVER + +## Setup secrets + +Next, we need to generate a `SECRET_KEY` for Takahe and want to set up a few encrypted environment variables for our Takahe installation. (See [Media Configuration](https://docs.jointakahe.org/en/latest/installation/#media-configuration) and [Email Configuration](https://docs.jointakahe.org/en/latest/installation/#email-configuration).) + + flyctl secrets set -a $APP_NAME TAKAHE_SECRET_KEY= + flyctl secrets set -a $APP_NAME TAKAHE_MEDIA_BACKEND=s3://access-key:secret-key@endpoint-url/bucket-name + flyctl secrets set -a $APP_NAME TAKAHE_EMAIL_SERVER=sendgrid://apikey + +## Setup fly.toml + +The main configuration for our Fly.io app lives in [`fly.toml`](fly.toml). Feel free to adjust the example base config file in this repository, especially considering the [Environment Variables](https://docs.jointakahe.org/en/latest/installation/#environment-variables) for configuring Takahe further. + +## Deploy + +Now, from the directory of the `fly.toml` file, we can deploy our app. + + flyctl deploy + +Takahe should now be running at \. + +## Create admin user + +To log into Takahe, first create a admin user by logging into the Fly.io instance: + + flyctl ssh console + /takahe/manage.py createsuperuser + +## Login, Takahe setup + +Now, go to \ to login and complete the setup of the Takahe instance. diff --git a/fly.io/fly.toml b/fly.io/fly.toml new file mode 100644 index 0000000..c21696c --- /dev/null +++ b/fly.io/fly.toml @@ -0,0 +1,40 @@ +app = "" + +kill_signal = "SIGINT" +kill_timeout = 5 + +[build] + image = "jointakahe/takahe-dev:edge" + +[env] + # TAKAHE_ENVIRONMENT = "development" + TAKAHE_MAIN_DOMAIN = "" + TAKAHE_EMAIL_FROM = "" + TAKAHE_USE_PROXY_HEADERS = true + GUNICORN_CMD_ARGS = "--workers 2" + +[processes] + web = "bash /takahe/docker/run.sh" + stator = "/takahe/manage.py runstator" + +[deploy] + release_command = "/takahe/manage.py migrate" + +[[services]] + processes = ["web"] + internal_port = 8000 + protocol = "tcp" + + [services.concurrency] + type = "connections" + hard_limit = 25 + soft_limit = 20 + + [[services.ports]] + handlers = ["http"] + port = 80 + force_https = true + + [[services.ports]] + handlers = ["tls", "http"] + port = 443 From 637514451cbd329f8c4666f6046e2bf8312a0558 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Colin=20Schl=C3=BCter?= Date: Tue, 20 Dec 2022 17:16:31 +0100 Subject: [PATCH 2/4] Link fly.io info in main README --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 4ee48fa..6a9bd4c 100644 --- a/README.md +++ b/README.md @@ -10,3 +10,8 @@ Kubernetes ---------- See more in the [kubernetes/ directory](kubernetes/) + +Takahē on Fly.io +---------------- + +See the [tutorial](fly.io/README.md) and the example [config file](fly.io/fly.toml) in [fly.io/](fly.io/). From 2948f942f31dbec801444bcf8ffee4f19c5a626c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Colin=20Schl=C3=BCter?= Date: Tue, 20 Dec 2022 18:47:17 +0100 Subject: [PATCH 3/4] =?UTF-8?q?Fix=20Takah=C4=93=20spelling.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fly.io/README.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/fly.io/README.md b/fly.io/README.md index a10ffd3..3646c29 100644 --- a/fly.io/README.md +++ b/fly.io/README.md @@ -1,7 +1,7 @@ -# takahe on Fly.io +# takahē on Fly.io -Here's a short tutorial to get [Takahe](https://jointakahe.org) running on [Fly.io](https://fly.io). -It's intentionally a very basic setup both in terms of the Fly.io configuration as well as the Takahe installation, but should get things going. +Here's a short tutorial to get [Takahē](https://jointakahe.org) running on [Fly.io](https://fly.io). +It's intentionally a very basic setup both in terms of the Fly.io configuration as well as the Takahē installation, but should get things going. As far as I understand Fly.io pricing, the minimal version of this should even run within the free tier. @@ -25,13 +25,13 @@ Next, we create the (empty) Fly.io app. ## Attach database to application -Now, we can attach the Postgres instance to the app and set the correct environment variable for the connection URL for Takahe. This also creates the database and the database user. +Now, we can attach the Postgres instance to the app and set the correct environment variable for the connection URL for Takahē. This also creates the database and the database user. flyctl postgres attach $APP_NAME-postgres -a $APP_NAME --database-name takahe --database-user takahe --variable-name TAKAHE_DATABASE_SERVER ## Setup secrets -Next, we need to generate a `SECRET_KEY` for Takahe and want to set up a few encrypted environment variables for our Takahe installation. (See [Media Configuration](https://docs.jointakahe.org/en/latest/installation/#media-configuration) and [Email Configuration](https://docs.jointakahe.org/en/latest/installation/#email-configuration).) +Next, we need to generate a `SECRET_KEY` for Takahē and want to set up a few encrypted environment variables for our Takahē installation. (See [Media Configuration](https://docs.jointakahe.org/en/latest/installation/#media-configuration) and [Email Configuration](https://docs.jointakahe.org/en/latest/installation/#email-configuration).) flyctl secrets set -a $APP_NAME TAKAHE_SECRET_KEY= flyctl secrets set -a $APP_NAME TAKAHE_MEDIA_BACKEND=s3://access-key:secret-key@endpoint-url/bucket-name @@ -39,7 +39,7 @@ Next, we need to generate a `SECRET_KEY` for Takahe and want to set up a few enc ## Setup fly.toml -The main configuration for our Fly.io app lives in [`fly.toml`](fly.toml). Feel free to adjust the example base config file in this repository, especially considering the [Environment Variables](https://docs.jointakahe.org/en/latest/installation/#environment-variables) for configuring Takahe further. +The main configuration for our Fly.io app lives in [`fly.toml`](fly.toml). Feel free to adjust the example base config file in this repository, especially considering the [Environment Variables](https://docs.jointakahe.org/en/latest/installation/#environment-variables) for configuring Takahē further. ## Deploy @@ -47,15 +47,15 @@ Now, from the directory of the `fly.toml` file, we can deploy our app. flyctl deploy -Takahe should now be running at \. +Takahē should now be running at \. ## Create admin user -To log into Takahe, first create a admin user by logging into the Fly.io instance: +To log into Takahē, first create a admin user by logging into the Fly.io instance: flyctl ssh console /takahe/manage.py createsuperuser -## Login, Takahe setup +## Login, Takahē setup -Now, go to \ to login and complete the setup of the Takahe instance. +Now, go to \ to login and complete the setup of the Takahē instance. From 899322ca227864da246f78dae11ee874b18bcc2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Colin=20Schl=C3=BCter?= Date: Tue, 20 Dec 2022 18:57:44 +0100 Subject: [PATCH 4/4] Documentation tweaks --- fly.io/README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fly.io/README.md b/fly.io/README.md index 3646c29..a59e328 100644 --- a/fly.io/README.md +++ b/fly.io/README.md @@ -5,6 +5,8 @@ It's intentionally a very basic setup both in terms of the Fly.io configuration As far as I understand Fly.io pricing, the minimal version of this should even run within the free tier. +The following assumes a working Fly.io account, the installed Fly commandline tool, [`flyctl`](https://fly.io/docs/flyctl/), and a previous authentication via `flyctl auth`. + ## Fly.io app name Let's set up a name for the Fly.io app: @@ -32,6 +34,7 @@ Now, we can attach the Postgres instance to the app and set the correct environm ## Setup secrets Next, we need to generate a `SECRET_KEY` for Takahē and want to set up a few encrypted environment variables for our Takahē installation. (See [Media Configuration](https://docs.jointakahe.org/en/latest/installation/#media-configuration) and [Email Configuration](https://docs.jointakahe.org/en/latest/installation/#email-configuration).) +There's no need to set `TAKAHE_DATABASE_SERVER` as that is already done by Fly in the database attachment step above. flyctl secrets set -a $APP_NAME TAKAHE_SECRET_KEY= flyctl secrets set -a $APP_NAME TAKAHE_MEDIA_BACKEND=s3://access-key:secret-key@endpoint-url/bucket-name @@ -59,3 +62,5 @@ To log into Takahē, first create a admin user by logging into the Fly.io instan ## Login, Takahē setup Now, go to \ to login and complete the setup of the Takahē instance. + + flyctl open