re-write of readme

This commit is contained in:
Paul Wilde 2022-03-16 15:46:38 +00:00
parent 3f1cb3fd6e
commit 77804695f2
2 changed files with 51 additions and 78 deletions

125
README.md
View file

@ -12,11 +12,16 @@ _Pleromians trying to understand the memes_
## Features
This Podman set up is adapted from [angristan's docker-pleroma](https://github.com/angristan/docker-pleroma). I muddled my way through the set up to get a final working set up. There may be some missed steps in the below, but ultimately this is what lead me to getting things running nicely.
A quick further note. I have included the `config :pleroma, configurable_from_database: true` configuration and the `pleroma_ctl config migrate_to_db` procedure. This means a lot of the actual config.exs parts can be eliminated completely, but I've left them in for clarity.
- adapted from [angristan/docker-pleroma](https://github.com/angristan/docker-pleroma)
- 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. 😢
As with Angristan's Docker-Pleroma: this is not a reusable (e.g. It can't be uploaded 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.
## Build-time variables
@ -29,40 +34,12 @@ 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.
Create a folder for your Pleroma instance. Inside, you should have `Dockerfile` and `podman-run.sh` from this repo.
Here is the `docker-compose.yml`. You should change the `POSTGRES_PASSWORD` variable.
```yaml
version: '2.3'
services:
postgres:
image: postgres:9.6-alpine
container_name: pleroma_postgres
restart: always
environment:
POSTGRES_USER: pleroma
POSTGRES_PASSWORD: pleroma
POSTGRES_DB: pleroma
volumes:
- ./postgres:/var/lib/postgresql/data
web:
build: .
image: pleroma
container_name: pleroma_web
restart: always
ports:
- '127.0.0.1:4000:4000'
volumes:
- ./uploads:/pleroma/uploads
depends_on:
- postgres
```
Create the upload and config folder and give write permissions for the uploads:
You should change the `POSTGRES_PASSWORD` variable in the `podman-run.sh` file.
Create the upload and config folder and give write permissions for the uploads:
The `podman-run.sh` script does this automatically.
```sh
mkdir uploads config
chown -R 911:911 uploads
@ -70,10 +47,15 @@ chown -R 911:911 uploads
Pleroma needs the `citext` PostgreSQL extension, here is how to add it:
The `podman-run.sh` script does this automatically when run with the `db-setup` argument.
```sh
docker-compose up -d postgres
docker exec -i pleroma_postgres psql -U pleroma -c "CREATE EXTENSION IF NOT EXISTS citext;"
docker-compose down
./podman-run.sh db-setup
```
This creates a pod and the postgresql container then runs the below
```sh
<You don't need to do this bit>
podman exec -i pleroma-db psql -U pleroma -c "CREATE EXTENSION IF NOT EXISTS citext;"
<You don't need to do that bit>
```
Configure Pleroma. Copy the following to `config/secret.exs`:
@ -116,78 +98,65 @@ You need to change at least:
Make sure your PostgreSQL parameters are ok.
You can now build the image. 2 way of doing it:
Again, the `podman-run.sh` script has runtime parameters to do this.
```sh
docker-compose build
# or
docker build -t pleroma .
./podman-run.sh build-setup
```
I prefer the latter because it's more verbose.
Setup the database:
This builds the container image and does the following:
Sets up the database:
```sh
docker-compose run --rm web mix ecto.migrate
>You don't need to do this<
podman exec pleroma-web mix ecto.migrate
```
and also... migrates config to the DB
```sh
podman exec pleroma-web /pleroma/bin/pleroma_ctl config migrate_to_db
>You don't need to do that<
```
Get your web push keys and copy them to `secret.exs`:
Again, the `podman-run.sh` script has runtime parameters to do this.
```sh
./podman-run.sh gen-keypair
```
docker-compose run --rm web mix web_push.gen.keypair
Which does sets up the containers again and runs the following:
```
>You don't need to do this<
podman exec pleroma-web mix web_push.gen.keypair
>You don't need to do that<
```
You will need to build the image again, to pick up your updated `secret.exs` file:
```
docker-compose build
# or
docker build -t pleroma .
Once again, `podman-run.sh` has a parameter for it:
```sh
./podman-run.sh final-build
```
You can now launch your instance:
```sh
docker-compose up -d
podman pod start pleroma-pod
```
Check if everything went well with:
```sh
docker logs -f pleroma_web
podman logs -f pleroma-web
```
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).
You can now setup a HAProxy or 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).
### Update
By default, the Dockerfile will be built from the latest commit of the `develop` branch as Pleroma does not have releases for now.
## Final Notes
Thus to update, just rebuild your image and recreate your containers:
```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
```
If you want to run a specific commit, you can use the `PLEROMA_VER` variable:
```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
```
`a9203ab3` being the hash of the commit. (They're [here](https://git.pleroma.social/pleroma/pleroma/commits/develop))
As with anything, I've only tested this on my systems, and the process of going through getting things working may have meant some steps are missing from this guide. At some point I will test this process again to ensure the script works well, but if anyone has any queries about it then let me know.
## Other Docker images
Here are other Pleroma Docker images that helped me build mine:
Here are other Pleroma Container images that helped me build mine:
- [angristan/docker-pleroma](https://github.com/angristan/docker-pleroma) - which this repo is adapted from
- [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)

View file

@ -53,6 +53,10 @@ podman run $runmode \
-e POSTGRES_HOST=localhost \
$runvars
if [[ $1 == "build-setup" ]]; then
podman exec pleroma-web /pleroma/bin/pleroma_ctl config migrate_to_db
fi
if [[ $1 == "gen-keypair" ]]; then
podman exec pleroma-web mix web_push.gen.keypair
fi