forked from owid/owid-grapher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-compose.full.yml
118 lines (105 loc) · 5.53 KB
/
docker-compose.full.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
version: "3.7"
# This docker-compose file creates a full local dev environment for both grapher and wordpress. It is meant for
# OWID internal developers as the setup of wordpress requires a copy of the wordpress database that is not
# publicly available.
# This setup assumes that work on the grapher happens outside any docker container - i.e. there is no Node 16
# container included in this setup. The idea is that grapher development (as well as running webpack and the
# admin server) happens on the host, and that only the mysql, php and nginx dependencies run as containers.
# The mysql database server is exposed on the host at the default mysql port of 3306 so you can use DB admin
# utilities on the host working against localhost:3306
# Before the first run you should download the database dumps. The easiest way to do this is to run the
# following 3 commands from a bash terminal with the root of the project as the working directory. Note that
# for the wordpress related downloads you'll need a working ssh setup on your host to connect to live-db.owid.io:
# ./devTools/docker/download-grapher-mysql.sh
# ./devTools/docker/download-wordpress-mysql.sh
# and if you want the wordpress file uploads as well then:
# ./devTools/docker/download-wordpress-uploads.sh
# Run `docker-compose up -d` to run all these services in deamon mode. The first time it will take a few minutes
# to build the containers and initialize and fill the database, afterwards it should be up in seconds.
# On the host, make sure you have a .env file with the correct settings, then start `yarn startTmuxServer` or similar
# and navigate to http://localhost:8080 to work with both the grapher admin and wordpress previews.
# Wordpress development
# The Wordpress admin is at http://localhost:8080/wp/wp-admin/
# While working on the editor blocks of the OWID Wordpress plugin, run `yarn startWordpressPlugin`.
# Alternatively, you can run `yarn buildWordpressPlugin` if you're working in Wordpress but not actively updating the editor.
# Working on the PHP code doesn't require any further tooling command to run.
services:
# Stock mysql database. Used for both grapher and wordpress databases. Root password is hardcoded for now
db:
image: mysql/mysql-server:latest
command: --default-authentication-plugin=mysql_native_password
restart: always
volumes:
- mysql_data:/var/lib/mysql
ports:
# Exposing via the port specified for Grapher
# Should always be the same as the WordPress port, because we store both DBs on the same server
- "${GRAPHER_DB_PORT}:3306"
environment:
MYSQL_ROOT_PASSWORD: weeniest-stretch-contaminate-gnarl
MYSQL_ROOT_HOST: "%"
# mysql 8.0 container with slight augmentation (+curl, +unzip, +ssh client, ...) for running the DB init scripts
# These init scripts check if the grapher and wordpress databases and users are missing, if so they create them
# and pull the data to have a working dev environment. As the wordpress donwload needs a working ssh access, it
# mounts the SSH agent and ~/.ssh directory into the container
db-load-data:
build:
context: ./devTools/docker/mysql-init-docker
# image: mysql/mysql-server:latest
command: "/app/full-mysql-init.sh"
volumes:
- ./devTools/docker:/app
- ./tmp-downloads:/tmp-downloads
# - ~/.ssh:/user/.ssh # map the .ssh directory into the container so it knows about the owid-live ssh configuration
# - ${SSH_AUTH_SOCK}:/ssh-agent # Forward the SSH agent socket into the container
environment:
DB_ROOT_PASS: weeniest-stretch-contaminate-gnarl
DB_ROOT_HOST: db
DATA_FOLDER: "/tmp-downloads"
# SSH_AUTH_SOCK: "/ssh-agent"
env_file:
- .env
depends_on:
- db
# Nginx that is used together with wordpress for the CSM part and top level routing.
web:
image: nginx:1.21
ports:
- 8080:80
volumes:
- ./devTools/docker/vhosts.conf:/etc/nginx/conf.d/default.conf
- ./wordpress:/app
depends_on:
- fpm
# PHP cgi server that executes wordpress
fpm:
build:
context: ./devTools/docker/wordpress-php-docker
ports:
- 9000:9000
volumes:
- ./devTools/docker/php.ini:/usr/local/etc/php/php.ini
- ./wordpress:/app
depends_on:
- db
# Init container for the PHP codebase. This mounts the ./wordpress directory that is also
# used by the nginx and php container and executes the PHP package manager composer to
# make sure that all dependencies and plugins are installed that are not part of our source
# (i.e. ./wordpress/web/app/plugins/owid is already there because it is part of this git repo
# but all the other plugins will only be downloaded by running composer)
wordpress-install:
build:
context: ./devTools/docker/wordpress-php-docker
command: "composer install --no-interaction"
volumes:
- ./wordpress:/app
# Init container for the owid wordpress plugin. The Javascript part of this plugin need to
# be built in a node container once with the ./wordpress directory mounted into the container.
wordpress-owid-plugin-build:
image: node:16
command: "yarn build"
working_dir: /app/web/app/plugins/owid
volumes:
- ./wordpress:/app
volumes:
mysql_data: