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

123
README.md
View file

@ -12,11 +12,16 @@ _Pleromians trying to understand the memes_
## Features ## 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 - Based on the elixir:alpine image
- Ran as an unprivileged user - Ran as an unprivileged user
- It works great - 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. Thus you will need to build the image yourself, but I explain how to do it below.
## Build-time variables ## 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 ### 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. You should change the `POSTGRES_PASSWORD` variable in the `podman-run.sh` file.
```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: Create the upload and config folder and give write permissions for the uploads:
The `podman-run.sh` script does this automatically.
```sh ```sh
mkdir uploads config mkdir uploads config
chown -R 911:911 uploads 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: 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 ```sh
docker-compose up -d postgres ./podman-run.sh db-setup
docker exec -i pleroma_postgres psql -U pleroma -c "CREATE EXTENSION IF NOT EXISTS citext;" ```
docker-compose down 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`: 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. Make sure your PostgreSQL parameters are ok.
You can now build the image. 2 way of doing it: You can now build the image. 2 way of doing it:
Again, the `podman-run.sh` script has runtime parameters to do this.
```sh ```sh
docker-compose build ./podman-run.sh build-setup
# or
docker build -t pleroma .
``` ```
This builds the container image and does the following:
I prefer the latter because it's more verbose. Sets up the database:
Setup the database:
```sh ```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`: 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: You will need to build the image again, to pick up your updated `secret.exs` file:
Once again, `podman-run.sh` has a parameter for it:
``` ```sh
docker-compose build ./podman-run.sh final-build
# or
docker build -t pleroma .
``` ```
You can now launch your instance: You can now launch your instance:
```sh ```sh
docker-compose up -d podman pod start pleroma-pod
``` ```
Check if everything went well with: Check if everything went well with:
```sh ```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: 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.
```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))
## Other Docker images ## 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) - [potproject/docker-pleroma](https://github.com/potproject/docker-pleroma)
- [rysiek/docker-pleroma](https://git.pleroma.social/rysiek/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) - [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 \ -e POSTGRES_HOST=localhost \
$runvars $runvars
if [[ $1 == "build-setup" ]]; then
podman exec pleroma-web /pleroma/bin/pleroma_ctl config migrate_to_db
fi
if [[ $1 == "gen-keypair" ]]; then if [[ $1 == "gen-keypair" ]]; then
podman exec pleroma-web mix web_push.gen.keypair podman exec pleroma-web mix web_push.gen.keypair
fi fi