My own modifications. Enjoy!

- Bronze
This commit is contained in:
2023-08-13 01:50:00 -04:00
parent 8fb03c885c
commit 3e64b4b2dd
13 changed files with 224 additions and 182 deletions

148
README.md
View File

@ -6,18 +6,9 @@ It actually consists of two components: a backend, named simply Pleroma, and a u
Its main advantages are its lightness and speed.
![Pleroma](https://i.imgur.com/VftiTlR.png)
## Why Docker?
_Pleromians trying to understand the memes_
## Features
- Based on the elixir:alpine image
- Ran as an unprivileged user
- It works great
Sadly, this is not a reusable (e.g. I can't upload it to the Docker Hub), because for now Pleroma needs to compile the configuration. 😢
Thus you will need to build the image yourself, but I explain how to do it below.
Boxing up Pleroma in a docker container allows it to be portable, and keeps your host system clean. The software and its dependencies will all be under the `pleroma_web` container (created with the lightweight elixir:alpine base image) while its postgres database will live under `pleroma_db` image. Only port 4000 will be exposed under localhost.
## Build-time variables
@ -29,140 +20,63 @@ Thus you will need to build the image yourself, but I explain how to do it below
### Installation
Create a folder for your Pleroma instance. Inside, you should have `Dockerfile` and `docker-compose.yml` from this repo.
This container is meant to run behind a reverse proxy. Please set up letsencrypt and a Nginx reverse proxy in a container or on your host by using the [example Nginx config](https://git.pleroma.social/pleroma/pleroma/blob/develop/installation/pleroma.nginx). There's also a config file in the `extras` folder you could take a look at.
Here is the `docker-compose.yml`. You should change the `POSTGRES_PASSWORD` variable.
Log into your server and clone this repository with:
```yaml
version: "3.8"
`git clone https://kitsunemimi.club/git/bronze/docker-pleroma`
services:
db:
image: postgres:12.1-alpine
container_name: pleroma_db
restart: always
environment:
POSTGRES_USER: pleroma
POSTGRES_PASSWORD: ChangeMe!
POSTGRES_DB: pleroma
volumes:
- ./postgres:/var/lib/postgresql/data
Go into the new docker-pleroma folder and run:
web:
image: pleroma
container_name: pleroma_web
restart: always
ports:
- "4000:4000"
build:
context: .
# Feel free to remove or override this section
# See 'Build-time variables' in README.md
args:
- "UID=911"
- "GID=911"
- "PLEROMA_VER=develop"
volumes:
- ./uploads:/var/lib/pleroma/uploads
- ./static:/var/lib/pleroma/static
- ./config.exs:/etc/pleroma/config.exs:ro
# optional, see 'Config Override' section in README.md
# - ./config-override.exs:/var/lib/pleroma/config.exs:ro
environment:
DOMAIN: example.com
INSTANCE_NAME: Pleroma
ADMIN_EMAIL: admin@example.com
NOTIFY_EMAIL: notify@example.com
DB_USER: pleroma
DB_PASS: ChangeMe!
DB_NAME: pleroma
depends_on:
- db
```
`sh ./scripts/setup.sh`
Create the upload and config folder and give write permissions for the uploads:
This first time setup script will ask you a few questions, generate a random password for your postgres database, put the results into your docker compose and create an admin account.
```sh
mkdir uploads config
chown -R 911:911 uploads
```
Remember that password reset link at the end will only work if your reverse proxy is configured and running (duh!).
Pleroma needs the `citext` PostgreSQL extension, here is how to add it:
Any further configuration can be done as soon as you log into your admin account, over admin-fe. It will be the speedometer icon right next to the cog on the top right of the webpage.
```sh
docker-compose up -d db
docker exec -i pleroma_db psql -U pleroma -c "CREATE EXTENSION IF NOT EXISTS citext;"
docker-compose down
```
### Maintenance
Optionally configure Pleroma, see [Config Override](#config-override).
You can now build the image. 2 way of doing it:
A very helpful [bash alias](https://www.digitalocean.com/community/tutorials/an-introduction-to-useful-bash-aliases-and-functions) for managing your pleroma instance:
```sh
docker-compose build
# or
docker build -t pleroma .
```
`alias pleroma-ctl='docker exec -it pleroma_web sh ./bin/pleroma_ctl'`
I prefer the latter because it's more verbose but this will ignore any build-time variables you have set in `docker-compose.yml`.
Now you can easily run any of the CLI commands cited in the [documentation](https://docs-develop.pleroma.social/backend/administration/CLI_tasks/user/).
You can now launch your instance:
#### Common tasks
```sh
docker-compose up -d
```
Update to the latest pleroma-fe frontend using:
The initial creation of the database schema will be done automatically. Check if everything went well with:
`sh ./scripts/update-plfe.sh`
```sh
docker logs -f pleroma_web
```
Update/rebuild the pleroma backend using:
Make a new admin user using docker exec (replace fakeadmin with any username you'd like):
`sh ./scripts/rebuild.sh`
```sh
docker exec -it pleroma_web sh ./bin/pleroma_ctl user new fakeadmin admin@test.net --admin
```
Vacuum your database with this script:
You can now setup a Nginx reverse proxy in a container or on your host by using the [example Nginx config](https://git.pleroma.social/pleroma/pleroma/blob/develop/installation/pleroma.nginx).
`sh ./scripts/vacuum.sh`
### Update
Emojis are under `./static/emoji` so drag and drop your folders there.
By default, the Dockerfile will be built from the latest commit of the `develop` branch as Pleroma does not have releases for now.
#### Backups
Thus to update, just rebuild your image and recreate your containers:
Backups can be done by copying the whole docker-pleroma folder. How you make this copy I'll leave up to you.
```sh
docker-compose pull # update the PostgreSQL if needed
docker-compose build .
# or
docker build -t pleroma .
docker-compose run --rm web mix ecto.migrate # migrate the database if needed
docker-compose up -d # recreate the containers if needed
```
For my own instance, I take a btrfs snapshot of this folder and make a tarball / squashfs archive of that snapshot. Should SHTF I have the snapshots and tarballs to fall back on!
If you want to run a specific commit, you can use the `PLEROMA_VER` variable:
However you choose to do it, make sure to `docker compose down` before making the backup, you dont want anything modified as you're making the copy.
```sh
docker build -t pleroma . --build-arg PLEROMA_VER=develop # a branch
docker build -t pleroma . --build-arg PLEROMA_VER=a9203ab3 # a commit
docker build -t pleroma . --build-arg PLEROMA_VER=v2.0.7 # a version
```
#### Upgrading database version
`a9203ab3` being the hash of the commit. (They're [here](https://git.pleroma.social/pleroma/pleroma/commits/develop))
This value can also be set through `docker-compose.yml` as seen in the example file provided in this repository.
## Config Override
By default the provided `docker-compose.yml` file mounts `config.exs` in the Pleroma container, this file is a dynamic configuration that sources some values from the environment variables provided to the container (variables like `ADMIN_EMAIL` etc.).
For those that want to change configuration that is not exposed through environment variables there is the option to mount the `config-override.exs` file which can than be modified to your satisfaction. Values set in this file will override anything set in `config.exs`. The override file provided in this repository disables new registrations on your instance, as an example.
Please see `UPDATE-DB.md`
## Other Docker images
Here are other Pleroma Docker images that helped me build mine:
- [angristan/docker-pleroma](https://github.com/angristan/docker-pleroma) (the one this is based off of!)
- [verita84/pleroma](https://git.poster.place/verita84/pleroma)
- [verita84/akkoma](https://git.poster.place/verita84/akkoma)
- [potproject/docker-pleroma](https://github.com/potproject/docker-pleroma)
- [rysiek/docker-pleroma](https://git.pleroma.social/rysiek/docker-pleroma)
- [RX14/iscute.moe](https://github.com/RX14/kurisu.rx14.co.uk/blob/master/services/iscute.moe/pleroma/Dockerfile)