Déployer une instance Mastodon sur Docker

Mastodon est un réseau social de micro-blogging libre et décentralisé. Il est une bonne alternative à Twitter. Voici comment tester un peu ses possibilités.

Prérequis

Avoir installé Docker.

Installation

Pour faire simple (bien que brutal) cloner le dépôt Github du projet.

$ git clone https://github.com/tootsuite/mastodon.git

Ensuite copier et éditer le fichier de configuration.

$ cp .env.production.sample .env.production

L’éditer et remplir les champs suivants :

LOCAL_DOMAIN= # d'abord remplis avec localhost j'ai ensuite laissé vide parce que mon instance est locale (pour mes tests)
LOCAL_HTTPS=false # true si certificat

Pour la configuration SMTP utiliser Mailgun ou tout autre serveur SMTP.

SMTP_SERVER=smtp.mailgun.org
SMTP_PORT=587
SMTP_LOGIN=toto
SMTP_PASSWORD=1234
SMTP_FROM_ADDRESS=notifications@example.com
SMTP_DOMAIN=example.com

Ajouter l’option SMTP_DOMAIN ce qui vous évitera des heures de recherches.

Lancer ensuite un build

docker-compose build

Puis générer la clé secrète

docker-compose run --rm web rake secret

Si tout ce passe bien recopier la clé dans le fichier .env.production

Créer la base de données

docker-compose run --rm web rails db:migrate

Et compiler les assets

docker-compose run --rm web rails assets:precompile

Vous pouver lancer le monstre :

docker-compose up

Ou en mode démon :

docker-compose up -d

Connectez vous sur le port 3000 : http://localhost:3000

Exemple Configuration
# Service dependencies
REDIS_HOST=redis
REDIS_PORT=6379
DB_HOST=db
DB_USER=postgres
DB_NAME=postgres
DB_PASS=
DB_PORT=5432

# Federation
LOCAL_DOMAIN=
LOCAL_HTTPS=false



# Application secrets
# Generate each with the `rake secret` task (`docker-compose run --rm web rake secret` if you use docker compose)
PAPERCLIP_SECRET=
SECRET_KEY_BASE=<secret>
OTP_SECRET=

# Registrations
# Single user mode will disable registrations and redirect frontpage to the first profile
# SINGLE_USER_MODE=true
# Prevent registrations with following e-mail domains
# EMAIL_DOMAIN_BLACKLIST=example1.com|example2.de|etc
# Only allow registrations with the following e-mail domains
# EMAIL_DOMAIN_WHITELIST=example1.com|example2.de|etc

# Optionally change default language
DEFAULT_LOCALE=fr

# E-mail configuration
# Note: Mailgun and SparkPost (https://sparkpo.st/smtp) each have good free tiers
SMTP_SERVER=smtp.mailgun.org
SMTP_PORT=587
SMTP_LOGIN=
SMTP_PASSWORD=
SMTP_FROM_ADDRESS=notifications@example.com
#SMTP_DELIVERY_METHOD=smtp # delivery method can also be sendmail
#SMTP_AUTH_METHOD=plain
#SMTP_OPENSSL_VERIFY_MODE=peer
#SMTP_ENABLE_STARTTLS_AUTO=true

# Optional asset host for multi-server setups
# CDN_HOST=assets.example.com

# S3 (optional)
# S3_ENABLED=true
# S3_BUCKET=
# AWS_ACCESS_KEY_ID=
# AWS_SECRET_ACCESS_KEY=
# S3_REGION=
# S3_PROTOCOL=http
# S3_HOSTNAME=192.168.1.123:9000


# S3 (Minio Config (optional) Please check Minio instance for details)
# S3_ENABLED=true
# S3_BUCKET=
# AWS_ACCESS_KEY_ID=
# AWS_SECRET_ACCESS_KEY=
# S3_REGION=
# S3_PROTOCOL=https
# S3_HOSTNAME=
# S3_ENDPOINT=

