Fix documentation
Some checks are pending
ci/woodpecker/push/build-amd64 Pipeline is pending
ci/woodpecker/push/build-arm64 Pipeline is pending
ci/woodpecker/push/build-docker Pipeline is pending
ci/woodpecker/push/docs Pipeline is pending
ci/woodpecker/push/lint Pipeline is pending
ci/woodpecker/push/test Pipeline is pending
ci/woodpecker/pr/build-amd64 Pipeline is pending
ci/woodpecker/pr/build-arm64 Pipeline is pending
ci/woodpecker/pr/build-docker Pipeline is pending
ci/woodpecker/pr/docs Pipeline is pending
ci/woodpecker/pr/lint Pipeline is pending
ci/woodpecker/pr/test Pipeline is pending

This commit is contained in:
Floatingghost 2024-06-04 11:40:49 +01:00
parent 569851f14c
commit dbbfeeb748
4 changed files with 95 additions and 47 deletions

View file

@ -0,0 +1,39 @@
services:
db:
# If you use a config generator, use the value below for your
# "ram" size
shm_size: 4gb
command:
- "postgres"
- "-c"
- "max_connections=40"
- "-c"
- "shared_buffers=1GB"
- "-c"
- "effective_cache_size=3GB"
- "-c"
- "maintenance_work_mem=512MB"
- "-c"
- "checkpoint_completion_target=0.9"
- "-c"
- "wal_buffers=16MB"
- "-c"
- "default_statistics_target=500"
- "-c"
- "random_page_cost=1.1"
- "-c"
- "effective_io_concurrency=200"
- "-c"
- "work_mem=6553kB"
- "-c"
- "min_wal_size=4GB"
- "-c"
- "max_wal_size=16GB"
- "-c"
- "max_worker_processes=4"
- "-c"
- "max_parallel_workers_per_gather=2"
- "-c"
- "max_parallel_workers=4"
- "-c"
- "max_parallel_maintenance_workers=2"

View file

@ -0,0 +1,5 @@
MIX_ENV=prod
ERL_EPMD_ADDRESS=127.0.0.1
DB_NAME=akkoma
DB_USER=akkoma
DB_PASS=akkoma

View file

@ -8,9 +8,7 @@ mkdir -p pgdata
docker compose run \ docker compose run \
--rm \ --rm \
-e "PLEROMA_CTL_RPC_DISABLED=true" \ -e "PLEROMA_CTL_RPC_DISABLED=true" \
akkoma ./bin/pleroma_ctl instance gen --no-sql-user --no-db-creation --dbhost db --dbname akkoma --dbuser akkoma --dbpass akkoma --listen-ip 0.0.0.0 --listen-port 4000 --static-dir /opt/akkoma/instance/ --uploads-dir /opt/akkoma/uploads/ --db-configurable true --output /opt/akkoma/config/generated_config.exs --output-psql /opt/akkoma/config/setup_db.psql akkoma ./bin/pleroma_ctl instance gen --no-sql-user --no-db-creation --dbhost db --dbname akkoma --dbuser akkoma --dbpass akkoma --listen-ip 0.0.0.0 --listen-port 4000 --static-dir /opt/akkoma/instance/ --uploads-dir /opt/akkoma/uploads/ --db-configurable y --output /opt/akkoma/config/generated_config.exs --output-psql /opt/akkoma/config/setup_db.psql
echo "Instance generated!"
# setup database from generated config # setup database from generated config
# we run from the akkoma container to ensure we have the right environment! can't connect to a DB that doesn't exist yet... # we run from the akkoma container to ensure we have the right environment! can't connect to a DB that doesn't exist yet...
@ -18,4 +16,11 @@ docker compose run \
--rm \ --rm \
-e "PLEROMA_CTL_RPC_DISABLED=true" \ -e "PLEROMA_CTL_RPC_DISABLED=true" \
-e "PGPASSWORD=akkoma" \ -e "PGPASSWORD=akkoma" \
akkoma psql -h db -U akkoma -d akkoma -f /opt/akkoma/config/setup_db.psql akkoma psql -h db -U akkoma -d akkoma -f /opt/akkoma/config/setup_db.psql
# stop tzdata trying to write to places it shouldn't
echo "config :tzdata, :data_dir, "/var/tmp/elixir_tzdata_storage" >> /opt/akkoma/config/generated_config.exs
echo "Instance generated!"
echo "Make sure you check your config and copy it to config/prod.secret.exs before starting the instance!"

View file

@ -28,31 +28,14 @@ echo "DOCKER_USER=$(id -u):$(id -g)" >> .env
This probably won't need to be changed, it's only there to set basic environment This probably won't need to be changed, it's only there to set basic environment
variables for the docker compose file. variables for the docker compose file.
### Building the container
The container provided is a thin wrapper around akkoma's dependencies,
it does not contain the code itself. This is to allow for easy updates
and debugging if required.
```bash
./docker-resources/build.sh
```
This will generate a container called `akkoma` which we can use
in our compose environment.
### Generating your instance ### Generating your instance
```bash ```bash
mkdir pgdata mkdir pgdata
./docker-resources/manage.sh mix deps.get ./docker-resources/generate-instance.sh
./docker-resources/manage.sh mix compile
./docker-resources/manage.sh mix pleroma.instance gen
``` ```
This will ask you a few questions - the defaults are fine for most things, This will ask you a few questions - the defaults are fine for most things!
the database hostname is `db`, the database password is `akkoma`
(not auto generated), and you will want to set the ip to `0.0.0.0`.
Now we'll want to copy over the config it just created Now we'll want to copy over the config it just created
@ -60,24 +43,6 @@ Now we'll want to copy over the config it just created
cp config/generated_config.exs config/prod.secret.exs cp config/generated_config.exs config/prod.secret.exs
``` ```
### Setting up the database
We need to run a few commands on the database container, this isn't too bad
```bash
docker compose run --rm --user akkoma -d db
# Note down the name it gives here, it will be something like akkoma_db_run
docker compose run --rm akkoma psql -h db -U akkoma -f config/setup_db.psql
docker stop akkoma_db_run # Replace with the name you noted down
```
Now we can actually run our migrations
```bash
./docker-resources/manage.sh mix ecto.migrate
# this will recompile your files at the same time, since we changed the config
```
### Start the server ### Start the server
We're going to run it in the foreground on the first run, just to make sure We're going to run it in the foreground on the first run, just to make sure
@ -102,7 +67,7 @@ docker compose up -d
If your instance is up and running, you can create your first user with administrative rights with the following task: If your instance is up and running, you can create your first user with administrative rights with the following task:
```shell ```shell
./docker-resources/manage.sh mix pleroma.user new MY_USERNAME MY_EMAIL@SOMEWHERE --admin ./docker-resources/manage.sh user new MY_USERNAME MY_EMAIL@SOMEWHERE --admin
``` ```
And follow the prompts And follow the prompts
@ -154,23 +119,43 @@ If you want, you can also run the reverse proxy on the host. This is a bit more
Follow the guides for source install for your distribution of choice, or adapt Follow the guides for source install for your distribution of choice, or adapt
as needed. Your standard setup can be found in the [Debian Guide](../debian_based_en/#nginx) as needed. Your standard setup can be found in the [Debian Guide](../debian_based_en/#nginx)
### Applying Postgresql optimisations
Your postgresql server will behave better if you tune its settings to your machine.
There is a file at `docker-resources/docker-compose.pgsql-tuning.yml` which shows you how to apply settings, for example
those generated by [PgTune](https://pgtune.leopard.in.ua/)
You can merge this config into a `docker-compose.override.yml` file to apply them. Make sure that you generate your options
based on the shm_size you allocate!
### You're done! ### You're done!
All that's left is to set up your frontends. All that's left is to set up your frontends.
The standard from-source commands will apply to you, just make sure you The standard OTP commands will apply to you, just make sure you
prefix them with `./docker-resources/manage.sh`! prefix them with `./docker-resources/manage.sh`!
So, for example, if an OTP command would be
```
./bin/pleroma_ctl user new myuser
```
The equivalent docker command would be
```
./docker-resources/manage.sh user new myuser
```
{! installation/frontends.include !} {! installation/frontends.include !}
### Updating Docker Installs ### Updating Docker Installs
```bash ```bash
git pull git pull
./docker-resources/build.sh docker compose pull
./docker-resources/manage.sh mix deps.get ./docker-resources/manage.sh migrate
./docker-resources/manage.sh mix compile
./docker-resources/manage.sh mix ecto.migrate
docker compose restart akkoma db docker compose restart akkoma db
``` ```
@ -180,6 +165,20 @@ create a new file called `docker-compose.override.yml`. There you can add any
overrides or additional services without worrying about git conflicts when a overrides or additional services without worrying about git conflicts when a
new release comes out. new release comes out.
### Migrating from the old docker install system
If you were running akkoma in docker before 2024.06, you will need to do a few little migration steps.
First off, we need to migrate our postgres installation to a newer version!
```bash
./docker-resources/migrate-postgresql-version.sh pgdata 14 16
```
This should be nice and quick.
After that you can just `docker compose pull` and all should be fine.
#### Further reading #### Further reading
{! installation/further_reading.include !} {! installation/further_reading.include !}