trashposs/docs/install.md

176 lines
6.4 KiB
Markdown
Raw Permalink Normal View History

2024-04-06 22:37:46 +02:00
# Installing TrashPoss
2024-04-06 23:55:59 +02:00
This document will guide you through manual installation of TrashPoss. We also provide prebuilt [packages](/trashposs/packaging) for various platforms, should you prefer those over a manual install.
2023-08-09 20:46:48 +02:00
## Dependencies
### Build
2023-08-09 20:46:48 +02:00
- C/C++ compiler like **GCC** or **Clang**
- Build tools like **make**
- **Python 3**
### Required
2023-08-09 20:46:48 +02:00
- [**Node.js**](https://nodejs.org) v18.16.0+ (v20 recommended)
- [**PostgreSQL**](https://www.postgresql.org/) 12+ (including modules, usually packaged as postgresql-contrib)
2023-08-10 20:58:16 +02:00
- [**Redis**](https://redis.io/) 6+
2023-08-09 20:46:48 +02:00
- [**libvips**](https://www.libvips.org/)
- **Web proxy**
- nginx
- Caddy
### Optional
2023-08-09 20:46:48 +02:00
- [**FFmpeg**](https://ffmpeg.org/) for video transcoding
## Preparations
### Download repository
Make sure you have `git-lfs` installed and have run `git lfs install` before cloning the repo, as we are using Git LFS for efficient storage of binary blobs.
2023-11-08 15:59:52 +01:00
2023-08-09 20:46:48 +02:00
```sh
2024-04-06 22:37:46 +02:00
git clone https://iceshrimp.dev/Crimekillz/trashposs.git
2023-08-09 20:46:48 +02:00
```
2024-04-06 22:37:46 +02:00
If you don't want to run the latest development version, pick a version from [here](https://iceshrimp.dev/Crimekillz/trashposs/releases) and run `git checkout <version>` before continuing.
2023-11-07 01:53:25 +01:00
2023-08-09 20:46:48 +02:00
### Creating a new user
2024-04-06 23:55:59 +02:00
In case you want to run TrashPoss as a different user, run `adduser --disabled-password --disabled-login trashposs`
Following steps will require you to run them as the user you have made, so use `su - trashposs`, or `sudo -iu trashposs`, or whatever else method in order to temporarily log in as that user.
2023-08-09 20:46:48 +02:00
### Configuration
2023-08-09 20:46:48 +02:00
- Copy `.config/example.yml` to `.config/default.yml`
- Edit `.config/default.yml` with text editor
- Make sure to set PostgreSQL and Redis section correctly
## Installing project dependencies
This project uses corepack to manage yarn versions, please make sure you don't have a globally installed non-corepack yarn binary (e.g. by having run `npm install -g yarn` in the past, or via your operating system's package manager)
2023-08-09 20:46:48 +02:00
```sh
corepack enable
corepack prepare --activate
2023-08-09 20:46:48 +02:00
yarn
```
Note: If you get a lot of `The remote archive doesn't match the expected checksum` errors, please make sure you installed `git-lfs` and ran `git lfs install && git lfs pull`.
2023-11-08 15:59:52 +01:00
2024-04-06 22:37:46 +02:00
## Building TrashPoss
2023-08-09 20:46:48 +02:00
```sh
yarn build
```
## Database
2023-08-09 20:46:48 +02:00
### Creating database
2023-08-09 20:46:48 +02:00
This will create a postgres user with your password and database, while also granting that user all privileges on database.
Using `psql` prompt:
```sh
sudo -u postgres psql
```
```postgresql
2024-04-06 23:55:59 +02:00
create database trashposs with encoding = 'UTF8';
create user trashposs with encrypted password '{YOUR_PASSWORD}';
grant all privileges on database trashposs to trashposs;
alter database trashposs owner to trashposs;
2023-08-09 20:46:48 +02:00
\q
```
### First migration
2024-04-06 22:37:46 +02:00
In order for TrashPoss to work properly, you need to initialise the database using
2023-08-09 20:46:48 +02:00
```bash
yarn run init
```
### Optimizing performance
2024-04-06 22:37:46 +02:00
If you are running TrashPoss on a system with more than one CPU thread, you might want to set the `clusterLimit` config option to about half of your thread count, depending on your system configuration. Please note that each worker requires around 10 PostgreSQL connections, so be sure to set `max_connections` appropriately (aim for `(10 * no_workers) + 10`, if you have no other applications accessing the PostgreSQL database).
For optimal database performance, it's highly recommended to configure PostgreSQL with [PGTune](https://pgtune.leopard.in.ua/) using the "Mixed type of application" profile. This is especially important should your database server use HDD instead of SATA or NVMe SSD storage.
2023-08-09 20:46:48 +02:00
## Setting up Webproxy
2023-08-09 20:46:48 +02:00
### Nginx
2024-04-06 23:55:59 +02:00
- Run `sudo cp docs/examples/trashposs.nginx.conf /etc/nginx/sites-available/ && cd /etc/nginx/sites-available/`
- Edit `trashposs.nginx.conf` to reflect your server properly
- Run `sudo ln -s ./trashposs.nginx.conf ../sites-enabled/trashposs.nginx.conf`
2023-08-09 20:46:48 +02:00
- Run `sudo nginx -t` to check that the config is valid, then restart the nginx service.
### Caddy
2023-08-09 20:46:48 +02:00
- Add the following to your Caddyfile, and replace `example.com` with your domain
```
example.com {
reverse_proxy localhost:3000
}
```
2024-04-06 22:37:46 +02:00
## Running TrashPoss
2023-08-09 20:46:48 +02:00
### Running manually
2024-04-06 22:37:46 +02:00
- Start TrashPoss by running `NODE_ENV=production yarn run start`.
If this is your first run, after TrashPoss has started successfully, you'll be able to go to the URL you have specified in `.config/default.yml` and create first user.
2023-08-09 20:46:48 +02:00
- To stop the server, use `Ctrl-C`.
### Running using systemd
2024-04-06 23:55:59 +02:00
- Run `sudo cp docs/examples/trashposs.service /etc/systemd/system/`
- Edit `/etc/systemd/system/trashposs.service` with text editor, and change `User`, `WorkingDir`, `ExecStart` if necessary.
2023-08-09 20:46:48 +02:00
- Run `sudo systemctl daemon-reload`
2024-04-06 23:55:59 +02:00
- Run `sudo systemctl enable --now trashposs` in order to enable and start TrashPoss.
- (Optional) Check if instance is running using `sudo systemctl status trashposs`
2023-08-09 20:46:48 +02:00
### Environment variables
- `ICESHRIMP_CONFIG` (default: `.config/default.yml`) to change where the the config file is located
- `ICESHRIMP_SECRETS` (default: unset) if you want to keep your secrets in a separate config file
- `ICESHRIMP_MEDIA_DIR` (default: `files`) to change where internally stored files are located
- `ICESHRIMP_CUSTOM_DIR` (default: `custom`) to change where custom assets and locales are located (caution: assets are copied at build time or when running `yarn gulp`, not during startup!)
Make sure you are specifying absolute paths when setting environment variables.
2024-04-06 22:37:46 +02:00
### Updating TrashPoss
2024-04-06 23:55:59 +02:00
Before you start, if you cloned the trashposs repository before the Git LFS migration, please follow [these instructions](https://iceshrimp.dev/Crimekillz/trashposs/wiki/Git-LFS#fixing-up-a-preexisting-cloned-repo) to get your repository back in sync.
2023-11-08 15:59:52 +01:00
2024-04-06 22:37:46 +02:00
First, stop the TrashPoss service and then run the following commands:
2023-08-09 20:46:48 +02:00
```sh
2023-08-10 20:58:16 +02:00
## Run git stash commands only if you have uncommitted changes
2023-08-09 20:46:48 +02:00
git stash
2023-11-07 01:53:25 +01:00
```
If you were previously running a tagged release and/or want to upgrade to one, run:
```sh
git fetch --tags
git checkout <new-version>
```
If you were previously running a development version, and want to continue doing so or switch to the latest commit, run:
```sh
git switch dev
2023-08-09 20:46:48 +02:00
git pull
2023-11-07 01:53:25 +01:00
```
Regardless of which of the above you picked, run:
```sh
2023-08-09 20:46:48 +02:00
git stash pop
yarn
2023-08-10 20:58:16 +02:00
yarn build && yarn migrate
2023-08-09 20:46:48 +02:00
```
Note: If you get a lot of `The remote archive doesn't match the expected checksum` errors, please make sure you installed `git-lfs` and ran `git lfs install && git lfs pull`.
2023-11-08 15:59:52 +01:00
2024-04-06 22:37:46 +02:00
Now restart the TrashPoss service and everything should be up to date.
2023-08-09 20:46:48 +02:00
## Post-install
2023-08-09 20:46:48 +02:00
See [post-install](post-install.md).