Gab Social. All are welcome.
This commit is contained in:
234
docs/developer.md
Normal file
234
docs/developer.md
Normal file
@@ -0,0 +1,234 @@
|
||||
# Gab Social Developer Setup
|
||||
|
||||
Developers wanting to work on [Gab Social](https://github.com/gab-ai-inc/gab-social) source code and make changes to the system must configure a host for use with Gab Social's development environment.
|
||||
|
||||
The instructions in this file do not create a production-grade host that is secure and can scale. Instead, these instructions deliver a working environment tuned for making changes to Gab Social and for quickly iterating on those changes to get stuff done.
|
||||
|
||||
## Host OS
|
||||
|
||||
[Gab Social](https://github.com/gab-ai-inc/gab-social) development has been tested on [Ubuntu 18.04LTS](https://www.ubuntu.com/download/desktop). As we continue to migrate further away from Gab Social's code, at least MacOS will be supported as a choice.
|
||||
|
||||
We are unlikely to support Windows as a host OS because no part of our software development infrastructure is based on Windows. We will, however, be happy to review and accept your pull requests adding Windows support for development and even production hosting if you think that's not too nutty.
|
||||
|
||||
## Superuser Host Access Rights Required
|
||||
|
||||
This document describes commands intended to be run in a terminal. It also describes changes needed in some components' configuration files. Some of these actions must be performed with the user account you will use for day-to-day development. And, some of the commands need to be performed as the superuser (root) or a user with equivalent administrative privileges.
|
||||
|
||||
When superuser permissions are required,
|
||||
|
||||
## Extend Ubuntu repositories when using Ubuntu 18.04.1LTS or later
|
||||
|
||||
Starting with Ubuntu 18.04.1 LTS, Canonical removed the multiverse and restricted repositories from the sources.list in `/etc/apt/`. It is now necessary to add those repositories manually , otherwise the installation of the following dependencies will fail.
|
||||
|
||||
```sh
|
||||
sudo add-apt-repository multiverse
|
||||
sudo add-apt-repository restricted
|
||||
sudo apt update
|
||||
```
|
||||
|
||||
## System Dependencies
|
||||
|
||||
The following software components and libraries are required by [Gab Social](https://github.com/gab-ai-inc/gab-social).
|
||||
|
||||
- *ImageMagick* - Gab Social uses imagemagick for image related operations
|
||||
- *FFMPEG* - Gab Social uses ffmpeg for conversion of GIFs to MP4s
|
||||
- *libprotobuf-dev* and *protobuf-compiler* - Gab Social uses these for language detection
|
||||
- *nginx* - nginx is our frontend web server
|
||||
- *Redis* - Gab Social uses redis for its in-memory data structure store
|
||||
- *postgresql* - Gab Social uses PostgreSQL as its SQL database
|
||||
- *Node.js* - Node is used for Gab Social's streaming API and other platform services
|
||||
- *Yarn* - Yarn is a Node.js package manager
|
||||
- *gcc, g++, etc.* - these are needed for the compilation of Ruby using ruby-build and to build Node.js extensions
|
||||
|
||||
## Dependency Installation
|
||||
|
||||
All dependencies should be installed as the system superuser (root). Either use the `sudo` command as required, or by first switching to the superuser using the following command:
|
||||
|
||||
```sh
|
||||
sudo -i
|
||||
```
|
||||
|
||||
If you become root, please be sure to switch back to your regular user account when instructed to do so later.
|
||||
|
||||
### Install system components
|
||||
|
||||
```sh
|
||||
apt-get install -y imagemagick ffmpeg libpq-dev libxml2-dev libxslt1-dev file git git-flow g++ libprotobuf-dev protobuf-compiler pkg-config gcc autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm5 libgdbm-dev nginx redis-server redis-tools postgresql postgresql-contrib certbot libidn11-dev libicu-dev
|
||||
```
|
||||
|
||||
### Install Node.js 10.15.3 LTS
|
||||
|
||||
Node.js is required for running the [Gab Social](https://github.com/gab-ai-inc/gab-social) Streaming API server and for other system management tasks related to the Gab Platform.
|
||||
|
||||
```bash
|
||||
# Install nvm to manage Node.js versions
|
||||
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
|
||||
|
||||
# Install the Node.js runtime
|
||||
nvm install 10.15.3
|
||||
|
||||
# Install Yarn
|
||||
npm install -g yarn
|
||||
```
|
||||
|
||||
## Create User Account
|
||||
|
||||
Gab Social requires a standard non-root user account for day-to-day operations and work. This can be your own account or (if following this document for the first time) the `gabsocial` user.
|
||||
|
||||
Creating a `gabsocial` user is simple and can make following the rest of this guide very simple.
|
||||
|
||||
```
|
||||
adduser --disabled-password --quiet gabsocial
|
||||
```
|
||||
|
||||
## PostgreSQL Database Creation
|
||||
|
||||
[Gab Social](https://github.com/gab-ai-inc/gab-social) requires access to a [PostgreSQL](https://www.postgresql.org) instance.
|
||||
|
||||
Create a user for a [PostgreSQL](https://www.postgresql.org) instance:
|
||||
|
||||
```
|
||||
# Launch psql as the postgres user
|
||||
sudo -u postgres psql
|
||||
|
||||
# In the following prompt
|
||||
CREATE USER gabsocial CREATEDB;
|
||||
\q
|
||||
```
|
||||
|
||||
**Note** that we do not set up a password of any kind, this is because we will be using ident authentication. This allows local users to access the database without a password.
|
||||
|
||||
### Switch back to your account
|
||||
|
||||
If you became the root user to install system dependencies, please relinquish superuser privileges and return to your user account.
|
||||
|
||||
```sh
|
||||
exit
|
||||
```
|
||||
|
||||
### Configure your working environment
|
||||
|
||||
The public-facing Web service `gabsocial-web` is currently built using Ruby On Rails. A developer workstation user account, therefore, must configure [`rbenv`](https://github.com/rbenv/rbenv) and [`ruby-build`](https://github.com/rbenv/ruby-build) as follows:
|
||||
|
||||
```sh
|
||||
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
|
||||
cd ~/.rbenv && src/configure && make -C src
|
||||
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
|
||||
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
|
||||
|
||||
# Restart shell
|
||||
exec bash
|
||||
|
||||
# Check if rbenv is correctly installed
|
||||
type rbenv
|
||||
|
||||
# Install ruby-build as rbenv plugin
|
||||
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
|
||||
```
|
||||
|
||||
Now that [`rbenv`](https://github.com/rbenv/rbenv) and [`ruby-build`](https://github.com/rbenv/ruby-build) are installed, we will install the
|
||||
[Ruby](https://www.ruby-lang.org/en/) version which [Gab Social](https://github.com/gab-ai-inc/gab-social) uses. That version will also need to be enabled.
|
||||
|
||||
To enable [Ruby](https://www.ruby-lang.org/en/), run:
|
||||
|
||||
```sh
|
||||
rbenv install 2.6.1
|
||||
rbenv global 2.6.1
|
||||
```
|
||||
|
||||
This will take some time. Go stretch for a bit and drink some water while the commands run.
|
||||
|
||||
### node.js And Ruby Dependencies
|
||||
|
||||
Now that [Ruby](https://www.ruby-lang.org/en/) is enabled, we will clone the [Git Social git repository](https://github.com/gab-ai-inc/gab-social) and install the [Ruby](https://www.ruby-lang.org/en/) and [node.js](https://nodejs.org/en/) dependancies.
|
||||
|
||||
Run the following to clone and install:
|
||||
|
||||
```sh
|
||||
# By convention at Gab, we work in ~/projects
|
||||
mkdir -p ~/projects
|
||||
cd ~/projects
|
||||
|
||||
# Clone the Gab Social repository into ~/projects
|
||||
git clone https://github.com/gab-ai-inc/gab-social.git gab-social
|
||||
|
||||
# Hop into the project directory (all are welcome!)
|
||||
cd ~/projects/gab-social
|
||||
|
||||
# Install bundler
|
||||
gem install bundler
|
||||
|
||||
# Use bundler to install the rest of the Ruby dependencies
|
||||
bundle install
|
||||
|
||||
# Use yarn to install node.js dependencies
|
||||
yarn install --pure-lockfile
|
||||
|
||||
# To setup the `gabsocial_development` database, run:
|
||||
bundle exec rails db:setup
|
||||
|
||||
# Use foreman to start things up
|
||||
gem install foreman
|
||||
foreman start
|
||||
```
|
||||
|
||||
At this point, you should be able to open `http://localhost:3000` in your browser and log in using the default credentials `admin@localhost:3000` and password `administrator`.
|
||||
|
||||
Some additional useful commands:
|
||||
|
||||
```sh
|
||||
# pre-compile the front-end assets and fun stuff
|
||||
bin/rails assets:precompile
|
||||
|
||||
# manually start the webpack dev server
|
||||
./bin/webpack-dev-server
|
||||
|
||||
# You can then run Gab Social with:
|
||||
bundle exec rails server
|
||||
```
|
||||
|
||||
## Managing your development environment
|
||||
|
||||
It is assumed that development hosts are not publicly accessible. For best security, there should be no route from a public network to your Gab Social development workstation.
|
||||
|
||||
By default, your development environment will have an admin account created for you to use - the email address will be `admin@YOURDOMAIN` (e.g. admin@localhost:3000) and the password will be `administrator`.
|
||||
|
||||
You can run tests with:
|
||||
|
||||
rspec
|
||||
|
||||
You can check localization status with:
|
||||
|
||||
i18n-tasks health
|
||||
|
||||
And update localization files after adding new strings with:
|
||||
|
||||
yarn manage:translations
|
||||
|
||||
You can check code quality with:
|
||||
|
||||
rubocop
|
||||
|
||||
## Federation development tips
|
||||
|
||||
Federation absolutely requires your Gab Social instance to have a domain name. If you want to operate a permanently-federated development server (Gab does), set up a [Gab Social](https://github.com/gab-ai-inc/gab-social) instance with a domain, and update it against your development fork/branch while doing that development on your local workstation or as a team.
|
||||
|
||||
To test federation on a *local* developer workstation, localhost => world tunneling can be made possible yourself on a domain you manage or by using services like [ngrok](https://ngrok.com).
|
||||
|
||||
Ngrok and similar services give you a random domain on each start up and iteration of your development build. This is good enough to test how the code you're working on handles real-world situations. But, your instance domain name is unique every time you run it.
|
||||
|
||||
For managing a production server, a service like Ngrok is the definition of Doing It Wrong™.
|
||||
|
||||
### Federation tips
|
||||
|
||||
Generally, federation is tricky to work on because it's hard to test. When you are testing with a disposable instance, you are polluting the database of the real server(s) you are testing against.
|
||||
|
||||
It is possible to use Ngrok for one session, record the exchanges from its web interface, and use that data to create fixtures and build test suites. From then on, the developer can continue working against the tests instead of live servers.
|
||||
|
||||
Study the code and RFCs before implementing federation features or changes.
|
||||
|
||||
### Remote Development
|
||||
|
||||
If the development environment is running remotely, setting the `REMOTE_DEV` environment variable will instruct your instance to use "letter opener web"
|
||||
|
||||
Letter Opener launches a local browser. Letter Opener Web collects emails and displays them at /letter_opener.
|
||||
562
docs/server.md
Normal file
562
docs/server.md
Normal file
@@ -0,0 +1,562 @@
|
||||
## Gab Social: Running A Server
|
||||
|
||||
**Disclaimer:**
|
||||
|
||||
This guide was written for [Ubuntu Server 18.04](https://www.ubuntu.com/server). You may run into issues if you are using another operating system.
|
||||
|
||||
It is assumed that you have technical knowledge and skills sufficient to administer Linux servers and scale them, if necessary. Gab Social communities that succeed have *no upper limit* to the maximum amount of users, posts, attachments, and problems related to operating publicly-accessible online communities at scale. Fortunately, Gab Social does not require you to operate at scale. You can run this server in single-user mode, which guarantees users complete ownership of all their data while still participating in the Gab Platform.
|
||||
|
||||
This document describes how to prepare a host for development, test, and production service.
|
||||
|
||||
## What is this guide?
|
||||
|
||||
This guide is a walk through of the setup process of a [Gab Social](https://github.com/gab-ai-inc/gab-social/) instance.
|
||||
|
||||
We use example.com to represent a domain or sub-domain. Example.com should be replaced with your instance domain or sub-domain.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
You will need the following for this guide:
|
||||
|
||||
- A server running [Ubuntu Server 18.04](https://www.ubuntu.com/server).
|
||||
- Root access to the server.
|
||||
- A domain or sub-domain to use for the instance.
|
||||
|
||||
## DNS
|
||||
|
||||
DNS records should be added before anything is done on the server.
|
||||
|
||||
The records added are:
|
||||
|
||||
- A record (IPv4 address) for example.com
|
||||
- AAAA record (IPv6 address) for example.com
|
||||
|
||||
> ### A Helpful And Optional Note
|
||||
>
|
||||
> Using `tmux` when following through with this guide will be helpful.
|
||||
>
|
||||
>
|
||||
> Not only will this help you not lose your place if you are disconnected, it will let you have multiple terminal windows open for switching contexts (root user versus the gabsocial user).
|
||||
>
|
||||
> You can install [tmux](https://github.com/tmux/tmux/wiki) from the package manager:
|
||||
>
|
||||
> ```sh
|
||||
> apt -y install tmux
|
||||
> ```
|
||||
|
||||
## Dependency Installation
|
||||
|
||||
All dependencies should be installed as root.
|
||||
|
||||
```sh
|
||||
sudo -i
|
||||
```
|
||||
|
||||
## Extend Ubuntu repositories when using Ubuntu 18.04.1 LTS
|
||||
|
||||
Starting with .1-release Ubuntu 18.04.1 LTS (not 18.04), Canonical has removed the multiverse, universe and restricted repository from the sources.list file in /etc/apt/. It is now necessary to add those repositories, otherwise the installation of the following dependencies will fail. Simply run the following commands:
|
||||
|
||||
```sh
|
||||
add-apt-repository universe
|
||||
add-apt-repository multiverse
|
||||
add-apt-repository restricted
|
||||
apt update
|
||||
```
|
||||
|
||||
#### Explanation of the dependencies
|
||||
|
||||
- imagemagick - Gab Social uses imagemagick for image related operations
|
||||
- ffmpeg - Gab Social uses ffmpeg for conversion of GIFs to MP4s
|
||||
- libprotobuf-dev and protobuf-compiler - Gab Social uses these for language detection
|
||||
- nginx - nginx is our frontend web server
|
||||
- redis-* - Gab Social uses redis for its in-memory data structure store
|
||||
- postgresql-* - Gab Social uses PostgreSQL as its SQL database
|
||||
- nodejs - Node is used for Gab Social's streaming API and other platform services
|
||||
- yarn - Yarn is a Node.js package manager
|
||||
- Other -dev packages, g++ - these are needed for the compilation of Ruby using ruby-build.
|
||||
|
||||
```sh
|
||||
apt -y install imagemagick ffmpeg libpq-dev libxml2-dev libxslt1-dev file git-core g++ libprotobuf-dev protobuf-compiler pkg-config gcc autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm5 libgdbm-dev nginx redis-server redis-tools postgresql postgresql-contrib certbot libidn11-dev libicu-dev
|
||||
```
|
||||
|
||||
### Dependencies That Need To Be Added As A Non-Root User
|
||||
|
||||
Let us create this user first:
|
||||
|
||||
```sh
|
||||
adduser gabsocial
|
||||
```
|
||||
|
||||
Log in as the `gabsocial` user:
|
||||
|
||||
|
||||
```sh
|
||||
sudo su - gabsocial
|
||||
```
|
||||
|
||||
#### Node Version Manager, Node.js, and Yarn
|
||||
|
||||
[Node Version Manager](https://github.com/nvm-sh/nvm) is a tool used for managing Node.js deployments. By convention at Gab, we only use Node.js as a standard user. No part of Node.js is managed or executed with superuser privileges. Those responsibilities are handled by Nginx later in this document.
|
||||
|
||||
```sh
|
||||
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
|
||||
```
|
||||
|
||||
Refresh your user session to pick up the environment changes added by `nvm`. Then, let's install Node.js v10.15.3LTS, verify that it was installed correctly, and install Yarn:
|
||||
|
||||
```sh
|
||||
# ask NVM to install 10.15.3LTS
|
||||
nvm install 10.15.3 --lts
|
||||
|
||||
# ask Node to print it's version number and exit.
|
||||
node --version
|
||||
|
||||
# (should display)
|
||||
v10.15.3
|
||||
|
||||
# Install Yarn, globally
|
||||
npm install -g yarn
|
||||
```
|
||||
|
||||
#### rbenv, Ruby, Rails, Rake
|
||||
|
||||
We will need to set up [`rbenv`](https://github.com/rbenv/rbenv) and [`ruby-build`](https://github.com/rbenv/ruby-build):
|
||||
|
||||
```sh
|
||||
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
|
||||
cd ~/.rbenv && src/configure && make -C src
|
||||
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
|
||||
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
|
||||
|
||||
# Restart shell
|
||||
exec bash
|
||||
|
||||
# Check if rbenv is correctly installed
|
||||
type rbenv
|
||||
|
||||
# Install ruby-build as rbenv plugin
|
||||
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
|
||||
```
|
||||
|
||||
Now that [`rbenv`](https://github.com/rbenv/rbenv) and [`ruby-build`](https://github.com/rbenv/ruby-build) are installed, we will install the
|
||||
[Ruby](https://www.ruby-lang.org/en/) version which [Gab Social](https://github.com/gab-ai-inc/gab-social) uses. That version will also need to be enabled.
|
||||
|
||||
To enable [Ruby](https://www.ruby-lang.org/en/), run:
|
||||
|
||||
```sh
|
||||
# We recommend watching videos on BitChute while this procedure
|
||||
# ruins your whole machine forever.
|
||||
rbenv install 2.6.1
|
||||
|
||||
# set the global RoR environment to version 2.6.1
|
||||
rbenv global 2.6.1
|
||||
```
|
||||
|
||||
### node.js And Ruby Dependencies
|
||||
|
||||
Now that [Ruby](https://www.ruby-lang.org/en/) is enabled, we will clone the [Gab Social git repository](https://github.com/gab-ai-inc/gab-social/) and install the [Ruby](https://www.ruby-lang.org/en/) and [node.js](https://nodejs.org/en/) dependancies.
|
||||
|
||||
Run the following to clone and install:
|
||||
|
||||
```sh
|
||||
# Return to gabsocial user's home directory
|
||||
cd ~
|
||||
|
||||
# Clone the gabsocial git repository into ~/live
|
||||
git clone https://github.com/gab-ai-inc/gab-social.git live
|
||||
|
||||
# Or, clone the developer version (requires credentials)
|
||||
git clone git@dev.openplatform.us:/opt/git/gab-social live
|
||||
|
||||
# Change directory to ~/live
|
||||
cd ~/live
|
||||
|
||||
# Checkout to the latest stable branch
|
||||
git checkout $(git tag -l | grep -v 'rc[0-9]*$' | sort -V | tail -n 1)
|
||||
|
||||
# Install bundler
|
||||
gem install bundler
|
||||
|
||||
# Use bundler to install the rest of the Ruby dependencies
|
||||
bundle install -j$(getconf _NPROCESSORS_ONLN) --deployment --without development test
|
||||
|
||||
# Use yarn to install node.js dependencies
|
||||
yarn install --pure-lockfile
|
||||
```
|
||||
|
||||
That is all we need to do for now with the `gabsocial` user, you can now `exit` back to root.
|
||||
|
||||
If you plan on deploying more than one front-end app server, you may want to consider using a host image once you are done setting up all dependencies. That `rbenv install 2.6.1` command only gets intensely worse on anemic shared cloud hosts, and the `bundle install` nonsense is just out of control.
|
||||
|
||||
The remainder of the setup procedure is quick (esp. when automated). If you want to leave the rest of your setup dynamic, now is really the right time to snapshot the host. You will save yourself a lot of deployment time in the days and months to come.
|
||||
|
||||
Eventually, the Ruby On Rails dependencies are going away. This is a stop-gap solution while we continue our migration to a Gab-native implementation of ActivityPub/GNU Social on HYDRA.
|
||||
|
||||
## PostgreSQL Database Creation
|
||||
|
||||
[Gab Social](https://github.com/gab-ai-inc/gab-social) requires access to a [PostgreSQL](https://www.postgresql.org) instance.
|
||||
|
||||
Create a user for a [PostgreSQL](https://www.postgresql.org) instance:
|
||||
|
||||
```
|
||||
# Launch psql as the postgres user
|
||||
sudo -u postgres psql
|
||||
|
||||
# In the following prompt
|
||||
CREATE USER gabsocial CREATEDB;
|
||||
\q
|
||||
```
|
||||
|
||||
**Note** that we do not set up a password of any kind, this is because we will be using ident authentication. This allows local users to access the database without a password.
|
||||
|
||||
## nginx Configuration
|
||||
|
||||
You need to configure [nginx](http://nginx.org) to serve your [Gab Social](https://github.com/gab-ai-inc/gab-social/) instance.
|
||||
|
||||
**Reminder: Replace all occurrences of example.com with your own instance's domain or sub-domain.**
|
||||
|
||||
`cd` to `/etc/nginx/sites-available` and open a new file:
|
||||
|
||||
`nano /etc/nginx/sites-available/example.com.conf`
|
||||
|
||||
Copy and paste the following and make edits as necessary:
|
||||
|
||||
```nginx
|
||||
map $http_upgrade $connection_upgrade {
|
||||
default upgrade;
|
||||
'' close;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
listen [::]:80;
|
||||
server_name example.com;
|
||||
root /home/gabsocial/live/public;
|
||||
# Useful for Let's Encrypt
|
||||
location /.well-known/acme-challenge/ { allow all; }
|
||||
location / { return 301 https://$host$request_uri; }
|
||||
}
|
||||
|
||||
server {
|
||||
listen 443 ssl http2;
|
||||
listen [::]:443 ssl http2;
|
||||
server_name example.com;
|
||||
|
||||
ssl_protocols TLSv1.2;
|
||||
ssl_ciphers HIGH:!MEDIUM:!LOW:!aNULL:!NULL:!SHA;
|
||||
ssl_prefer_server_ciphers on;
|
||||
ssl_session_cache shared:SSL:10m;
|
||||
|
||||
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
|
||||
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
|
||||
|
||||
keepalive_timeout 70;
|
||||
sendfile on;
|
||||
client_max_body_size 80m;
|
||||
|
||||
root /home/gabsocial/live/public;
|
||||
|
||||
gzip on;
|
||||
gzip_disable "msie6";
|
||||
gzip_vary on;
|
||||
gzip_proxied any;
|
||||
gzip_comp_level 6;
|
||||
gzip_buffers 16 8k;
|
||||
gzip_http_version 1.1;
|
||||
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
|
||||
|
||||
add_header Strict-Transport-Security "max-age=31536000";
|
||||
|
||||
location / {
|
||||
try_files $uri @proxy;
|
||||
}
|
||||
|
||||
location ~ ^/(emoji|packs|system/accounts/avatars|system/media_attachments/files) {
|
||||
add_header Cache-Control "public, max-age=31536000, immutable";
|
||||
try_files $uri @proxy;
|
||||
}
|
||||
|
||||
location /sw.js {
|
||||
add_header Cache-Control "public, max-age=0";
|
||||
try_files $uri @proxy;
|
||||
}
|
||||
|
||||
location @proxy {
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto https;
|
||||
proxy_set_header Proxy "";
|
||||
proxy_pass_header Server;
|
||||
|
||||
proxy_pass http://127.0.0.1:3000;
|
||||
proxy_buffering off;
|
||||
proxy_redirect off;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection $connection_upgrade;
|
||||
|
||||
tcp_nodelay on;
|
||||
}
|
||||
|
||||
location /api/v1/streaming {
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto https;
|
||||
proxy_set_header Proxy "";
|
||||
|
||||
proxy_pass http://127.0.0.1:4000;
|
||||
proxy_buffering off;
|
||||
proxy_redirect off;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection $connection_upgrade;
|
||||
|
||||
tcp_nodelay on;
|
||||
}
|
||||
|
||||
error_page 500 501 502 503 504 /500.html;
|
||||
}
|
||||
```
|
||||
|
||||
Activate the [nginx](http://nginx.org) configuration added:
|
||||
|
||||
```sh
|
||||
cd /etc/nginx/sites-enabled
|
||||
ln -s ../sites-available/example.com.conf
|
||||
```
|
||||
|
||||
This configuration makes the assumption you are using [Let's Encrypt](https://letsencrypt.org) as your TLS certificate provider.
|
||||
|
||||
**If you are going to be using Let's Encrypt as your TLS certificate provider, see the
|
||||
next sub-section. If not edit the `ssl_certificate` and `ssl_certificate_key` values
|
||||
accordingly.**
|
||||
|
||||
## Let's Encrypt
|
||||
|
||||
This section is only relevant if you are using [Let's Encrypt](https://letsencrypt.org/)
|
||||
as your TLS certificate provider.
|
||||
|
||||
### Generation Of The Certificate
|
||||
|
||||
We need to generate Let's Encrypt certificates.
|
||||
|
||||
**Make sure to replace any occurrence of 'example.com' with your Gab Social instance's domain.**
|
||||
|
||||
Make sure that [nginx](http://nginx.org) is stopped at this point:
|
||||
|
||||
```sh
|
||||
systemctl stop nginx
|
||||
```
|
||||
|
||||
We will be creating the certificate twice, once with TLS SNI validation in standalone mode and the second time we will be using the webroot method. This is required due to the way
|
||||
[nginx](http://nginx.org) and the [Let's Encrypt](https://letsencrypt.org/) tool works.
|
||||
|
||||
```sh
|
||||
certbot certonly --standalone -d example.com
|
||||
```
|
||||
|
||||
After that successfully completes, we will use the webroot method. This requires [nginx](http://nginx.org) to be running:
|
||||
|
||||
```sh
|
||||
systemctl start nginx
|
||||
# The certbot tool will ask if you want to keep the existing certificate or renew it. Choose to renew it.
|
||||
certbot certonly --webroot -d example.com -w /home/gabsocial/live/public/
|
||||
```
|
||||
|
||||
### Automated Renewal Of Let's Encrypt Certificate
|
||||
|
||||
[Let's Encrypt](https://letsencrypt.org/) certificates have a validity period of 90 days.
|
||||
|
||||
You need to renew your certificate before the expiration date. Not doing so will make users of your instance unable to access the instance and users of other instances unable to federate with yours.
|
||||
|
||||
We can create a cron job that runs daily to do this:
|
||||
|
||||
```sh
|
||||
nano /etc/cron.daily/letsencrypt-renew
|
||||
```
|
||||
|
||||
Copy and paste this script into that file:
|
||||
|
||||
```sh
|
||||
#!/usr/bin/env bash
|
||||
certbot renew
|
||||
systemctl reload nginx
|
||||
```
|
||||
|
||||
Save and exit the file.
|
||||
|
||||
Make the script executable and restart the cron daemon so that the script runs daily:
|
||||
|
||||
```sh
|
||||
chmod +x /etc/cron.daily/letsencrypt-renew
|
||||
systemctl restart cron
|
||||
```
|
||||
|
||||
That is it. Your server will renew your [Let's Encrypt](https://letsencrypt.org/) certificate.
|
||||
|
||||
## Gab Social Application Configuration
|
||||
|
||||
We will configure the Gab Social application.
|
||||
|
||||
For this we will switch to the `gabsocial` system user:
|
||||
|
||||
|
||||
```sh
|
||||
sudo su - gabsocial
|
||||
```
|
||||
|
||||
Change directory to `~/live` and run the [Gab Social](https://github.com/gab-ai-inc/gab-social) setup wizard:
|
||||
|
||||
```sh
|
||||
cd ~/live
|
||||
RAILS_ENV=production bundle exec rake gabsocial:setup
|
||||
```
|
||||
|
||||
If upgrading:
|
||||
|
||||
```sh
|
||||
cd ~/live
|
||||
RAILS_ENV=production rails assets:precompile
|
||||
```
|
||||
|
||||
The interactive wizard will guide you through basic and necessary options, generate new app secrets, setup the database schema and precompile the assets.
|
||||
|
||||
**The assets precompilation takes a couple minutes, so this is a good time to take another break.**
|
||||
|
||||
## Gab Social systemd Service Files
|
||||
|
||||
We will need three [systemd](https://github.com/systemd/systemd) service files for each Gab Social service.
|
||||
|
||||
Now switch back to the root user.
|
||||
|
||||
For the [Gab Social](https://github.com/gab-ai-inc/gab-social/) web workers service place the following in `/etc/systemd/system/gabsocial-web.service`:
|
||||
|
||||
```
|
||||
[Unit]
|
||||
Description=gabsocial-web
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=gabsocial
|
||||
WorkingDirectory=/home/gabsocial/live
|
||||
Environment="RAILS_ENV=production"
|
||||
Environment="PORT=3000"
|
||||
ExecStart=/home/gabsocial/.rbenv/shims/bundle exec puma -C config/puma.rb
|
||||
ExecReload=/bin/kill -SIGUSR1 $MAINPID
|
||||
TimeoutSec=15
|
||||
Restart=always
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
```
|
||||
|
||||
For [Gab Social](https://github.com/gab-ai-inc/gab-social/) background queue service, place the following in `/etc/systemd/system/gabsocial-sidekiq.service`:
|
||||
|
||||
```
|
||||
[Unit]
|
||||
Description=gabsocial-sidekiq
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=gabsocial
|
||||
WorkingDirectory=/home/gabsocial/live
|
||||
Environment="RAILS_ENV=production"
|
||||
Environment="DB_POOL=5"
|
||||
ExecStart=/home/gabsocial/.rbenv/shims/bundle exec sidekiq -c 5 -q default -q push -q mailers -q pull
|
||||
TimeoutSec=15
|
||||
Restart=always
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
```
|
||||
|
||||
For the [Gab Social](https://github.com/gab-ai-inc/gab-social/) streaming API service place the following in `/etc/systemd/system/gabsocial-streaming.service`:
|
||||
|
||||
```
|
||||
[Unit]
|
||||
Description=gabsocial-streaming
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=gabsocial
|
||||
WorkingDirectory=/home/gabsocial/live
|
||||
Environment="NODE_ENV=production"
|
||||
Environment="PORT=4000"
|
||||
ExecStart=/usr/bin/npm run start
|
||||
TimeoutSec=15
|
||||
Restart=always
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
```
|
||||
|
||||
Now you need to enable all of these services:
|
||||
|
||||
```sh
|
||||
systemctl enable /etc/systemd/system/gabsocial-*.service
|
||||
```
|
||||
|
||||
Now start the services:
|
||||
|
||||
```sh
|
||||
systemctl start gabsocial-*.service
|
||||
```
|
||||
|
||||
Check that they are properly running:
|
||||
|
||||
```sh
|
||||
systemctl status gabsocial-*.service
|
||||
```
|
||||
|
||||
## Remote media attachment cache cleanup
|
||||
|
||||
Gab Social downloads media attachments from other instances and caches it locally for viewing. This cache can grow quite large if not cleaned up periodically and can cause issues such as low disk space or a bloated S3 bucket.
|
||||
|
||||
The recommended method to clean up the remote media cache is a cron job that runs daily like so (put this in the gabsocial system user's crontab with `crontab -e`.)
|
||||
|
||||
```sh
|
||||
RAILS_ENV=production
|
||||
@daily cd /home/gabsocial/live && /home/gabsocial/.rbenv/shims/bundle exec rake gabsocial:media:remove_remote
|
||||
```
|
||||
|
||||
That rake task removes cached remote media attachments that are older than NUM_DAYS, NUM_DAYS defaults to 7 days (1 week) if not specified. NUM_DAYS is another environment variable so you can specify it like so:
|
||||
|
||||
```sh
|
||||
RAILS_ENV=production
|
||||
NUM_DAYS=14
|
||||
@daily cd /home/gabsocial/live && /home/gabsocial/.rbenv/shims/bundle exec rake gabsocial:media:remove_remote
|
||||
```
|
||||
|
||||
## Email Service
|
||||
|
||||
If you plan on receiving email notifications or running more than just a single-user instance, you likely will want to get set up with an email provider.
|
||||
|
||||
There are several free email providers out there- a couple of decent ones are Mailgun.com, which requires a credit card but gives 10,000 free emails, and Sparkpost.com, which gives 15,000 with no credit card but requires you not be on a .space tld.
|
||||
|
||||
It may be easier to use a subdomain to setup your email with a custom provider - in this case, when registering your domain with the email service, sign up as something like "mail.domain.com"
|
||||
|
||||
Once you create your account, follow the instructions each provider gives you for updating your DNS records. Once you have all the information ready to go and the service validates your DNS configuration, edit your config file. These records should already exist in the configuration, but here's a sample setup that uses Mailgun that you can replace with your own personal info:
|
||||
|
||||
```
|
||||
SMTP_SERVER=smtp.mailgun.org
|
||||
SMTP_PORT=587
|
||||
SMTP_LOGIN=anAccountThatIsntPostmaster@gabsocial.domain.com
|
||||
SMTP_PASSWORD=HolySnacksAPassword
|
||||
SMTP_FROM_ADDRESS=Domain.com Gab Social Admin <notifications@gab.com>
|
||||
```
|
||||
|
||||
Finally, to test this, spin up a Rails console (see [the administration guide](https://github.com/gab-ai-inc/gab-social-documentation/blob/master/Running-Gab-Social/Administration-guide.md)) and run the following commands to test this out:
|
||||
|
||||
```ruby
|
||||
m = UserMailer.new.mail to:'email@address.com', subject: 'test', body: 'awoo'
|
||||
m.deliver
|
||||
```
|
||||
|
||||
That is all! If everything was done correctly, a [Gab Social](https://github.com/gab-ai-inc/gab-social/) instance will appear when you visit `https://example.com` in a web browser.
|
||||
|
||||
Congratulations and welcome to Gab Social!
|
||||
53
docs/wkhtmltopdf-deps.txt
Normal file
53
docs/wkhtmltopdf-deps.txt
Normal file
@@ -0,0 +1,53 @@
|
||||
# WK<HTML>TOPDF
|
||||
|
||||
[wkhtmltopdf](https://wkhtmltopdf.org/) is an open source (LGPLv3) command line tool to render HTML to PDF and various image formats using the Qt WebKit rendering engine. It is a required dependency that enables Gab Social to create PDF documents as downloadable invoices for purchases made during the Gab PRO upgrade and subscription process.
|
||||
|
||||
This is not a light dependency and is potentially pulling a lot of code into your production environment.
|
||||
|
||||
As of this writing on Ubuntu 18.04LTS, enabling subscriptions and payments requires the following additional packages to be installed:
|
||||
|
||||
adwaita-icon-theme amd64-microcode at-spi2-core avahi-daemon crda dconf-gsettings-backend dconf-service fontconfig geoclue-2.0 glib-networking glib-networking-common glib-networking-services
|
||||
gsettings-desktop-schemas gstreamer1.0-plugins-base gtk-update-icon-cache hicolor-icon-theme humanity-icon-theme iio-sensor-proxy intel-microcode iucode-tool iw libatk-bridge2.0-0 libatk1.0-0 libatk1.0-data
|
||||
libatspi2.0-0 libavahi-client3 libavahi-common-data libavahi-common3 libavahi-core7 libavahi-glib1 libbrotli1 libcairo-gobject2 libcairo2 libcdparanoia0 libcolord2 libcroco3 libcups2 libdaemon0 libdatrie1
|
||||
libdbus-glib-1-2 libdconf1 libdouble-conversion1 libdrm-amdgpu1 libdrm-intel1 libdrm-nouveau2 libdrm-radeon1 libegl-mesa0 libegl1 libepoxy0 libevdev2 libfontenc1 libgbm1 libgdk-pixbuf2.0-0
|
||||
libgdk-pixbuf2.0-bin libgdk-pixbuf2.0-common libgeoclue-2-0 libgl1 libgl1-mesa-dri libgl1-mesa-glx libglapi-mesa libglvnd0 libglx-mesa0 libglx0 libgstreamer-plugins-base1.0-0 libgstreamer1.0-0 libgtk-3-0
|
||||
libgtk-3-bin libgtk-3-common libgudev-1.0-0 libhyphen0 libice6 libinput-bin libinput10 libjson-glib-1.0-0 libjson-glib-1.0-common liblcms2-2 libllvm7 libmbim-glib4 libmbim-proxy libmm-glib0 libmtdev1
|
||||
libnl-3-200 libnl-genl-3-200 libnss-mdns libogg0 libopus0 liborc-0.4-0 libpango-1.0-0 libpangocairo-1.0-0 libpangoft2-1.0-0 libpciaccess0 libpcsclite1 libpixman-1-0 libproxy1v5 libqmi-glib5 libqmi-proxy
|
||||
libqt5core5a libqt5dbus5 libqt5gui5 libqt5network5 libqt5positioning5 libqt5printsupport5 libqt5qml5 libqt5quick5 libqt5sensors5 libqt5svg5 libqt5webchannel5 libqt5webkit5 libqt5widgets5 librest-0.7-0
|
||||
librsvg2-2 librsvg2-common libsm6 libsoup-gnome2.4-1 libsoup2.4-1 libthai-data libthai0 libtheora0 libvisual-0.4-0 libvorbis0a libvorbisenc2 libwacom-bin libwacom-common libwacom2 libwayland-client0
|
||||
libwayland-cursor0 libwayland-egl1 libwayland-server0 libwoff1 libx11-xcb1 libxatracker2 libxaw7 libxcb-dri2-0 libxcb-dri3-0 libxcb-glx0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-present0
|
||||
libxcb-randr0 libxcb-render-util0 libxcb-render0 libxcb-shape0 libxcb-shm0 libxcb-sync1 libxcb-util1 libxcb-xfixes0 libxcb-xinerama0 libxcb-xkb1 libxcomposite1 libxcursor1 libxdamage1 libxfixes3 libxfont2
|
||||
libxi6 libxinerama1 libxkbcommon-x11-0 libxkbcommon0 libxkbfile1 libxmu6 libxrandr2 libxrender1 libxshmfence1 libxss1 libxt6 libxtst6 libxv1 libxvmc1 libxxf86vm1 linux-firmware linux-generic-hwe-18.04
|
||||
linux-headers-4.18.0-20 linux-headers-4.18.0-20-generic linux-headers-generic-hwe-18.04 linux-image-4.18.0-20-generic linux-image-generic-hwe-18.04 linux-modules-4.18.0-20-generic
|
||||
linux-modules-extra-4.18.0-20-generic modemmanager qt5-gtk-platformtheme qttranslations5-l10n thermald ubuntu-mono usb-modeswitch usb-modeswitch-data wireless-regdb wpasupplicant x11-common x11-xkb-utils
|
||||
xfonts-base xfonts-encodings xfonts-utils xserver-common xserver-xorg-core-hwe-18.04 xserver-xorg-hwe-18.04 xserver-xorg-input-all-hwe-18.04 xserver-xorg-input-libinput-hwe-18.04
|
||||
xserver-xorg-input-wacom-hwe-18.04 xserver-xorg-legacy-hwe-18.04 xserver-xorg-video-all-hwe-18.04 xserver-xorg-video-amdgpu-hwe-18.04 xserver-xorg-video-ati-hwe-18.04 xserver-xorg-video-fbdev-hwe-18.04
|
||||
xserver-xorg-video-intel-hwe-18.04 xserver-xorg-video-nouveau-hwe-18.04 xserver-xorg-video-qxl-hwe-18.04 xserver-xorg-video-radeon-hwe-18.04 xserver-xorg-video-vesa-hwe-18.04
|
||||
xserver-xorg-video-vmware-hwe-18.04
|
||||
|
||||
Suggested packages will be:
|
||||
|
||||
avahi-autoipd gvfs colord cups-common libvisual-0.4-plugins gstreamer1.0-tools liblcms2-utils avahi-autoipd | zeroconf opus-tools pcscd qt5-image-formats-plugins qtwayland5 qt5-qmltooling-plugins
|
||||
librsvg2-bin fdutils linux-hwe-doc-4.18.0 | linux-hwe-source-4.18.0 linux-hwe-tools comgt wvdial wpagui libengine-pkcs11-openssl xfonts-100dpi | xfonts-75dpi xfonts-scalable xinput firmware-amd-graphics
|
||||
xserver-xorg-video-r128 xserver-xorg-video-mach64 firmware-misc-nonfree
|
||||
|
||||
And, the following NEW packages will be installed:
|
||||
|
||||
adwaita-icon-theme amd64-microcode at-spi2-core avahi-daemon crda dconf-gsettings-backend dconf-service fontconfig geoclue-2.0 glib-networking glib-networking-common glib-networking-services
|
||||
gsettings-desktop-schemas gstreamer1.0-plugins-base gtk-update-icon-cache hicolor-icon-theme humanity-icon-theme iio-sensor-proxy intel-microcode iucode-tool iw libatk-bridge2.0-0 libatk1.0-0 libatk1.0-data
|
||||
libatspi2.0-0 libavahi-client3 libavahi-common-data libavahi-common3 libavahi-core7 libavahi-glib1 libbrotli1 libcairo-gobject2 libcairo2 libcdparanoia0 libcolord2 libcroco3 libcups2 libdaemon0 libdatrie1
|
||||
libdbus-glib-1-2 libdconf1 libdouble-conversion1 libdrm-amdgpu1 libdrm-intel1 libdrm-nouveau2 libdrm-radeon1 libegl-mesa0 libegl1 libepoxy0 libevdev2 libfontenc1 libgbm1 libgdk-pixbuf2.0-0
|
||||
libgdk-pixbuf2.0-bin libgdk-pixbuf2.0-common libgeoclue-2-0 libgl1 libgl1-mesa-dri libgl1-mesa-glx libglapi-mesa libglvnd0 libglx-mesa0 libglx0 libgstreamer-plugins-base1.0-0 libgstreamer1.0-0 libgtk-3-0
|
||||
libgtk-3-bin libgtk-3-common libgudev-1.0-0 libhyphen0 libice6 libinput-bin libinput10 libjson-glib-1.0-0 libjson-glib-1.0-common liblcms2-2 libllvm7 libmbim-glib4 libmbim-proxy libmm-glib0 libmtdev1
|
||||
libnl-3-200 libnl-genl-3-200 libnss-mdns libogg0 libopus0 liborc-0.4-0 libpango-1.0-0 libpangocairo-1.0-0 libpangoft2-1.0-0 libpciaccess0 libpcsclite1 libpixman-1-0 libproxy1v5 libqmi-glib5 libqmi-proxy
|
||||
libqt5core5a libqt5dbus5 libqt5gui5 libqt5network5 libqt5positioning5 libqt5printsupport5 libqt5qml5 libqt5quick5 libqt5sensors5 libqt5svg5 libqt5webchannel5 libqt5webkit5 libqt5widgets5 librest-0.7-0
|
||||
librsvg2-2 librsvg2-common libsm6 libsoup-gnome2.4-1 libsoup2.4-1 libthai-data libthai0 libtheora0 libvisual-0.4-0 libvorbis0a libvorbisenc2 libwacom-bin libwacom-common libwacom2 libwayland-client0
|
||||
libwayland-cursor0 libwayland-egl1 libwayland-server0 libwoff1 libx11-xcb1 libxatracker2 libxaw7 libxcb-dri2-0 libxcb-dri3-0 libxcb-glx0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-present0
|
||||
libxcb-randr0 libxcb-render-util0 libxcb-render0 libxcb-shape0 libxcb-shm0 libxcb-sync1 libxcb-util1 libxcb-xfixes0 libxcb-xinerama0 libxcb-xkb1 libxcomposite1 libxcursor1 libxdamage1 libxfixes3 libxfont2
|
||||
libxi6 libxinerama1 libxkbcommon-x11-0 libxkbcommon0 libxkbfile1 libxmu6 libxrandr2 libxrender1 libxshmfence1 libxss1 libxt6 libxtst6 libxv1 libxvmc1 libxxf86vm1 linux-firmware linux-generic-hwe-18.04
|
||||
linux-headers-4.18.0-20 linux-headers-4.18.0-20-generic linux-headers-generic-hwe-18.04 linux-image-4.18.0-20-generic linux-image-generic-hwe-18.04 linux-modules-4.18.0-20-generic
|
||||
linux-modules-extra-4.18.0-20-generic modemmanager qt5-gtk-platformtheme qttranslations5-l10n thermald ubuntu-mono usb-modeswitch usb-modeswitch-data wireless-regdb wkhtmltopdf wpasupplicant x11-common
|
||||
x11-xkb-utils xfonts-base xfonts-encodings xfonts-utils xserver-common xserver-xorg-core-hwe-18.04 xserver-xorg-hwe-18.04 xserver-xorg-input-all-hwe-18.04 xserver-xorg-input-libinput-hwe-18.04
|
||||
xserver-xorg-input-wacom-hwe-18.04 xserver-xorg-legacy-hwe-18.04 xserver-xorg-video-all-hwe-18.04 xserver-xorg-video-amdgpu-hwe-18.04 xserver-xorg-video-ati-hwe-18.04 xserver-xorg-video-fbdev-hwe-18.04
|
||||
xserver-xorg-video-intel-hwe-18.04 xserver-xorg-video-nouveau-hwe-18.04 xserver-xorg-video-qxl-hwe-18.04 xserver-xorg-video-radeon-hwe-18.04 xserver-xorg-video-vesa-hwe-18.04
|
||||
xserver-xorg-video-vmware-hwe-18.04
|
||||
Reference in New Issue
Block a user