about summary refs log tree commit diff
path: root/deploy/docker-compose.yml
blob: 1201d60251bf2ff37f2dcde8d0c5bfa24cb66bd3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
version: '2.4'
services:

  # automatically update images
  watchtower:
    image: containrrr/watchtower
    restart: unless-stopped
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    networks:
      - external

  # may not be necessary with recent docker, need to investigate
  ipv6nat:
    image: robbertkl/ipv6nat
    restart: always
    privileged: true
    network_mode: host
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - /lib/modules:/lib/modules:ro

  logrotate:
    image: blacklabelops/logrotate
    restart: unless-stopped
    environment:
      - LOGS_DIRECTORIES=/var/lib/docker/containers
      - LOGROTATE_INTERVAL=daily
      - LOGROTATE_COPIES=90
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /var/lib/docker/containers:/var/lib/docker/containers
    logging:
      driver: "json-file"
      options:
        max-size: "50m"
        max-file: "3"

  db:
    restart: always
    image: postgres:15
    healthcheck:
      test: ["CMD", "pg_isready", "-U", "postgres"]
    networks:
      - db_network
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /etc/timezone:/etc/timezone:ro
      - ./mastodon/db:/var/lib/postgresql/data

  redis:
    restart: always
    image: redis:alpine
    healthcheck:
      test: ["CMD", "redis-cli", "ping"]
    networks:
      - redis_network
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /etc/timezone:/etc/timezone:ro
      - ./mastodon/redis:/data

  mastodon-web:
    image: pluralcafe/mastodon:edge
    healthcheck:
      test: ["CMD-SHELL", "wget -q --spider --header 'x-forwarded-proto: https' --proxy=off localhost:3000/health || exit 1"]
    restart: always
    env_file: ./mastodon/.env.production
    command: sh -c "rm -f /mastodon/tmp/pids/server.pid; RAILS_ENV=production bundle exec rails db:migrate; bundle exec rails s -p 3000 -b '0.0.0.0'"
    networks:
      - db_network
      - redis_network
      - external
    depends_on:
      - ipv6nat
      - db
      - redis
    ports:
      - "127.0.0.1:3010:3000"
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /etc/timezone:/etc/timezone:ro
      - ./html/system:/mastodon/public/system

  mastodon-streaming:
    image: pluralcafe/mastodon:edge
    healthcheck:
      test: ["CMD-SHELL", "wget -q --spider --header 'x-forwarded-proto: https' --proxy=off localhost:4000/api/v1/streaming/health || exit 1"]
    restart: always
    env_file: ./mastodon/.env.production
    command: yarn start
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /etc/timezone:/etc/timezone:ro
    networks:
      - db_network
      - redis_network
      - external
    depends_on:
      - db
      - redis
    ports:
      - "127.0.0.1:3011:4000"

  sidekiq:
    image: pluralcafe/mastodon:edge
    restart: always
    env_file: ./mastodon/.env.production
    command: bundle exec sidekiq -q default -q mailers -q push -q pull -q scheduler
    depends_on:
      - ipv6nat
      - db
      - redis
    networks:
      - external
      - db_network
      - redis_network
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /etc/timezone:/etc/timezone:ro
      - ./html/system:/mastodon/public/system

  # after the Twitter migration of november 2022, separating ingress only makes sense
  sidekiq-ingress:
    image: pluralcafe/mastodon:edge
    restart: always
    env_file: ./mastodon/.env.production
    command: bundle exec sidekiq -q default -q ingress
    depends_on:
      - ipv6nat
      - db
      - redis
    networks:
      - external
      - db_network
      - redis_network
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /etc/timezone:/etc/timezone:ro
      - ./html/system:/mastodon/public/system

  barkeep:
    image: pluralcafe/barkeep
    restart: always
    env_file: ./mastodon/.env.ambassador
    command: yarn start
    depends_on:
      - db
      - ipv6nat
      - mastodon-web
    networks:
      - external
      - db_network
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /etc/timezone:/etc/timezone:ro

networks:
  external:
    driver: bridge
    enable_ipv6: true
    ipam:
      driver: default
      config:
        - subnet: 172.18.0.0/16
        - subnet: fd00:0000:0000::/48
  db_network:
    internal: true
  redis_network:
    internal: true