forked from thewca/worldcubeassociation.org
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-compose.yml
49 lines (47 loc) · 1.47 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
version: "3"
services:
wca_on_rails:
build:
context: WcaOnRails
ports:
- 3000:3000
environment:
DATABASE_HOST: wca_db
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:load:development ;
fi &&
bin/rails server -b 0.0.0.0'
depends_on:
- wca_db
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
# Suppress unneeded messages via https://stackoverflow.com/a/55706057/2558618
cap_add:
- SYS_NICE
volumes:
wca_db_volume:
driver: local
gems_volume:
driver: local