From 4b2d667373d353063ca8e6212ba970f2b8602ae7 Mon Sep 17 00:00:00 2001 From: Rui Carmo Date: Sun, 7 Apr 2024 11:31:13 +0100 Subject: [PATCH] cleanup docs --- docs/CONTRIBUTING.md | 9 -- docs/FAQ.md | 12 +- docs/INSTALL.md | 42 ++++-- docs/README.md | 3 + docs/{ => old}/DESIGN.md | 0 docs/{ => old}/INSTALL-centos-9.md | 0 docs/{ => old}/INSTALL-other.md | 0 .../INSTALL-raspbian-9.4-stretch-10-buster.md | 0 docs/{ => old}/INSTALL-ubuntu-18.04-bionic.md | 0 docs/{ => old}/INSTALL-ubuntu-22.04-jammy.md | 0 docs/old/INSTALL.md | 134 ++++++++++++++++++ docs/{ => old}/PLUGINS.md | 0 12 files changed, 169 insertions(+), 31 deletions(-) delete mode 100644 docs/CONTRIBUTING.md create mode 100644 docs/README.md rename docs/{ => old}/DESIGN.md (100%) rename docs/{ => old}/INSTALL-centos-9.md (100%) rename docs/{ => old}/INSTALL-other.md (100%) rename docs/{ => old}/INSTALL-raspbian-9.4-stretch-10-buster.md (100%) rename docs/{ => old}/INSTALL-ubuntu-18.04-bionic.md (100%) rename docs/{ => old}/INSTALL-ubuntu-22.04-jammy.md (100%) create mode 100644 docs/old/INSTALL.md rename docs/{ => old}/PLUGINS.md (100%) diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md deleted file mode 100644 index 1bb3ada..0000000 --- a/docs/CONTRIBUTING.md +++ /dev/null @@ -1,9 +0,0 @@ -We welcome contributions! - -### Guidelines - - * Small and focused PRs. Please don't include changes that don't address the subject of your PR. - * Follow the style of importing functions directly e.g. `from os.path import abspath`. - * Check out the [core values of Piku](../README.md#core-values). - * PEP8. - diff --git a/docs/FAQ.md b/docs/FAQ.md index a547486..8197ff5 100644 --- a/docs/FAQ.md +++ b/docs/FAQ.md @@ -2,23 +2,21 @@ **Q:** Why `piku`? -**A:** Partly because it's supposed to run on a [Pi][pi], because it's Japanese onomatopeia for 'twitch' or 'jolt', and because I know the name will annoy some of my friends. +**A:** Partly because it's started out on the [Raspberry Pi][pi], because it's Japanese onomatopeia for 'twitch' or 'jolt', and because we knew the name would be cute and amusing. **Q:** Why Python/why not Go? -**A:** I actually thought about doing this in Go right off the bat, but [click][click] is so cool and I needed to have [uWSGI][uwsgi] running anyway, so I caved in. But I'm very likely to take something like [suture](https://github.com/thejerf/suture) and port this across, doing away with [uWSGI][uwsgi] altogether. +**A:** We actually thought about doing this in Go right off the bat, but [click][click] is so cool and we needed to have `uwsgi` running anyway, so we caved in. But possible future directions are likely to take something like [suture](https://github.com/thejerf/suture) and port this across (or just use [Caddy](http://caddyserver.com)), doing away with `uwsgi` altogether. -Go also (at the time) did not have a way to vendor dependencies that I was comfortable with, and that is also why Go support fell behind. Hopefully that will change soon. +Go also (at the time) did not have a way to vendor dependencies that we were comfortable with, and that is also why Go support fell behind. Hopefully that will change soon. **Q:** Does it run under Python 3? -**A:** Right now, it _only_ runs on Python 3, even though it can deploy apps written in both major versions. It began its development using 2.7 and using`click` for abstracting the simpler stuff, and I eventually switched over to 3.5 once it was supported in Debian Stretch and Raspbian since I wanted to make installing it on the Raspberry Pi as simple as possible. +**A:** Right now, it _only_ runs on Python 3, even though it can deploy apps written in both major versions. It began its development using 2.7 and using`click` for abstracting the simpler stuff, and we eventually switched over to 3.5 once it was supported in Debian Stretch and Raspbian since we wanted to make installing it on the Raspberry Pi as simple as possible. **Q:** Why not just use `dokku`? -**A:** I used `dokku` daily for most of my personal stuff for a good while. But it relied on a number of `x64` containers that needed to be completely rebuilt for ARM, and when I decided I needed something like this (March 2016) that was barely possible - `docker` itself was not fully baked for ARM yet, and people were at the time trying to get `herokuish` and `buildstep` to build on ARM. - - +**A:** We used `dokku` daily for many projects. But it relied on a number of `x64` containers that needed to be completely rebuilt for `ARM`, and when we decided we needed something like this (March 2016) that was barely possible - `docker` itself was not fully baked for `ARM` yet, and people were at the time just starting to get `herokuish` and `buildstep` to build on `ARM`. [click]: http://click.pocoo.org [pi]: http://www.raspberrypi.org diff --git a/docs/INSTALL.md b/docs/INSTALL.md index b450cd2..f949cbc 100644 --- a/docs/INSTALL.md +++ b/docs/INSTALL.md @@ -1,18 +1,33 @@ # Installation -`piku` requires `Python 3`, [uWSGI][uwsgi], SSH, and a Linux distribution that runs `systemd`, such as Raspbian Jessie/Debian 8+/Ubuntu/Fedora/CentOS. +## TL;DR: -There are 3 ways to install piku on a server: +To install it on your server, `ssh` in as `root` and run this: -1. Manually: Follow INSTALL-x.md for which ever platform. If you are running `piku` on specific Linux versions, feel free to contribute your own instructions. +```bash +curl https://piku.github.io/get | sh +``` -2. Use cloud-init to do it automatically at VPS build time: https://github.com/piku/cloud-init +## Installation Methods -3. Use piku-bootstrap to do it once your box is already provisioned: https://github.com/piku/piku-bootstrap +`piku` requires `Python 3`, [uWSGI][uwsgi], `ssh`, and a Linux distribution that runs `systemd`, such as Raspbian Jessie/Debian 8+/Ubuntu/Fedora/CentOS. -# Generic steps (referenced from INSTALL-x) +There are 3 main ways to install `piku` on a server: -## Set up the `piku` user +1. Use [piku-bootstrap](https://github.com/piku/piku-bootstrap) to do it if your server is already provisioned (that is what the TL;DR command does) + +2. Use `cloud-init` to do it automatically at VPS build time (see the [`cloud-init`](https://github.com/piku/cloud-init) repository, which has examples for most common cloud providers) + +3. Manually: Follow the guide below or one of the platform-specfic guides. + +There is also an [Ansible playbook](https://github.com/piku/ansible-setup). + +!!! Contributing + If you are running `piku` on specific Linux versions, feel free to contribute your own instructions. + +## Generic Installation Steps + +### Set up the `piku` user `piku` requires a separate user account to run. To create a new user with the right group membership (we're using the built-in `www-data` group because it's generally thought of as a less-privileged group), enter the following command: @@ -38,10 +53,9 @@ Creating '/home/piku/.piku/logs'. Setting '/home/piku/piku.py' as executable. ``` +### Set up `ssh` access -## Set up SSH access - -If you don't have an SSH public key (or never used one before), you need to create one. The following instructions assume you're running some form of UNIX on your own machine (Windows users should check the documentation for their SSH client, unless you have [Cygwin][cygwin] installed). +If you don't have an `ssh` public key (or never used one before), you need to create one. The following instructions assume you're running some form of UNIX on your own machine (Windows users should check the documentation for their `ssh` client, unless you have [Cygwin][cygwin] installed). **On your own machine**, issue the `ssh-keygen` command and follow the prompts: @@ -81,9 +95,9 @@ cat .ssh/authorized_keys command="FINGERPRINT=85:29:07:cb:de:ad:be:ef:42:65:00:c8:d2:6b:9e:ff NAME=default /home/piku/piku.py $SSH_ORIGINAL_COMMAND",no-agent-forwarding,no-user-rc,no-X11-forwarding,no-port-forwarding ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDhTYZi/qeJBKgU3naI8FNjQgeMYnMsEtqrOmUc4lJoPNH2qBUTNkzwThGqsBm2HNLPURWMiEifBqF+kRixMud67Co7Zs9ys7pwFXkJB9bbZasd2JCGfVZ4UYXHnvgejSWkLAV/4bObhsbP2vWOmbbm91Cwn+PGJgoiW08yrd45lsDmgv9cUAJS3e8LkgVELvIDg49yM5ArB88oxwMEoUgWU2OniHmH0o1zw5I8WXHRhHOjb8cGsdTYfXEizRKKRTM2Mu6dKRt1GNL0UbWi8iS3uJHGD3AcQ4ApdMl5X0gTixKHponStOrSMy19/ltuIy8Sjr7KKPxz07ikMYr7Vpcp youruser@yourlaptop.lan ``` -This line is what enables you to SSH (and perform `git` over SSH operations) to the `piku` user without a password, verifying your identity via your public key, restricting what can be done remotely and passing on to `piku` itself the commands you'll be issuing. +This line is what enables you to `ssh` (and perform `git` over `ssh` operations) to the `piku` user without a password, verifying your identity via your public key, restricting what can be done remotely and passing on to `piku` itself the commands you'll be issuing. -## Test +### Test From your machine, do: @@ -116,7 +130,5 @@ Commands: Connection to pi.lan closed. ``` - [uwsgi]: https://github.com/unbit/uwsgi -[cygwin]: http://www.cygwin.com - +[cygwin]: http://www.cygwin.com \ No newline at end of file diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 0000000..3b00b57 --- /dev/null +++ b/docs/README.md @@ -0,0 +1,3 @@ +# Documentation + +There is now a [documentation site](https://piku.github.io) available, which is built from the `piku.github.io` repository. This directory holds only a small subset of the documentation. \ No newline at end of file diff --git a/docs/DESIGN.md b/docs/old/DESIGN.md similarity index 100% rename from docs/DESIGN.md rename to docs/old/DESIGN.md diff --git a/docs/INSTALL-centos-9.md b/docs/old/INSTALL-centos-9.md similarity index 100% rename from docs/INSTALL-centos-9.md rename to docs/old/INSTALL-centos-9.md diff --git a/docs/INSTALL-other.md b/docs/old/INSTALL-other.md similarity index 100% rename from docs/INSTALL-other.md rename to docs/old/INSTALL-other.md diff --git a/docs/INSTALL-raspbian-9.4-stretch-10-buster.md b/docs/old/INSTALL-raspbian-9.4-stretch-10-buster.md similarity index 100% rename from docs/INSTALL-raspbian-9.4-stretch-10-buster.md rename to docs/old/INSTALL-raspbian-9.4-stretch-10-buster.md diff --git a/docs/INSTALL-ubuntu-18.04-bionic.md b/docs/old/INSTALL-ubuntu-18.04-bionic.md similarity index 100% rename from docs/INSTALL-ubuntu-18.04-bionic.md rename to docs/old/INSTALL-ubuntu-18.04-bionic.md diff --git a/docs/INSTALL-ubuntu-22.04-jammy.md b/docs/old/INSTALL-ubuntu-22.04-jammy.md similarity index 100% rename from docs/INSTALL-ubuntu-22.04-jammy.md rename to docs/old/INSTALL-ubuntu-22.04-jammy.md diff --git a/docs/old/INSTALL.md b/docs/old/INSTALL.md new file mode 100644 index 0000000..f949cbc --- /dev/null +++ b/docs/old/INSTALL.md @@ -0,0 +1,134 @@ +# Installation + +## TL;DR: + +To install it on your server, `ssh` in as `root` and run this: + +```bash +curl https://piku.github.io/get | sh +``` + +## Installation Methods + +`piku` requires `Python 3`, [uWSGI][uwsgi], `ssh`, and a Linux distribution that runs `systemd`, such as Raspbian Jessie/Debian 8+/Ubuntu/Fedora/CentOS. + +There are 3 main ways to install `piku` on a server: + +1. Use [piku-bootstrap](https://github.com/piku/piku-bootstrap) to do it if your server is already provisioned (that is what the TL;DR command does) + +2. Use `cloud-init` to do it automatically at VPS build time (see the [`cloud-init`](https://github.com/piku/cloud-init) repository, which has examples for most common cloud providers) + +3. Manually: Follow the guide below or one of the platform-specfic guides. + +There is also an [Ansible playbook](https://github.com/piku/ansible-setup). + +!!! Contributing + If you are running `piku` on specific Linux versions, feel free to contribute your own instructions. + +## Generic Installation Steps + +### Set up the `piku` user + +`piku` requires a separate user account to run. To create a new user with the right group membership (we're using the built-in `www-data` group because it's generally thought of as a less-privileged group), enter the following command: + +```bash +# pick a username +export PAAS_USERNAME=piku +# create it +sudo adduser --disabled-password --gecos 'PaaS access' --ingroup www-data $PAAS_USERNAME +# copy & setup piku.py +sudo su - $PAAS_USERNAME -c "wget https://raw.githubusercontent.com/piku/piku/master/piku.py && python3 ~/piku.py setup" +``` + +The `setup` output should be something like this: + +``` +Creating '/home/piku/.piku/apps'. +Creating '/home/piku/.piku/repos'. +Creating '/home/piku/.piku/envs'. +Creating '/home/piku/.piku/uwsgi'. +Creating '/home/piku/.piku/uwsgi-available'. +Creating '/home/piku/.piku/uwsgi-enabled'. +Creating '/home/piku/.piku/logs'. +Setting '/home/piku/piku.py' as executable. +``` + +### Set up `ssh` access + +If you don't have an `ssh` public key (or never used one before), you need to create one. The following instructions assume you're running some form of UNIX on your own machine (Windows users should check the documentation for their `ssh` client, unless you have [Cygwin][cygwin] installed). + +**On your own machine**, issue the `ssh-keygen` command and follow the prompts: + +```bash +ssh-keygen + +Generating public/private rsa key pair. +Enter file in which to save the key (/home/youruser/.ssh/id_rsa): +Created directory '/home/youruser/.ssh'. +Enter passphrase (empty for no passphrase): +Enter same passphrase again: +Your identification has been saved in /home/youruser/.ssh/id_rsa. +Your public key has been saved in /home/youruser/.ssh/id_rsa.pub. +The key fingerprint is: +85:29:07:cb:de:ad:be:ef:42:65:00:c8:d2:6b:9e:ff youruser@yourlaptop.lan +The key's randomart image is: ++--[ RSA 2048]----+ +<...> ++-----------------+ +``` + +Copy the resulting `id_rsa.pub` (or equivalent, just make sure it's the _public_ file) to your `piku` server and do the following: + +```bash +sudo su - piku +python3 piku.py setup:ssh /tmp/id_rsa.pub + +Adding key '85:29:07:cb:de:ad:be:ef:42:65:00:c8:d2:6b:9e:ff'. +``` + +Now if you look at `.ssh/authorized_keys`, you should see something like this: + +```bash +sudo su - piku +cat .ssh/authorized_keys + +command="FINGERPRINT=85:29:07:cb:de:ad:be:ef:42:65:00:c8:d2:6b:9e:ff NAME=default /home/piku/piku.py $SSH_ORIGINAL_COMMAND",no-agent-forwarding,no-user-rc,no-X11-forwarding,no-port-forwarding ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDhTYZi/qeJBKgU3naI8FNjQgeMYnMsEtqrOmUc4lJoPNH2qBUTNkzwThGqsBm2HNLPURWMiEifBqF+kRixMud67Co7Zs9ys7pwFXkJB9bbZasd2JCGfVZ4UYXHnvgejSWkLAV/4bObhsbP2vWOmbbm91Cwn+PGJgoiW08yrd45lsDmgv9cUAJS3e8LkgVELvIDg49yM5ArB88oxwMEoUgWU2OniHmH0o1zw5I8WXHRhHOjb8cGsdTYfXEizRKKRTM2Mu6dKRt1GNL0UbWi8iS3uJHGD3AcQ4ApdMl5X0gTixKHponStOrSMy19/ltuIy8Sjr7KKPxz07ikMYr7Vpcp youruser@yourlaptop.lan +``` + +This line is what enables you to `ssh` (and perform `git` over `ssh` operations) to the `piku` user without a password, verifying your identity via your public key, restricting what can be done remotely and passing on to `piku` itself the commands you'll be issuing. + +### Test + +From your machine, do: + +```bash +ssh piku@pi.lan + +Usage: piku.py [OPTIONS] COMMAND [ARGS]... + + The smallest PaaS you've ever seen + +Options: + --help Show this message and exit. + +Commands: + apps List applications + config Show application configuration + config:get Retrieve a configuration setting + config:live Show live configuration settings + config:set Set a configuration setting + deploy Deploy an application + destroy Destroy an application + disable Disable an application + enable Enable an application + logs Tail an application log + ps Show application worker count + ps:scale Show application configuration + restart Restart an application + setup Initialize paths + setup:ssh Set up a new SSH key +Connection to pi.lan closed. +``` + +[uwsgi]: https://github.com/unbit/uwsgi +[cygwin]: http://www.cygwin.com \ No newline at end of file diff --git a/docs/PLUGINS.md b/docs/old/PLUGINS.md similarity index 100% rename from docs/PLUGINS.md rename to docs/old/PLUGINS.md