forked from thewca/worldcubeassociation.org
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-compose.yml
79 lines (75 loc) · 2.07 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
version: "3"
services:
wca_on_rails:
build:
context: WcaOnRails
ports:
- "3000:3000"
environment:
DATABASE_HOST: wca_db
WEBPACKER_DEV_SERVER_HOST: wca_webpacker
working_dir: /app/WcaOnRails
volumes:
- .:/app
- gems_volume:/usr/local/bundle
tty: true
# First, install Ruby and Node dependencies
# Next, wait for the database to be ready for queries via https://stackoverflow.com/a/53717981/2558618
# 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 &&
while ! mysql --host=wca_db --user=root -e "SELECT 1" >/dev/null 2>&1; do
echo "Waiting for MySQL to be ready" && sleep 5 ;
done &&
echo "MySQL is ready!" &&
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 &&
bin/rails server -b 0.0.0.0'
depends_on:
- wca_db
networks:
- wca-main
wca_webpacker:
build:
context: WcaOnRails
ports:
- "3035:3035"
environment:
DATABASE_HOST: wca_db
WEBPACKER_DEV_SERVER_HOST: 0.0.0.0
working_dir: /app/WcaOnRails
volumes:
- .:/app
- gems_volume:/usr/local/bundle
command: >
bash -c 'bundle install && yarn install &&
bin/webpacker-dev-server'
depends_on:
- wca_on_rails
networks:
- wca-main
wca_db:
image: mysql:8.0
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: "true"
command: --default-authentication-plugin=mysql_native_password
expose:
- "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
volumes:
wca_db_volume:
driver: local
gems_volume:
driver: local
networks:
wca-main:
name: wca-main