forked from thewca/worldcubeassociation.org
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-compose.yml
151 lines (140 loc) · 3.69 KB
/
docker-compose.yml
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
x-environment: &env
RAILS_ENV: development
DATABASE_HOST: wca_db
x-app: &app
build:
dockerfile: Dockerfile.dev
context: .
working_dir: /app
entrypoint: ./entrypoint.dev.sh
environment:
<<: *env
volumes:
- .:/app
- gems_volume:/usr/local/bundle
- node_modules_volume:/app/node_modules
networks:
- wca-main
x-app-environment: &appVars
<<: *env
SIDEKIQ_REDIS_URL: redis://wca_redis:6379/1
MAILCATCHER_SMTP_HOST: wca_mailcatcher
services:
wca_environment:
<<: *app
container_name: "environment"
command: >
bash -c 'corepack install &&
rm -f .db-inited &&
bin/setup &&
touch .db-inited'
healthcheck:
test: [ "CMD", "test", "-f", ".db-inited" ]
interval: 5s
timeout: 2s
retries: 20
# Give the container some time to populate the database
start_period: 15m
# Tell Docker that it's okay and expected that this container terminates (with exit code 0)
# after completing the script listed under `command` above
restart: no
depends_on:
wca_db:
condition: 'service_healthy'
wca_redis:
condition: 'service_started'
wca_on_rails:
<<: *app
container_name: "rails"
ports:
- "3000:3000"
environment:
<<: *appVars
SHAKAPACKER_DEV_SERVER_HOST: wca_webpacker
CACHE_REDIS_URL: redis://wca_redis:6379/0
tty: true
# Start the server and bind to 0.0.0.0 (vs 127.0.0.1) so Docker's port mappings work correctly
command: bin/rails server -b 0.0.0.0
depends_on:
wca_environment:
condition: service_completed_successfully
wca_webpacker:
<<: *app
container_name: "webpacker"
ports:
- "3035:3035"
environment:
<<: *appVars
SHAKAPACKER_DEV_SERVER_HOST: 0.0.0.0
NODE_ENV: development
command: bin/shakapacker-dev-server
depends_on:
wca_environment:
# We need to make sure that the database is populated because our frontend code
# pulls stuff like WCA Events and Round formats from the DB when compiling assets
condition: service_completed_successfully
wca_mailcatcher:
<<: *app
container_name: "mailcatcher"
expose:
- "1025"
ports:
- "1080:1080"
command: >
bash -c 'gem install mailcatcher &&
mailcatcher --foreground --ip=0.0.0.0'
wca_sidekiq:
<<: *app
container_name: 'sidekiq'
environment:
<<: *appVars
# Cronjobs are disabled in development by default. If you wish to run cronjobs,
# set this env variable to any integer value greater than zero
# CRONJOB_POLLING_MINUTES: 30
command: bin/bundle exec sidekiq
depends_on:
wca_environment:
condition: service_completed_successfully
wca_db:
image: mysql:8.0
container_name: "database"
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: "true"
command: --authentication-policy=mysql_native_password
ports:
- "3306:3306"
volumes:
- wca_db_volume:/var/lib/mysql
- ./docker/my.cnf:/etc/my.cnf
# Suppress unneeded messages via https://stackoverflow.com/a/55706057/2558618
cap_add:
- SYS_NICE
networks:
- wca-main
healthcheck:
test: [ "CMD", "mysql", "-u", "root", "-e", "SELECT 1;" ]
interval: 5s
timeout: 5s
retries: 20
wca_redis:
image: redis:7.0-alpine
container_name: "redis-main"
expose:
- "6379"
command: redis-server --loglevel warning
volumes:
- cache_volume:/data
networks:
- wca-main
volumes:
gems_volume:
driver: local
node_modules_volume:
driver: local
wca_db_volume:
driver: local
cache_volume:
driver: local
networks:
wca-main:
name: wca-main