# Optional alias for S3 if you want to use Cloudfront or Cloudflare in front
# S3_CLOUDFRONT_HOST=


# Streaming API integration
# STREAMING_API_BASE_URL=


# Advanced settings
# If you need to use pgBouncer, you need to disable prepared statements:
# PREPARED_STATEMENTS=false
Administration

Créer un utilisateur avec l’interface de création de compte et le définir comme administrateur.

docker-compose run --rm web rails mastodon:make_admin USERNAME=<user>

 

Sources

https://angristan.fr/installer-instance-mastodon-debian-8/

https://blog.lertsenem.com/creer-son-instance-mastodon-perso-vite-fait-mal-fait-fr.html

https://github.com/tootsuite/mastodon

https://korben.info/synchroniser-mastodon-twitter.html

Une réflexion sur « Déployer une instance Mastodon sur Docker »

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *

Matomo encountered an error: Uncaught Error: Class "Piwik\Plugins\CustomVariables\CustomVariables" not found in /var/www/piwik/core/Tracker/TrackerCodeGenerator.php:98 Stack trace: #0 /var/www/piwik/plugins/SitesManager/API.php(159): Piwik\Tracker\TrackerCodeGenerator->generate() #1 [internal function]: Piwik\Plugins\SitesManager\API->getJavascriptTag() #2 /var/www/piwik/core/API/Proxy.php(255): call_user_func_array() #3 /var/www/piwik/core/Context.php(28): Piwik\API\Proxy->Piwik\API\{closure}() #4 /var/www/piwik/core/API/Proxy.php(158): Piwik\Context::executeWithQueryParameters() #5 /var/www/piwik/core/API/Request.php(272): Piwik\API\Proxy->call() #6 /var/www/thegtricks/wp-content/plugins/wp-piwik/classes/WP_Piwik/Request/Php.php(46): Piwik\API\Request->process() #7 /var/www/thegtricks/wp-content/plugins/wp-piwik/classes/WP_Piwik/Request/Php.php(18): WP_Piwik\Request\Php->call() #8 /var/www/thegtricks/wp-content/plugins/wp-piwik/classes/WP_Piwik/Request.php(63): WP_Piwik\Request\Php->request() #9 /var/www/thegtricks/wp-content/plugins/wp-piwik/classes/WP_Piwik.php(1038): WP_Piwik\Request->perform() #10 /var/www/thegtricks/wp-content/plugins/wp-piwik/classes/WP_Piwik.php(1205): WP_Piwik->request() #11 /var/www/thegtricks/wp-content/plugins/wp-piwik/classes/WP_Piwik/TrackingCode.php(16): WP_Piwik->updateTrackingCode() #12 /var/www/thegtricks/wp-content/plugins/wp-piwik/classes/WP_Piwik.php(296): WP_Piwik\TrackingCode->__construct() #13 /var/www/thegtricks/wp-includes/class-wp-hook.php(324): WP_Piwik->addJavascriptCode() #14 /var/www/thegtricks/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters() #15 /var/www/thegtricks/wp-includes/plugin.php(517): WP_Hook->do_action() #16 /var/www/thegtricks/wp-includes/general-template.php(3068): do_action() #17 /var/www/thegtricks/wp-content/themes/twentyfifteen-child/footer.php(45): wp_footer() #18 /var/www/thegtricks/wp-includes/template.php(790): require_once('...') #19 /var/www/thegtricks/wp-includes/template.php(725): load_template() #20 /var/www/thegtricks/wp-includes/general-template.php(92): locate_template() #21 /var/www/thegtricks/wp-content/themes/twentyfifteen/single.php(53): get_footer() #22 /var/www/thegtricks/wp-includes/template-loader.php(106): include('...') #23 /var/www/thegtricks/wp-blog-header.php(19): require_once('...') #24 /var/www/thegtricks/index.php(17): require('...') #25 {main} thrown (which lead to: Session must be started before any output has been sent to the browser; output started in /var/www/thegtricks/wp-includes/script-loader.php/2925)