forked from thewca/worldcubeassociation.org
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-compose.yml
148 lines (139 loc) · 3.81 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
version: "3.8"
x-app: &app
build:
context: WcaOnRails
working_dir: /app/WcaOnRails
volumes:
- .:/app
- gems_volume:/usr/local/bundle
- yarn_volume:/app/node_modules
networks:
- wca-main
services:
wca_on_rails:
<<: *app
container_name: "rails"
ports:
- "3000:3000"
environment:
RAILS_ENV: development
DATABASE_HOST: wca_db
SHAKAPACKER_DEV_SERVER_HOST: wca_webpacker
CACHE_REDIS_URL: redis://wca_redis:6379/0
SIDEKIQ_REDIS_URL: redis://wca_redis:6379/1
MAILCATCHER_SMTP_HOST: wca_mailcatcher
tty: true
# First, install Ruby and Node dependencies
# Next, load the database if it does not exist yet
# Start the server and bind to 0.0.0.0 (vs 127.0.0.1) so Docker's port mappings work correctly
command: >
bash -c 'bundle install && yarn install &&
rm -f .db-inited &&
if ! [[ "`mysqlshow --user=root --host=wca_db wca_development`" =~ "Tables" ]] ;
then echo "Populating development db, this will take a while" && bin/rake db:reset ;
fi &&
touch .db-inited &&
bin/rails server -b 0.0.0.0'
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
depends_on:
wca_db:
condition: 'service_healthy'
wca_redis:
condition: 'service_started'
wca_webpacker:
<<: *app
container_name: "webpacker"
ports:
- "3035:3035"
environment:
DATABASE_HOST: wca_db
SHAKAPACKER_DEV_SERVER_HOST: 0.0.0.0
command: >
bash -c 'bundle install && yarn install &&
bin/shakapacker-dev-server'
depends_on:
wca_db:
condition: 'service_healthy'
wca_on_rails:
# 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_healthy'
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:
RAILS_ENV: development
DATABASE_HOST: wca_db
SIDEKIQ_REDIS_URL: redis://wca_redis:6379/1
# 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: >
bash -c 'bundle install && yarn install &&
bundle exec sidekiq'
depends_on:
wca_on_rails:
condition: 'service_healthy'
wca_redis:
condition: 'service_started'
wca_db:
condition: 'service_healthy'
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:
wca_db_volume:
driver: local
gems_volume:
driver: local
yarn_volume:
driver: local
cache_volume:
driver: local
networks:
wca-main:
name: wca-main