Skip to content

Instantly share code, notes, and snippets.

@fredix
Last active June 22, 2020 11:56
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fredix/6ef5c95c600dbbb9afc0e0538a93d90d to your computer and use it in GitHub Desktop.
Save fredix/6ef5c95c600dbbb9afc0e0538a93d90d to your computer and use it in GitHub Desktop.
docker stack yaml to run mastodon
# ce gist permet de lancer mastodon dans un swarm docker avec traefik.io. Il faut supprimer cette partie pour ne pas imposer des contraintes de location des conteneurs
deploy:
placement:
constraints:
- node.labels.location == home
# lancement sur le noeud leader avec : docker stack deploy --compose-file=mastodon.yml mastodon
version: '3'
services:
db:
restart: always
image: postgres:alpine
volumes:
- /sync/mastodon/postgres:/var/lib/postgresql/data
deploy:
placement:
constraints:
- node.labels.location == home
redis:
restart: always
image: redis:alpine
volumes:
- /sync/mastodon/redis:/data
deploy:
placement:
constraints:
- node.labels.location == home
web:
build: .
image: gargron/mastodon:v1.3.3
restart: always
env_file: .env.production
command: bundle exec rails s -p 3000 -b '0.0.0.0'
ports:
- "3000"
depends_on:
- db
- redis
volumes:
- /sync/mastodon/public/assets:/mastodon/public/assets
- /sync/mastodon/public/system:/mastodon/public/system
- /sync/mastodon/public/packs:/mastodon/public/packs
networks:
- default
- traefik-net
deploy:
placement:
constraints:
- node.labels.location == home
labels:
- "traefik.port=3000"
- "traefik.docker.network=traefik-net"
- "traefik.frontend.rule=Host:pouet.fredix.xyz"
streaming:
build: .
image: gargron/mastodon:v1.3.3
restart: always
env_file: .env.production
command: npm run start
ports:
- "4000"
depends_on:
- db
- redis
networks:
- default
- traefik-net
deploy:
placement:
constraints:
- node.labels.location == home
labels:
- "traefik.port=4000"
- "traefik.docker.network=traefik-net"
- "traefik.backend=streaming"
- "traefik.frontend.rule=Host:pouet.fredix.xyz;PathPrefixStrip:/api/v1/streaming"
sidekiq:
build: .
image: gargron/mastodon:v1.3.3
restart: always
env_file: .env.production
command: bundle exec sidekiq -q default -q mailers -q pull -q push
depends_on:
- db
- redis
volumes:
- /sync/mastodon/public/system:/mastodon/public/system
deploy:
placement:
constraints:
- node.labels.location == home
networks:
traefik-net:
external: true
# le .env.prodcution :
# 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=domain.tld
LOCAL_HTTPS=true
# Application secrets
# Generate each with the `rake secret` task (`docker-compose run --rm web rake secret` if you use docker compose)
PAPERCLIP_SECRET=secret
SECRET_KEY_BASE=secret
OTP_SECRET=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=login
SMTP_PASSWORD=pass
SMTP_FROM_ADDRESS=email
#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=https://pouet.fredix.xyz/api/v1/streaming
# Advanced settings
# If you need to use pgBouncer, you need to disable prepared statements:
# PREPARED_STATEMENTS=false
@Djyp
Copy link

Djyp commented Jun 27, 2017

Bonjour,
Comme ce docker-compose.yml ne se fait pas à partir des sources et qu'il n'y a pas de build, est-ce que la mise à jour de l'instance se déroule de la même manière qu'avec un build ? C'est-à-dire changer la version dans le docker-compose.yml, et exécuter :
docker-compose run --rm web rake db:migrate
docker-compose run --rm web rake assets:precompile
docker-compose up -d

EDIT : my bad, il faut les sources en fait >_< bref de toute façon ça serait logqiue que la mise à jour soit pareille

@Djyp
Copy link

Djyp commented Jun 27, 2017

Oops, ligne 97 :
- # le .env.prodcution :
+# le .env.production :

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment