diff --git a/.drone.yml b/.drone.yml index d4d41b3..cab5d03 100644 --- a/.drone.yml +++ b/.drone.yml @@ -16,6 +16,6 @@ steps: - ./build_container.sh - mkdir release/ - rm -v treebird-latest/treebird - - tar -czf release/treebird-static-files-latest-`git rev-parse HEAD`.tar.gz treebird-latest/ + - tar -czf release/treebird-static-files-latest-`git rev-parse HEAD`.tar.gz treebird-latest/ treebird.nginx - docker save treebird:latest | gzip > release/treebird-latest-`git rev-parse HEAD`.tar.gz - docker run --rm -e DRONE_BUILD_EVENT=tag -e PLUGIN_BASE_URL=https://git.freecumextremist.com/ -e PLUGIN_API_KEY=$APIKEY -e PLUGIN_FILES=release/* -e DRONE_REPO_OWNER=icscarythings -e DRONE_REPO_NAME=treebird-docker -v $(pwd):$(pwd) -w $(pwd) plugins/gitea-release diff --git a/README.md b/README.md index 0d5497e..8d544e8 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,72 @@ Nekobit's `Treebird` C-FCGI based front end for [Pleroma](https://pleroma.social - `docker` (or `docker.io` on older distros) - `nginx` (or another FCGI capable web server) +- `bash` (only for commands in the instructions. If you mentally translate you dont need it) + +## Installing +To install you can either build the container yourself or grab the latest from +the Gitea release tab. Here I'm going to assume the latter. + +1. On your server download the `treebird-latest` and `treebird-latest-static-files` tars + +2. If you don't have it already, install docker (`apt install docker` or `docker.io` for old debian) + NOTE: for other distros obviously this will differ so find it in your package manager + +3. Load the image + + sudo docker load -i treebird-latest.tar.gz + +4. Add an unprivileged treebrid user and group to the host (this is needed to avoid uid/gid conflicts) + + sudo useradd -r -s /bin/false -c 'Treebird FE user' -U treebird + +5. Run the container as below to start in daemon mode (`-d`) on port 4008 as user:group treebird:treebird + + docker run \ + --rm \ + --name treebird \ + -p 127.0.0.1:4008:4008 \ + -u "`id -u treebird`:`id -g treebird`" \ + -e TREEBIRD_CFG_INSTANCE_URL="https://my.instance.domain/" \ + -d "treebird:latest" + + # You can verify this started by checking `docker ps` + # This should remain up until either the system is rebooted or the docker + # daemon is restarted (or you can manually stop with the docker stop command). + + # To have it auto start on reboot you need to either add to your init system + # or manage with a docker wrapper like docker-compose or etc. + # TODO: instructions + +6. Add a web folder for the static files + + sudo mkdir -p /var/www/treebird + sudo chmod a+r /var/www/treebird + +7. Extract static files to web folder + + tar -xzf treebird-static-latest.tar.gz + sudo cp -r treebird-latest/* /var/www/treebird + +8. Setup your Nginx Configuration (other servers idk for now) + + # In case the folders do not exist yet, do the following + sudo mkdir -p /etc/nginx/sites-{available,enabled} + + # If you needed the above, ensure you also you have `include sites-enabled/*;` + # in the http section of `/etc/nginx/nginx.conf` + + # First edit treebird.nginx to replace treebird.example.com with your treebird hostname + sudo cp treebird.nginx /etc/nginx/sites-available/treebird.nginx + sudo ln -s /etc/nginx/{sites-available,sites-enabled}/treebird.nginx + + # Activate SSL for domain (the usual... select domain and etc.) + sudo certbot --nginx + + # Start nginx + sudo systemctl start nginx + +It should now be running on the domain you configured. ## Building Building the container should be as simple as running `build_container.sh` and @@ -41,6 +107,3 @@ option so it will close when you close the terminal (since this is only for test From here, you can open your preferred web browser to `http://localhost/` and `Treebird` should appear. - -## Installing -TODO (will add steps after I install it on my own domain). diff --git a/treebird.nginx b/treebird.nginx new file mode 100644 index 0000000..621f151 --- /dev/null +++ b/treebird.nginx @@ -0,0 +1,58 @@ +server { + server_name treebird.example.com; + + location @treebird { + # These are added manually because the FCGI include varies radically + # between installs in some cases I have seen... + fastcgi_param QUERY_STRING $query_string; + fastcgi_param REQUEST_METHOD $request_method; + fastcgi_param CONTENT_TYPE $content_type; + fastcgi_param CONTENT_LENGTH $content_length; + + fastcgi_param REQUEST_URI $request_uri; + fastcgi_param DOCUMENT_URI $document_uri; + fastcgi_param DOCUMENT_ROOT $document_root; + fastcgi_param SERVER_PROTOCOL $server_protocol; + fastcgi_param REQUEST_SCHEME $scheme; + fastcgi_param HTTPS $https if_not_empty; + + fastcgi_param GATEWAY_INTERFACE CGI/1.1; + fastcgi_param SERVER_SOFTWARE nginx/$nginx_version; + + fastcgi_param REMOTE_ADDR $remote_addr; + fastcgi_param REMOTE_PORT $remote_port; + fastcgi_param SERVER_ADDR $server_addr; + fastcgi_param SERVER_PORT $server_port; + fastcgi_param SERVER_NAME $server_name; + + fastcgi_param SCRIPT_FILENAME /usr/local/bin/treebird; + fastcgi_param PATH_INFO $uri; + + fastcgi_pass 127.0.0.1:4008; # Port can be changed if set to match container port + } + + location / { + root /var/www/treebird; #Change this to the location of the static files + try_files $uri @treebird; + } + + listen [::]:443 ssl; + listen 443 ssl; + ssl_certificate /etc/letsencrypt/live/treebird.example.com/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/treebird.example.com/privkey.pem; + include /etc/letsencrypt/options-ssl-nginx.conf; + ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; +} + +server { + if ($host = treebird.example.com) { + return 301 https://$host$request_uri; + } + + + listen 80; + listen [::]:80; + + server_name treebird.example.com; + return 404; +}