Update everything

- Base Alpine upgraded
- Mastodon default version arg upgraded
- New docker-compose.yml (traefik v2)
This commit is contained in:
Wonderfall 2020-06-02 04:37:29 +02:00
parent 5ae8b92d32
commit 9fd72b7b6f
4 changed files with 96 additions and 103 deletions

View file

@ -1,12 +1,13 @@
FROM ruby:2.6.1-alpine3.9
FROM ruby:2.6.6-alpine3.11
ARG VERSION=v2.9.0
ARG VERSION=v3.1.4
ARG REPOSITORY=tootsuite/mastodon
ARG LIBICONV_VERSION=1.15
ENV UID=991 GID=991 \
RUN_DB_MIGRATIONS=true \
SIDEKIQ_WORKERS=5 \
BIND=0.0.0.0 \
RAILS_SERVE_STATIC_FILES=true \
RAILS_ENV=production \
NODE_ENV=production \
@ -34,6 +35,9 @@ RUN apk -U upgrade \
s6 \
su-exec \
tzdata \
yaml \
readline \
gcompat \
# Install build dependencies
&& apk add -t build-dependencies \

View file

@ -1,7 +1,5 @@
## wonderfall/mastodon
![Mastodon](https://github.com/tootsuite/mastodon/blob/master/app/javascript/images/mastodon-getting-started.png?raw=true)
A GNU Social-compatible microblogging server : https://github.com/tootsuite/mastodon
#### Why this image?
@ -9,52 +7,26 @@ This image is not the official one. The main difference you can notice is that a
#### Features
- Based on Alpine Linux.
- As lightweight as possible.
- As lightweight as possible.
- All-in-one container (s6).
- Assets are precompiled.
- Database migrations can be run at startup.
- No root processes.
#### Build-time variables
- **VERSION** : version of Mastodon, can be `v1.4.1` or `master`. *(default : latest version)*
- **VERSION** : version of Mastodon *(default : latest version)*
- **REPOSITORY** : location of the code *(default : tootsuite/mastodon)*
#### Environment variables you should change
- **UID** : mastodon user id *(default : 991)*
- **GID** : mastodon group id *(default : 991)*
- **RUN_DB_MIGRATIONS** : run `rake db:migrate` at startup *(default : true)*
- **RUN_DB_MIGRATIONS** : run database migrations at startup *(default : true)*
- **SIDEKIQ_WORKERS** : number of Sidekiq workers *(default : 5)*
- Other environment variables : https://github.com/tootsuite/mastodon/blob/master/.env.production.sample
#### Volumes
- **/mastodon/public/system** : shit like media attachments, avatars, etc.
- **/mastodon/public/assets** : Mastodon assets
- **/mastodon/public/packs** : Mastodon assets
- **/mastodon/public/system** : Mastodon files
- **/mastodon/log** : Mastodon logfiles (mount if you prefer to)
#### Ports
- **3000** : Mastodon web
- **4000** : Mastodon streaming
#### docker-compose sample
```
mastodon:
image: wonderfall/mastodon:stable
restart: always
container_name: mastodon
env_file: /home/docker/mastodon/.env.production
environment:
- WEB_CONCURRENCY=16
- MAX_THREADS=20
- SIDEKIQ_WORKERS=25
- RUN_DB_MIGRATIONS=true
links:
- mastodon-pgb
- mastodon-redis
volumes:
- /home/docker/mastodon/public/system:/mastodon/public/system
- /home/docker/mastodon/public/assets:/mastodon/public/assets
- /home/docker/mastodon/public/packs:/mastodon/public/packs
```
- **3000** : web
- **4000** : streaming

84
docker-compose.yml Normal file
View file

@ -0,0 +1,84 @@
# This is the docker-compose.yml I use with Traefik v2, feel free to use it.
version: '3'
networks:
http_network:
external: true
mastodon_network:
external: false
services:
traefik:
image: traefik:2.2
container_name: traefik
restart: unless-stopped
ports:
- 80:80
- 443:443
labels:
# There you should configure as you like: https://docs.traefik.io/user-guides/docker-compose/basic-example/
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- /home/docker/traefik/traefik.yml:/etc/traefik/traefik.yml
- /home/docker/traefik/acme.json:/acme.json
- /home/docker/traefik/config.yml:/config.yml
networks:
- http_network
mastodon-db:
image: postgres:9.6-alpine
container_name: mastodon-db
restart: unless-stopped
volumes:
- /home/docker/mastodon/db:/var/lib/postgresql/data
environment:
- POSTGRES_USER=mastodon
- POSTGRES_DB=mastodon
- POSTGRES_PASSWORD=
networks:
- mastodon_network
mastodon-redis:
image: redis:6.0-alpine
container_name: mastodon-redis
restart: unless-stopped
volumes:
- /home/docker/mastodon/redis:/data
networks:
- mastodon_network
mastodon:
image: mastodon
container_name: mastodon
restart: unless-stopped
env_file: /home/docker/mastodon/.env.production
networks:
- http_network
- mastodon_network
depends_on:
- mastodon-db
- mastodon-redis
volumes:
- /home/docker/mastodon/data:/mastodon/public/system
- /home/docker/mastodon/logs:/mastodon/log
labels:
- traefik.enable=true
- traefik.http.routers.mastodon-web.entrypoints=http
- traefik.http.routers.mastodon-web.rule=Host(`domain.tld`)
- traefik.http.routers.mastodon-web.middlewares=https-redirect@file
- traefik.http.routers.mastodon-web-secure.entrypoints=https
- traefik.http.routers.mastodon-web-secure.rule=Host(`domain.tld`)
- traefik.http.routers.mastodon-web-secure.tls=true
- traefik.http.routers.mastodon-web-secure.tls.certresolver=http
- traefik.http.routers.mastodon-web-secure.service=mastodon-web
- traefik.http.services.mastodon-web.loadbalancer.server.port=3000
- traefik.http.routers.mastodon-streaming.entrypoints=http
- traefik.http.routers.mastodon-streaming.rule=Host(`domain.tld`) && PathPrefix(`/api/v1/streaming`)
- traefik.http.routers.mastodon-streaming.middlewares=https-redirect@file
- traefik.http.routers.mastodon-streaming-secure.entrypoints=https
- traefik.http.routers.mastodon-streaming-secure.rule=Host(`domain.tld`) && PathPrefix(`/api/v1/streaming`)
- traefik.http.routers.mastodon-streaming-secure.tls=true
- traefik.http.routers.mastodon-streaming-secure.tls.certresolver=http
- traefik.http.routers.mastodon-streaming-secure.service=mastodon-streaming
- traefik.http.services.mastodon-streaming.loadbalancer.server.port=4000
- traefik.docker.network=http_network

View file

@ -1,67 +0,0 @@
version: '3'
networks:
http_network:
external: true
mastodon_network:
external: false
services:
traefik:
image: traefik:1.6-alpine
container_name: traefik
ports:
- "80:80"
- "443:443"
labels:
- traefik.enable=true
- traefik.frontend.rule=Host:traefik.example.com
- traefik.port=8080
- traefik.docker.network=http_network
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- /home/docker/traefik/traefik.toml:/traefik.toml:ro
- /home/docker/traefik/acme:/etc/traefik/acme
networks:
- http_network
mastodon-db:
image: postgres:9.6-alpine
container_name: mastodon-db
volumes:
- /home/docker/mastodon/db:/var/lib/postgresql/data
environment:
- POSTGRES_PASSWORD=supersecret
- POSTGRES_USER=mastodon
- POSTGRES_DB=mastodon
networks:
- mastodon_network
mastodon-redis:
image: redis:4.0-alpine
container_name: mastodon-redis
volumes:
- /home/docker/mastodon/redis:/data
networks:
- mastodon_network
mastodon:
image: wonderfall/mastodon
container_name: mastodon
env_file: /home/docker/mastodon/.env.production
volumes:
- /home/docker/mastodon/data:/mastodon/public/system
- /home/docker/mastodon/logs:/mastodon/log
networks:
- mastodon_network
- http_network
depends_on:
- mastodon-db
- mastodon-redis
labels:
- traefik.enable=true
- traefik.webui.frontend.rule=Host:example.com
- traefik.webui.port=3000
- traefik.streaming.frontend.rule=Host:example.com;PathPrefixStrip:/api/v1/streaming
- traefik.streaming.port=4000
- traefik.docker.network=http_network