Skip to content
This repository was archived by the owner on Jan 11, 2024. It is now read-only.

Latest commit

 

History

History
180 lines (120 loc) · 5.96 KB

docker_deployment_guide.md

File metadata and controls

180 lines (120 loc) · 5.96 KB

Admin Docker Guide

For bare metal see: Admin Bare Metal Guide.

Note Mbin is still in development.

System Requirements

  • Docker Engine

  • Docker Compose V2

    If you are using Compose V1, replace docker compose with docker-compose in those commands below.

Docker Install

The most convenient way to install docker is using an official convenience script provided at get.docker.com:

curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh

Alternatively, you can follow the official Docker install documentation for your platform.

Once Docker is installed on your system, it is recommended to create a docker group and add it to your user:

sudo groupadd docker
sudo usermod -aG docker $USER

Mbin Installation

Preparation

Clone git repository:

git clone https://github.com/MbinOrg/mbin.git
cd mbin

Build the Docker image:

Note If you're using a version of Docker Engine earlier than 23.0, run export DOCKER_BUILDKIT=1, prior to building the image. This does not apply to users running Docker Desktop. More info can be found here

docker build -t mbin -f docker/Dockerfile .

Create config files and storage directories:

cd docker
cp ../.env.example_docker .env
cp compose.prod.yml compose.override.yml
mkdir -p storage/media storage/caddy_config storage/caddy_data
sudo chown $USER:$USER storage/media storage/caddy_config storage/caddy_data

Configure .env and compose.override.yml

  1. Choose your Redis password, PostgreSQL password, RabbitMQ password, and Mercure password.
  2. Place them in the corresponding variables in both .env and compose.override.yml.

Note Ensure the HTTPS environmental variable is set to TRUE in compose.override.yml for the php, messenger, and messenger_ap containers if your environment is using a valid certificate behind a reverse proxy. This is likely true for most production environments and is required for proper federation, that is, this will ensure the webfinger responses include https: in the URLs generated.

Configure OAuth2 keys

  1. Create an RSA key pair using OpenSSL:
# Replace <mbin_dir> with Mbin's root directory
mkdir <mbin_dir>/config/oauth2/
# If you protect the key with a passphrase, make sure to remember it!
# You will need it later
openssl genrsa -des3 -out ./config/oauth2/private.pem 4096
openssl rsa -in ./config/oauth2/private.pem --outform PEM -pubout -out ./config/oauth2/public.pem
  1. Generate a random hex string for the OAuth2 encryption key:
openssl rand -hex 16
  1. Add the public and private key paths to .env:
OAUTH_PRIVATE_KEY=%kernel.project_dir%/config/oauth2/private.pem
OAUTH_PUBLIC_KEY=%kernel.project_dir%/config/oauth2/public.pem
OAUTH_PASSPHRASE=<Your (optional) passphrase from above here>
OAUTH_ENCRYPTION_KEY=<Hex string generated in previous step>

Running the containers

By default docker compose will execute the compose.yml and compose.override.yml files.

Run the container in the background (-d means detached, but this can also be omitted for testing):

# Replace <mbin_dir> with Mbin's root directory
cd <mbin_dir>/docker
docker compose up -d

See your running containers via: docker ps.

Then, you should be able to access the new instance via http://localhost.
You can also access RabbitMQ management UI via http://localhost:15672.

Mbin first setup

Create new admin user (without email verification), please change the username, email and password below:

docker compose exec php bin/console kbin:user:create <username> <email@example.com> <password>
docker compose exec php bin/console kbin:user:admin <username>
docker compose exec php bin/console kbin:ap:keys:update

Next, log in and create a magazine named "random" to which unclassified content from the fediverse will flow.

Add auxiliary containers to compose.yml

Add any auxiliary container as you want. For example, add a Nginx container as reverse proxy to provide HTTPS encryption.

Uploaded media files

Uploaded media files (e.g. photos uploaded by users) will be stored on the host directory storage/media. They will be served by the Caddy web server in the www container as static files.

Make sure KBIN_STORAGE_URL in your .env configuration file is set to be https://yourdomain.tld/media (assuming you setup Nginx with SSL certificate by now).

You can also serve those media files on another server by mirroring the files at storage/media and changing KBIN_STORAGE_URL correspondingly.

Filesystem ACL support

The filesystem ACL is disabled by default, in the mbin image. You can set the environment variable ENABLE_ACL=1 to enable it. Remember that not all filesystems support ACL. This will cause an error if you enable filesystem ACL for such filesystems.

Run Production

If you created the file compose.override.yml with your configs (cp compose.prod.yml compose.override.yml), running production would be the same command:

docker compose up -d

See also the official: Deploying in Production guide.

If you want to deploy your app on a cluster of machines, you can use Docker Swarm, which is compatible with the provided Compose files.

Clear cache

docker compose exec php bin/console cache:clear
docker compose exec redis redis-cli
> auth REDIS_PASSWORD
> FLUSHDB

Backup and restore

docker exec -it container_id pg_dump -U kbin mbin > dump.sql
docker compose exec -T database psql -U kbin mbin < dump.sql

See also