From b5aef4d481155fd1eaae17fed8bb51035219d46d Mon Sep 17 00:00:00 2001 From: Rui Carmo Date: Sun, 7 Apr 2024 11:31:45 +0100 Subject: [PATCH] cleanup docs --- docs/old/DESIGN.md | 106 --------- docs/old/INSTALL-centos-9.md | 66 ------ docs/old/INSTALL-other.md | 219 ------------------ .../INSTALL-raspbian-9.4-stretch-10-buster.md | 90 ------- docs/old/INSTALL-ubuntu-18.04-bionic.md | 70 ------ docs/old/INSTALL-ubuntu-22.04-jammy.md | 70 ------ docs/old/INSTALL.md | 134 ----------- docs/old/PLUGINS.md | 41 ---- docs/old/RASPBERRY_PI_QUICKSTART.md | 155 ------------- docs/old/ROADMAP.md | 58 ----- docs/old/SCRIPTS.md | 43 ---- 11 files changed, 1052 deletions(-) delete mode 100644 docs/old/DESIGN.md delete mode 100644 docs/old/INSTALL-centos-9.md delete mode 100644 docs/old/INSTALL-other.md delete mode 100644 docs/old/INSTALL-raspbian-9.4-stretch-10-buster.md delete mode 100644 docs/old/INSTALL-ubuntu-18.04-bionic.md delete mode 100644 docs/old/INSTALL-ubuntu-22.04-jammy.md delete mode 100644 docs/old/INSTALL.md delete mode 100644 docs/old/PLUGINS.md delete mode 100644 docs/old/RASPBERRY_PI_QUICKSTART.md delete mode 100644 docs/old/ROADMAP.md delete mode 100644 docs/old/SCRIPTS.md diff --git a/docs/old/DESIGN.md b/docs/old/DESIGN.md deleted file mode 100644 index 8eedbd8..0000000 --- a/docs/old/DESIGN.md +++ /dev/null @@ -1,106 +0,0 @@ -# Design Notes - -The idea behind `piku` is that it provides the simplest possible way to deploy web apps or services. Simplicity comes at the expense of features, of course, and this document tries to capture the trade-offs. - -## Why uWSGI - -Using [uWSGI][uwsgi] in [emperor mode][emperor] gives us the following features for free: - -* Painless Python WSGI and `virtualenv` integration -* Process monitoring, restarting, basic resource limiting, etc. -* Basic security scaffolding, beginning with the ability to define `uid`/`gid` on a per-app basis (if necessary) - -## Application packaging - -An app is simply a `git` repository with some additional files on the top level, the most important of which is the `Procfile`. - -### `Procfile` format - -`piku` recognizes six kinds of process declarations in the `Procfile`: - -* `wsgi` workers, in the format `dotted.module:entry_point` (Python-only) -* `web` workers, which can be anything that honors the `PORT` environment variable -* `static` workers, which simply mount the first argument as the root static path -* `preflight` which is a special "worker" that is run once _before_ the app is deployed _and_ installing deps (can be useful for cleanups). -* `release` which is a special worker that is run once when the app is deployed, after installing deps (can be useful for build steps). -* `cron` workers, which require a simplified `cron` expression preceding the command to be run (e.g. `cron: */5 * * * * python batch.py` to run a batch every 5 minutes) -* `worker` processes, which are standalone workers and can have arbitrary names - -So a Python application could have a `Procfile` like such: - -```bash -# A module to be loaded by uwsgi to serve HTTP requests -wsgi: module.submodule:app -# A background worker -worker: python long_running_script.py -# Another worker with a different name -fetcher: python fetcher.py -# Simple cron expression: minute [0-59], hour [0-23], day [0-31], month [1-12], weekday [1-7] (starting Monday, no ranges allowed on any field) -cron: 0 0 * * * python midnight_cleanup.py -release: python initial_cleanup.py -``` - -...whereas a generic app would be: - -```bash -web: embedded_server --port $PORT -worker: background_worker -``` - -Any worker will be automatically respawned upon failure ([uWSGI][uwsgi] will automatically shun/throttle crashy workers). - -## `ENV` settings - -Since `piku` is targeted at [12 Factor apps][12f], it allows you to set environment variables in a number of ways, the simplest of which is by adding an `ENV` file to your repository: - -```bash -SETTING1=foo -# piku supports comments and variable expansion -SETTING2=${SETTING1}/bar -# if this isn't defined, piku will assign a random TCP port -PORT=9080 -``` - -See [ENV.md](./ENV.md) for a full list of Piku variables which can also be set. - -Environment variables can be changed after deployment using `config:set`. - -## Runtime detection - -`piku` follows a very simple set of rules to determine what kind of runtime is required: - -1. If there's a `requirements.txt` file at the top level, then the app is assumed to require Python. -2. _TODO: Go_ -3. _TODO: Node_ -4. _TODO: Java_ -2. For all the rest, a `Procfile` is required to determine application entry points. - - -## Application isolation - -Application isolation can be tackled at several levels, the most relevant of which being: - -* OS/process isolation -* Runtime/library isolation - -For 1.0, all applications run under the same `uid`, under separate branches of the same filesystem, and without any resource limiting. - -Ways to improve upon that (short of full containerisation) typically entail the use of a `chroot` jail environment (which is available under most POSIX systems in one form or another) or Linux kernel namespaces - both of which are supported by [uWSGI][uwsgi] (which can also handle resource limiting to a degree). - -As to runtime isolation, `piku` only provides `virtualenv` support until 1.0. Python apps can run under Python 2 or 3 depending on the setting of `PYTHON_VERSION`, but will always use pre-installed interpreters (Go, Node and Java support will share these limitations in each major version). - -## Internals - -`piku` uses two `git` repositories for each app: a bare repository for client push, and a clone for deployment (which is efficient in terms of storage since `git` tries to use hardlinks on local clones whenever possible). - -This separation makes it easier to cope with long/large deployments and restore apps to a pristine condition, since the app will only go live after the deployment clone is reset (via `git checkout -f`). - -## Components - -This diagram (available as a `dot` file in the `img` folder) outlines how its components interact: - -![](../img/piku.png) - -[uwsgi]: https://github.com/unbit/uwsgi -[emperor]: http://uwsgi-docs.readthedocs.org/en/latest/Emperor.html -[12f]: http://12factor.net diff --git a/docs/old/INSTALL-centos-9.md b/docs/old/INSTALL-centos-9.md deleted file mode 100644 index 5bb1105..0000000 --- a/docs/old/INSTALL-centos-9.md +++ /dev/null @@ -1,66 +0,0 @@ -# Installation on CentOS 9 - -> This is a standalone, distribution-specific version of `INSTALL.md`. You do not need to read or follow the original file, but can refer to it for generic steps like setting up SSH keys (which are assumed to be common knowledge here) - -All steps done as root (or add sudo if you prefer). - -## Dependencies - -Before installing `piku`, you need to install the following packages: - -```bash -dnf in -y ansible-core ansible-collection-ansible-posix ansible-collection-ansible-utils nginx nodejs npm openssl postgresql postgresql-server postgresql-contrib python3 python3-pip uwsgi uwsgi-logger-file uwsgi-logger-systemd -pip install click -``` - -## Set up the `piku` user - -```bash -adduser --groups nginx piku -# copy & setup piku.py -su - piku -c "wget https://raw.githubusercontent.com/piku/piku/master/piku.py && python3 ~/piku.py setup" -``` - -## Set up SSH access - -See INSTALL.md - -## uWSGI Configuration - -[FYI The uWSGI Emperor – multi-app deployment](https://uwsgi-docs.readthedocs.io/en/latest/Emperor.html) - -```bash -mv /home/piku/.piku/uwsgi/uwsgi.ini /etc/uwsgi.d/piku.ini # linking alone increases the host attack service if one can get inside the piku user or one of its apps, so moving is safer -chown piku:piku /etc/uwsgi.d/piku.ini # In Tyrant mode (set by default in /etc/uwsgi.ini) the Emperor will run the vassal using the UID/GID of the vassal configuration file -systemctl restart uwsgi -journalctl -feu uwsgi # see logs -``` - -## `nginx` Configuration - -[FYI Setting up and configuring NGINX](https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/9/html/deploying_web_servers_and_reverse_proxies/setting-up-and-configuring-nginx_deploying-web-servers-and-reverse-proxies) - -```bash -echo "include /home/piku/.piku/nginx/*.conf;" > /etc/nginx/conf.d/piku.conf -systemctl restart nginx -journalctl -feu nginx # see logs -``` - -## Set up systemd.path to reload nginx upon config changes - -```bash -# Set up systemd.path to reload nginx upon config changes -su - -git clone https://github.com/piku/piku.git # need a copy of some files -cp -v piku/piku-nginx.{path,service} /etc/systemd/system/ -systemctl enable piku-nginx.{path,service} -systemctl start piku-nginx.path -# Check the status of piku-nginx.service -systemctl status piku-nginx.path # should return `active: active (waiting)` -``` - -## Notes - - - -[uwsgi]: https://github.com/unbit/uwsgi diff --git a/docs/old/INSTALL-other.md b/docs/old/INSTALL-other.md deleted file mode 100644 index b6107d5..0000000 --- a/docs/old/INSTALL-other.md +++ /dev/null @@ -1,219 +0,0 @@ -# Installation on other platforms - -> This is a standalone, distribution-specific version of `INSTALL.md`. You do not need to read or follow the original file, but can refer to it for generic steps like setting up SSH keys (which are assumed to be common knowledge here) - - -## Dependencies - -Before running `piku` for the first time, you need to install the following Python packages at the system level: - -### Raspbian Jessie, Debian 8, Ubuntu 16.04 - -```bash -sudo apt-get install git python3-virtualenv python3-pip -sudo pip3 install -U click -``` - -### Raspbian Wheezy - -```bash -sudo apt-get install git python3 -sudo easy_install3 -U pip3 -sudo pip3 install -U click virtualenv -``` - -These may or may not be installed already (`click` usually isn't). For Raspbian Wheezy this is the preferred approach, since current `apt` packages are fairly outdated. - -## Set up the `piku` user, Set up SSH access - -See INSTALL.md - - -## uWSGI Installation (Debian Linux variants, any architecture) - -[uWSGI][uwsgi] can be installed in a variety of fashions. These instructions cover both pre-packaged and source installs depending on your system. - -### Raspbian Jessie, Debian 8 - -> **Warning** -> -> These OS releases are no longer supported and these instructions are kept for reference purposes only. - -In Raspbian Jessie, Debian 8 and other `systemd` distributions where [uWSGI][uwsgi] is already available pre-compiled (but split into a number of plugins), do the following: - -```bash -# At the time of this writing, this installs uwsgi 2.0.7 on Raspbian Jessie. -# You can also install uwsgi-plugins-all if you want to get runtime support for other languages -sudo apt-get install uwsgi uwsgi-plugin-python3 -# refer to our executable using a link, in case there are more versions installed -sudo ln -s `which uwsgi` /usr/local/bin/uwsgi-piku -# disable the standard uwsgi startup script -sudo systemctl disable uwsgi - -# add our own startup script -sudo cp /tmp/uwsgi-piku.service /etc/systemd/system/ -sudo systemctl enable uwsgi-piku -sudo systemctl start uwsgi-piku - -# check it's running -sudo systemctl status uwsgi-piku.service -``` -**Important Note:** Make sure you run `piku.py setup` as outlined above before starting the service. - -Also, please note that `uwsgi-piku.service`, as provided, creates a `/run/uwsgi-piku` directory for it to place socket files and sundry. This is not actually used at the moment, since the `uwsgi` socket file is placed inside the `piku` user directory for consistency across OS distributions. This will be cleaned up in a later release. - -### Raspbian Wheezy - -> **Warning** -> -> This OS release is no longer supported and these instructions are kept for reference purposes only. - -Since Raspbian Wheezy is a fairly old distribution by now, its `uwsgi-*` packages are completely outdated (and depend on Python 2.6), so we have to compile and install our own version, as well as using an old-style `init` script to have it start automatically upon boot. - -```bash -sudo apt-get install build-essential python-dev libpcre3-dev -# At the time of this writing, this installs 2.0.12 -sudo pip install uwsgi -# refer to our executable using a link, in case there are more versions installed -sudo ln -s `which uwsgi` /usr/local/bin/uwsgi-piku - -# set up our init script -sudo cp /tmp/uwsgi-piku.dist /etc/init.d/uwsgi-piku -sudo chmod +x /etc/init.d/uwsgi-piku -sudo update-rc.d uwsgi-piku defaults -sudo service uwsgi-piku start -``` -**Important Note:** Make sure you run `python3 piku.py setup` as outlined above before starting the service. - -### Ubuntu 14.04 LTS - -> **Warning** -> -> This OS release is no longer supported and these instructions are kept for reference purposes only. - -This is a mix of both the above, and should change soon when we get 16.04. If you have trouble, install [uWSGI][uwsgi] via `pip` instead. - -```bash -# At the time of this writing, this installs uwsgi 1.9.17 on Ubuntu 14.04 LTS. -# You can also install uwsgi-plugins-all if you want to get runtime support for other languages -sudo apt-get install uwsgi uwsgi-plugin-python3 -# refer to our executable using a link, in case there are more versions installed -sudo ln -s `which uwsgi` /usr/local/bin/uwsgi-piku - -# set up our init script -sudo cp /tmp/uwsgi-piku.dist /etc/init.d/uwsgi-piku -sudo chmod +x /etc/init.d/uwsgi-piku -sudo update-rc.d uwsgi-piku defaults -sudo service uwsgi-piku start -``` - -## nginx Installation (Raspbian 8, Ubuntu 16.04) - -> **Warning** -> -> These OS releases are no longer supported and these instructions are kept for reference purposes only. - -*PLEASE NOTE:* There is a bug in `nginx` 1.6.2 under Raspbian 8 that causes it to try to allocate around a gigabyte of RAM when using SSL with SPDY. I seriously recommend using Ubuntu instead, if you can, or disabling SSL altogether. - -```bash -sudo apt-get install nginx -# Set up nginx to pick up our config files -sudo cp /tmp/nginx.default.dist /etc/nginx/sites-available/default -# Set up systemd.path to reload nginx upon config changes -sudo cp ./piku-nginx.{path, service} /etc/systemd/system/ -sudo systemctl enable piku-nginx.{path,service} -sudo systemctl start piku-nginx.path -# Check the status of piku-nginx.service -systemctl status piku-nginx.path # should return `Active: active (waiting)` -# Restart NGINX -sudo systemctl restart nginx -``` - -## Java 8 Installation (All Debian Linux variants, on Raspberry Pi) - -> **Warning** -> -> OpenJDK 8 is no longer shipping with most distributions and these instructions are kept for reference purposes only. - -To be able to deploy Java apps, we're going to need to install Java (and, since we're going to be doing so on ARM, it's best to use Oracle's runtime). To do that, we're going to use the `webupd8team` PPA, which has a (cross-platform) Java installer. - -First, get rid of OpenJDK and import the PPA key: - -```bash -sudo apt-get remove openjdk* -sudo apt-key adv --recv-key --keyserver keyserver.ubuntu.com EEA14886 -``` - -### Raspbian Jessie - -> **Warning** -> -> This OS release is no longer supported and these instructions are kept for reference purposes only. - -For Jessie, we're going to use the `trusty` version of the installer: - -```bash -sudo tee /etc/apt/sources.list.d/webupd8team.list -deb http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main -deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main -^D -``` - -### Ubuntu 16.04 for ARM - -> **Warning** -> -> This OS release is no longer supported and these instructions are kept for reference purposes only. - -For Xenial, we're going to use its own version: - -```bash -sudo tee /etc/apt/sources.list.d/webupd8team.list -deb http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main -deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main -^D -``` - -Now perform the actual install: - -```bash -sudo apt-get update -sudo apt-get install oracle-java8-installer oracle-java8-set-default -``` - -## Go Installation (All Debian Linux variants, on Raspberry Pi) - -> This is **EXPERIMENTAL** and may not work at all. - -### Raspbian Wheezy/Jessie - -> **Warning** -> -> Wheezy and Jessie are no longer supported and these instructions are kept for reference purposes only. - -Since Raspbian's Go compiler is version 1.0.2, we need something more up-to-date. - -1. Get an [ARM 6 binary tarball][goarm] -2. Unpack it under the `piku` user like such: - -```bash -sudo su - piku -tar -zxvf /tmp/go1.5.3.linux-arm.tar.gz -# remove unnecessary files -rm -rf go/api go/blog go/doc go/misc go/test -``` - -3. Give it a temporary `GOPATH` and install `godep`: - -```bash -sudo su - piku -GOROOT=$HOME/go GOPATH=$HOME/gopath PATH=$PATH:$HOME/go/bin go get github.com/tools/godep -# temporary workaround until this is fixed in godep or Go 1.7(?) -GOROOT=$HOME/go GOPATH=$HOME/gopath PATH=$PATH:$HOME/go/bin go get golang.org/x/sys/unix -``` - -_TODO: complete this._ - -[goarm]: http://dave.cheney.net/unofficial-arm-tarballs -[uwsgi]: https://github.com/unbit/uwsgi -[cygwin]: http://www.cygwin.com diff --git a/docs/old/INSTALL-raspbian-9.4-stretch-10-buster.md b/docs/old/INSTALL-raspbian-9.4-stretch-10-buster.md deleted file mode 100644 index 95dc316..0000000 --- a/docs/old/INSTALL-raspbian-9.4-stretch-10-buster.md +++ /dev/null @@ -1,90 +0,0 @@ -# Installation on Raspbian Stretch or Buster - -> This is a standalone, distribution-specific version of `INSTALL.md`. You do not need to read or follow the original file, but can refer to it for generic steps like setting up SSH keys (which are assumed to be common knowledge here) - -`piku` setup is simplified in modern Debian versions, since it can take advantage of some packaging improvements in [uWSGI][uwsgi] and does not require a custom `systemd` service. However, Stretch still ships with Python 3.5, which means it's not an ideal environment for new deployments on both Intel and ARM devices (Buster, in turn, ships with Python 3.7). - -## Setting up your Raspberry Pi - -Download and install [Raspbian](https://www.raspberrypi.org/downloads/raspbian/) onto an SD card. - -After you install it is recommended that you do the following to update your installation to the latest available software. - -```bash -# update apt-get -sudo apt-get update - -# upgrade all software -sudo apt-get upgrade -``` - -Configure your installation. It is recommended that `Change Password` from the default and setup `Locale Options` (Locale and Timezone) and `EXPAND FILESYSTEM`. You will also want to `Enable SSH`. -```bash -# configure your installation -sudo raspi-config -``` - -At this point it is a good idea to `sudo shutdown -h now` and make a backup image of the card. - -## Dependencies - -Before installing `piku`, you need to install the following packages: - -```bash -sudo apt-get install -y build-essential certbot git \ - libjpeg-dev libxml2-dev libxslt1-dev zlib1g-dev nginx \ - python-certbot-nginx python-dev python-pip python-virtualenv \ - python3-dev python3-pip python3-click python3-virtualenv \ - uwsgi uwsgi-plugin-asyncio-python3 uwsgi-plugin-gevent-python \ - uwsgi-plugin-python uwsgi-plugin-python3 uwsgi-plugin-tornado-python \ - uwsgi-plugin-lua5.1 uwsgi-plugin-lua5.2 uwsgi-plugin-luajit -``` -## Set up the `piku` user, Set up SSH access - -See INSTALL.md - -## uWSGI Configuration - -[uWSGI][uwsgi] in Stretch and Buster requires very little configuration, since it is already properly packaged. All you need to do is create a symlink to the `piku` configuration file in `/etc/uwsgi/apps-enabled`: - -```bash -sudo ln /home/$PAAS_USERNAME/.piku/uwsgi/uwsgi.ini /etc/uwsgi/apps-enabled/piku.ini -sudo systemctl restart uwsgi -``` - -## `nginx` Configuration - -`piku` requires you to edit `/etc/nginx/sites-available/default` to the following, so it can inject new site configurations into `nginx`: - -``` -server { - listen 80 default_server; - listen [::]:80 default_server; - root /var/www/html; - index index.html index.htm; - server_name _; - location / { - try_files $uri $uri/ =404; - } -} -# replace `PAAS_USERNAME` with the username you created. -include /home/PAAS_USERNAME/.piku/nginx/*.conf; -``` - -## Set up systemd.path to reload nginx upon config changes - -```bash -# Set up systemd.path to reload nginx upon config changes -sudo cp ./piku-nginx.{path, service} /etc/systemd/system/ -sudo systemctl enable piku-nginx.{path,service} -sudo systemctl start piku-nginx.path -# Check the status of piku-nginx.service -systemctl status piku-nginx.path # should return `Active: active (waiting)` -# Restart NGINX -sudo systemctl restart nginx -``` -## Notes - -> This file was last updated on June 2019 - -[uwsgi]: https://github.com/unbit/uwsgi diff --git a/docs/old/INSTALL-ubuntu-18.04-bionic.md b/docs/old/INSTALL-ubuntu-18.04-bionic.md deleted file mode 100644 index 954af99..0000000 --- a/docs/old/INSTALL-ubuntu-18.04-bionic.md +++ /dev/null @@ -1,70 +0,0 @@ -# Installation on Ubuntu 18.04 LTS (Bionic) - -> This is a standalone, distribution-specific version of `INSTALL.md`. You do not need to read or follow the original file, but can refer to it for generic steps like setting up SSH keys (which are assumed to be common knowledge here) - -`piku` setup is simplified in Bionic, since it can take advantage of some packaging improvements in [uWSGI][uwsgi] and does not require a custom `systemd` service. Since Bionic also ships with Python 3.6, this is an ideal environment for new deployments on both Intel and ARM devices. - -## Dependencies - -Before installing `piku`, you need to install the following packages: - -```bash -sudo apt-get update -sudo apt-get install -y build-essential certbot git \ - libjpeg-dev libxml2-dev libxslt1-dev zlib1g-dev nginx \ - python-certbot-nginx python-dev python-pip python-virtualenv \ - python3-dev python3-pip python3-click python3-virtualenv \ - uwsgi uwsgi-plugin-asyncio-python3 uwsgi-plugin-gevent-python \ - uwsgi-plugin-python uwsgi-plugin-python3 uwsgi-plugin-tornado-python -``` - -## Set up the `piku` user, Set up SSH access - -See INSTALL.md - -## uWSGI Configuration - -[uWSGI][uwsgi] requires very little configuration, since it is already properly packaged. All you need to do is place a link to the `piku` configuration file in `/etc/uwsgi/apps-enabled`: - -```bash -sudo ln /home/$PAAS_USERNAME/.piku/uwsgi/uwsgi.ini /etc/uwsgi/apps-enabled/piku.ini -sudo systemctl restart uwsgi -``` - -## `nginx` Configuration - -`piku` requires you to edit `/etc/nginx/sites-available/default` to the following, so it can inject new site configurations into `nginx`: - -``` -server { - listen 80 default_server; - listen [::]:80 default_server; - root /var/www/html; - index index.html index.htm; - server_name _; - location / { - try_files $uri $uri/ =404; - } -} -# replace `PAAS_USERNAME` with the username you created. -include /home/PAAS_USERNAME/.piku/nginx/*.conf; -``` - -## Set up systemd.path to reload nginx upon config changes - -```bash -# Set up systemd.path to reload nginx upon config changes -sudo cp ./piku-nginx.{path, service} /etc/systemd/system/ -sudo systemctl enable piku-nginx.{path,service} -sudo systemctl start piku-nginx.path -# Check the status of piku-nginx.service -systemctl status piku-nginx.path # should return `Active: active (waiting)` -# Restart NGINX -sudo systemctl restart nginx -``` - -## Notes - -> This file was last updated on November 2018 - -[uwsgi]: https://github.com/unbit/uwsgi diff --git a/docs/old/INSTALL-ubuntu-22.04-jammy.md b/docs/old/INSTALL-ubuntu-22.04-jammy.md deleted file mode 100644 index 8ee3733..0000000 --- a/docs/old/INSTALL-ubuntu-22.04-jammy.md +++ /dev/null @@ -1,70 +0,0 @@ -# Installation on Ubuntu 22.04 LTS (Jammy) - -> This is a standalone, distribution-specific version of `INSTALL.md`. You do not need to read or follow the original file, but can refer to it for generic steps like setting up SSH keys (which are assumed to be common knowledge here) - -`piku` setup is simplified in Jammy, since it can take advantage of some packaging improvements in [uWSGI][uwsgi] and does not require a custom `systemd` service. Since Jammy also ships with Python 3.10, this is an ideal environment for new deployments on both Intel and ARM devices. - -## Dependencies - -Before installing `piku`, you need to install the following packages: - -```bash -sudo apt-get update -sudo apt-get install -y build-essential certbot git \ - libjpeg-dev libxml2-dev libxslt1-dev zlib1g-dev nginx \ - python3-certbot-nginx \ - python3-dev python3-pip python3-click python3-virtualenv \ - uwsgi uwsgi-plugin-asyncio-python3 uwsgi-plugin-gevent-python3 \ - uwsgi-plugin-python3 uwsgi-plugin-tornado-python3 -``` - -## Set up the `piku` user, Set up SSH access - -See INSTALL.md - -## uWSGI Configuration - -[uWSGI][uwsgi] requires very little configuration, since it is already properly packaged. All you need to do is place a link to the `piku` configuration file in `/etc/uwsgi/apps-enabled`: - -```bash -sudo ln /home/$PAAS_USERNAME/.piku/uwsgi/uwsgi.ini /etc/uwsgi/apps-enabled/piku.ini -sudo systemctl restart uwsgi -``` - -## `nginx` Configuration - -`piku` requires you to edit `/etc/nginx/sites-available/default` to the following, so it can inject new site configurations into `nginx`: - -``` -server { - listen 80 default_server; - listen [::]:80 default_server; - root /var/www/html; - index index.html index.htm; - server_name _; - location / { - try_files $uri $uri/ =404; - } -} -# replace `PAAS_USERNAME` with the username you created. -include /home/PAAS_USERNAME/.piku/nginx/*.conf; -``` - -## Set up systemd.path to reload nginx upon config changes - -```bash -# Set up systemd.path to reload nginx upon config changes -sudo cp ./piku-nginx.{path, service} /etc/systemd/system/ -sudo systemctl enable piku-nginx.{path,service} -sudo systemctl start piku-nginx.path -# Check the status of piku-nginx.service -systemctl status piku-nginx.path # should return `Active: active (waiting)` -# Restart NGINX -sudo systemctl restart nginx -``` - -## Notes - -> This file was last updated on November 2018 - -[uwsgi]: https://github.com/unbit/uwsgi diff --git a/docs/old/INSTALL.md b/docs/old/INSTALL.md deleted file mode 100644 index f949cbc..0000000 --- a/docs/old/INSTALL.md +++ /dev/null @@ -1,134 +0,0 @@ -# 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/old/PLUGINS.md b/docs/old/PLUGINS.md deleted file mode 100644 index 034da6e..0000000 --- a/docs/old/PLUGINS.md +++ /dev/null @@ -1,41 +0,0 @@ -Thanks to [jsenin](https://github.com/jsenin), `piku` currently has experimental support for external plugins via [#129](https://github.com/piku/piku/pull/129). - -Plugins are inserted into the commands listing and can perform arbitrary actions. At this moment there are no official plugins, but here is an example file that should be placed at `~/.piku/plugins/postgres/__init__.py` that could contain the commands to manage a Postgres database: - -```python -import click - -@click.group() -def postgres(): - """Postgres command plugin""" - pass - -@postgres.command("postgres:create") -@click.argument('name') -@click.argument('user') -@click.argument('password') -def postgres_create(): - """Postgres create a database""" - pass - -@postgres.command("postgres:drop") -@click.argument('name') -def postgres_drop(): - """Postgres drops a database""" - pass - -@postgres.command("postgres:import") -@click.argument('name') -def postgres_drop(): - """Postgres import a database""" - pass - -@postgres.command("postgres:dump") -@click.argument('name') -def postgres_drop(): - """Postgres dumps a database SQL""" - pass - -def cli_commands(): - return postgres -``` diff --git a/docs/old/RASPBERRY_PI_QUICKSTART.md b/docs/old/RASPBERRY_PI_QUICKSTART.md deleted file mode 100644 index 64c91e7..0000000 --- a/docs/old/RASPBERRY_PI_QUICKSTART.md +++ /dev/null @@ -1,155 +0,0 @@ -# Setting up a Raspberry Pi Piku Server from Scratch - -## DISCLAIMER! - -### These instructions are correct as of April 1st 2016 - -Start by flashing a SD card with [the latest Raspbian Jessie Lite image](https://www.raspberrypi.org/downloads/raspbian/). - -# Do this in your Raspberry Pi as 'pi' user - -Boot it, launch *raspi-config* to perform (at least) the following configuration: - -```bash -# as 'pi' user -sudo raspi-config -``` - -* 1) expand filesystem -* 2) change default user password -* 3) set up memory split as you wish (for a headless server, 16MB for GPU) - -Optionally: - -* 4) set up over-clocking. - -# Secure your install - -Delete the existing SSH keys and recreate them (why? [read this](https://www.raspberrypi.org/forums/viewtopic.php?t=126892)). - -```bash -# as 'pi' user -sudo rm -v /etc/ssh/ssh_host_* -sudo dpkg-reconfigure openssh-server -sudo reboot -``` - -This will recreate the server keys. Next, update your system: - -```bash -# as 'pi' user -sudo apt update -sudo apt upgrade -``` - -# Install required packages - -As of April 2016, the shipping versions with Raspbian are recent enough to run `piku`: - -```bash -# as 'pi' user -sudo apt install -y python-virtualenv python-pip git uwsgi uwsgi-plugin-python nginx -sudo pip install -U click -sudo reboot -``` - -# Meanwhile, go get the goodies while Raspberry Pi is rebooting - -(We assume you know about ssh keys and have one "at hand", you'll need to copy it) - -Clone the [piku repo](https://github.com/piku/piku) somewhere and copy files to your Raspberry Pi - -```bash -# as yourself in your desktop/laptop computer -scp piku.py uwsgi-piku.service nginx.default.dist pi@your_machine:/tmp -scp your_public_ssh_key.pub pi@your_machine:/tmp -``` - -# Back to the Pi - -Prepare uWSGI (part one): -```bash -# as 'pi' user -sudo ln -s `which uwsgi` /usr/local/bin/uwsgi-piku -sudo systemctl disable uwsgi -sudo cp /tmp/uwsgi-piku.service /etc/systemd/system/ -sudo systemctl daemon-reload -sudo systemctl enable uwsgi-piku -``` - -Prepare nginx: - -```bash -sudo apt-get install nginx -# Set up nginx to pick up our config files -sudo cp /tmp/nginx.default.dist /etc/nginx/sites-available/default -# Set up systemd.path to reload nginx upon config changes -sudo cp ./piku-nginx.{path, service} /etc/systemd/system/ -sudo systemctl enable piku-nginx.{path,service} -sudo systemctl start piku-nginx.path -# Check the status of piku-nginx.service -systemctl status piku-nginx.path # should return `Active: active (waiting)` -# Restart NGINX -sudo systemctl restart nginx -``` - -Create 'piku' user and set it up - -```bash -# as 'pi' user -sudo adduser --disabled-password --gecos 'PaaS access' --ingroup www-data piku -sudo su - piku -# this is now done as 'piku' user -mkdir ~/.ssh -chmod 700 ~/.ssh -cp /tmp/piku.py ~/piku.py -python piku.py setup -python piku.py setup:ssh /tmp/id_rsa.pub -# return to 'pi' user -exit -``` - -Prepare uWSGI (part two): - -```bash -# as 'pi' user -sudo systemctl start uwsgi-piku -sudo systemctl status uwsgi-piku.service -``` - - -# If you're still here, odds are your Pi is ready for work - -Go back to your machine and try these commands: - -```bash -# as yourself in your desktop/laptop computer -ssh piku@your_machine - -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 your_machine closed. -``` - -If you find any bugs with this quickstart guide, please let [Luis Correia](http://twitter.com/luisfcorreia) know ;) diff --git a/docs/old/ROADMAP.md b/docs/old/ROADMAP.md deleted file mode 100644 index f693e5f..0000000 --- a/docs/old/ROADMAP.md +++ /dev/null @@ -1,58 +0,0 @@ -# Roadmap - -This was the original roadmap, filed here in 2019-11-21 for future reference: - -- [ ] Prebuilt Raspbian image with everything baked in -- [ ] `chroot`/namespace isolation (tentative) -- [ ] Relay commands to other nodes -- [ ] Proxy deployments to other nodes (build on one box, deploy to many) -- [ ] Support Clojure/Java deployments through `boot` or `lein` -- [ ] Sample Go app -- [ ] Support Go deployments (in progress) -- [ ] nginx SSL optimization/cypher suites, own certificates -- [ ] Review deployment messages -- [ ] WIP: Review docs/CLI command documentation (short descriptions done, need `help ` and better descriptions) -- [ ] Lua/WSAPI support -- [x] Support for Java Apps with maven/gradle (in progress through jwsgi, by @matrixjnr) -- [x] Django and Wisp examples (by @chr15m) -- [x] Project logo (by @chr15m) -- [x] Various release/deployment improvements (by @chr15m) -- [x] Support Node deployments (by @chr15m) -- [x] Let's Encrypt support (by @chr15m) -- [x] Allow setting `nginx` IP bindings in `ENV` file (`NGINX_IPV4_ADDRESS` and `NGINX_IPV6_ADDRESS`) -- [x] Cleanups to remove 2.7 syntax internally -- [x] Change to Python 3 runtime as default, with `PYTHON_VERSION = 2` as fallback -- [x] Run in Python 3 only -- [x] (experimental) REPL in `feature/repl` -- [x] Python 3 support through `PYTHON_VERSION = 3` -- [x] static URL mapping to arbitrary paths (hat tip to @carlosefr for `nginx` tuning) -- [x] remote CLI (requires `ssh -t`) -- [x] saner uWSGI logging -- [x] `gevent` activated when `UWSGI_GEVENT = ` -- [x] enable CloudFlare ACL when `NGINX_CLOUDFLARE_ACL = True` -- [x] Autodetect SPDY/HTTPv2 support and activate it -- [x] Basic nginx SSL config with self-signed certificates and UNIX domain socket connection -- [x] nginx support - creates an nginx config file if `NGINX_SERVER_NAME` is defined -- [x] Testing with pre-packaged [uWSGI][uwsgi] versions on Debian Jessie (yes, it was painful) -- [x] Support barebones binary deployments -- [x] Complete installation instructions (see `INSTALL.md`, which also has a draft of Go installation steps) -- [x] Installation helper/SSH key setup -- [x] Worker scaling -- [x] Remote CLI commands for changing/viewing applied/live settings -- [x] Remote tailing of all logfiles for a single application -- [x] HTTP port selection (and per-app environment variables) -- [x] Sample Python app -- [X] `Procfile` support (`wsgi` and `worker` processes for now, `web` processes being tested) -- [x] Basic CLI commands to manage apps -- [x] `virtualenv` isolation -- [x] Support Python deployments -- [x] Repo creation upon first push -- [x] Basic understanding of [how `dokku` works](http://off-the-stack.moorman.nu/2013-11-23-how-dokku-works.html) - -[click]: http://click.pocoo.org -[pi]: http://www.raspberrypi.org -[dokku]: https://github.com/dokku/dokku -[raspi-cluster]: https://github.com/rcarmo/raspi-cluster -[cygwin]: http://www.cygwin.com -[uwsgi]: https://github.com/unbit/uwsgi -[wsl]: https://en.wikipedia.org/wiki/Windows_Subsystem_for_Linux diff --git a/docs/old/SCRIPTS.md b/docs/old/SCRIPTS.md deleted file mode 100644 index c2df86c..0000000 --- a/docs/old/SCRIPTS.md +++ /dev/null @@ -1,43 +0,0 @@ -# Ubuntu 16.04 - -Full installation sequence on a blank Ubuntu 16.04 machine: - -```bash -sudo apt-get update -sudo apt-get -y dist-upgrade -sudo apt-get -y autoremove -sudo apt-get install -y tmux vim htop fail2ban uwsgi uwsgi-plugin-python uwsgi-plugin-python3 uwsgi-plugin-asyncio-python3 uwsgi-plugin-gevent-python uwsgi-plugin-tornado-python nginx libxml2-dev libxslt1-dev python-dev zlib1g-dev build-essential git python3-virtualenv python3-pip python3-click -sudo pip3 install -U click pip -sudo adduser --disabled-password --gecos 'PaaS access' --ingroup www-data piku - -# move to /tmp and grab our distribution files -cd /tmp -wget https://raw.githubusercontent.com/piku/piku/master/piku.py -wget https://raw.githubusercontent.com/piku/piku/master/piku-nginx.path -wget https://raw.githubusercontent.com/piku/piku/master/piku-nginx.service -wget https://raw.githubusercontent.com/piku/piku/master/nginx.default.dist -wget https://raw.githubusercontent.com/piku/piku/master/uwsgi-piku.service -# Set up nginx to pick up our config files -sudo cp /tmp/nginx.default.dist /etc/nginx/sites-available/default -# Set up systemd.path to reload nginx upon config changes -sudo cp ./piku-nginx.{path, service} /etc/systemd/system/ -sudo systemctl enable piku-nginx.{path,service} -sudo systemctl start piku-nginx.path -# Restart NGINX -sudo systemctl restart nginx -sudo cp /tmp/uwsgi-piku.service /etc/systemd/system/ -# refer to our executable using a link, in case there are more versions installed -sudo ln -s `which uwsgi` /usr/local/bin/uwsgi-piku -# disable the standard uwsgi startup script -sudo systemctl disable uwsgi -sudo systemctl enable uwsgi-piku -sudo su - piku -mkdir ~/.ssh -chmod 700 ~/.ssh -# now copy the piku script to this user account -cp /tmp/piku.py ~/piku.py -python3 piku.py setup -# Now import your SSH key using setup:ssh - -sudo systemctl start uwsgi-piku -```