Skip to content
This repository was archived by the owner on Aug 1, 2024. It is now read-only.

Commit 8dca89e

Browse files
authored
Merge pull request #1097 from openedx/farhanumar/psre-2485-1
feat: Added mysql 8 container in docker-compose
2 parents e5f2fc8 + 8351a43 commit 8dca89e

4 files changed

Lines changed: 94 additions & 2 deletions

File tree

docker-compose.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,23 @@ services:
252252
volumes:
253253
- mysql57_data:/var/lib/mysql
254254

255+
mysql80:
256+
command: mysqld --character-set-server=utf8 --collation-server=utf8_general_ci
257+
container_name: "edx.${COMPOSE_PROJECT_NAME:-devstack}.mysql80"
258+
hostname: mysql80.devstack.edx
259+
environment:
260+
MYSQL_ROOT_PASSWORD: ""
261+
MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
262+
image: mysql:8.0.26
263+
networks:
264+
default:
265+
aliases:
266+
- edx.devstack.mysql80
267+
ports:
268+
- "3406:3306"
269+
volumes:
270+
- mysql80_data:/var/lib/mysql
271+
255272
redis:
256273
container_name: "edx.${COMPOSE_PROJECT_NAME:-devstack}.redis"
257274
hostname: redis.devstack.edx
@@ -865,3 +882,4 @@ volumes:
865882
mongo_data:
866883
opensearch12_data:
867884
mysql57_data:
885+
mysql80_data:

drop-mysql-user.sql

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#docker-compose exec -T mysql80 bash -e -c "mysql -uroot mysql" < drop-mysql-user.sql
2+
#docker exec -it edx.devstack.mysql80 mysql
3+
4+
drop user 'credentials001'@'%';
5+
drop user 'discov001'@'%';
6+
drop user 'ecomm001'@'%';
7+
drop user 'notes001'@'%';
8+
drop user 'registrar001'@'%';
9+
drop user 'xqueue001'@'%';
10+
drop user 'analytics001'@'%';
11+
drop user 'edxapp001'@'%';

provision-mysql80.sql

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
CREATE DATABASE IF NOT EXISTS credentials;
2+
CREATE USER 'credentials001'@'%' IDENTIFIED BY 'password';
3+
GRANT ALL ON credentials.* TO 'credentials001'@'%';
4+
5+
CREATE DATABASE IF NOT EXISTS discovery;
6+
CREATE USER 'discov001'@'%' IDENTIFIED BY 'password';
7+
GRANT ALL ON discovery.* TO 'discov001'@'%';
8+
9+
CREATE DATABASE IF NOT EXISTS ecommerce;
10+
CREATE USER 'ecomm001'@'%' IDENTIFIED BY 'password';
11+
GRANT ALL ON ecommerce.* TO 'ecomm001'@'%';
12+
13+
CREATE DATABASE IF NOT EXISTS notes;
14+
CREATE USER 'notes001'@'%' IDENTIFIED BY 'password';
15+
GRANT ALL ON notes.* TO 'notes001'@'%';
16+
17+
CREATE DATABASE IF NOT EXISTS registrar;
18+
CREATE USER 'registrar001'@'%' IDENTIFIED BY 'password';
19+
GRANT ALL ON registrar.* TO 'registrar001'@'%';
20+
21+
CREATE DATABASE IF NOT EXISTS xqueue;
22+
CREATE USER 'xqueue001'@'%' IDENTIFIED BY 'password';
23+
GRANT ALL ON xqueue.* TO 'xqueue001'@'%';
24+
25+
CREATE DATABASE IF NOT EXISTS `dashboard`;
26+
CREATE USER 'analytics001'@'%' IDENTIFIED BY 'password';
27+
GRANT ALL ON `dashboard`.* TO 'analytics001'@'%';
28+
29+
CREATE DATABASE IF NOT EXISTS `analytics-api`;
30+
GRANT ALL ON `analytics-api`.* TO 'analytics001'@'%';
31+
32+
CREATE DATABASE IF NOT EXISTS `reports`;
33+
GRANT ALL ON `reports`.* TO 'analytics001'@'%';
34+
35+
CREATE DATABASE IF NOT EXISTS `reports_v1`;
36+
GRANT ALL ON `reports_v1`.* TO 'analytics001'@'%';
37+
38+
CREATE DATABASE IF NOT EXISTS edxapp;
39+
CREATE DATABASE IF NOT EXISTS edxapp_csmh;
40+
CREATE USER 'edxapp001'@'%' IDENTIFIED BY 'password';
41+
GRANT ALL ON edxapp.* TO 'edxapp001'@'%';
42+
GRANT ALL ON edxapp_csmh.* TO 'edxapp001'@'%';
43+
44+
FLUSH PRIVILEGES;

provision.sh

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,18 +123,27 @@ echo -e "${GREEN}Will provision the following:\n ${to_provision_ordered}${NC}"
123123

124124
# Bring the databases online.
125125
docker-compose up -d mysql57
126+
docker-compose up -d mysql80
126127
if needs_mongo "$to_provision_ordered"; then
127128
docker-compose up -d mongo
128129
fi
129130

130-
# Ensure the MySQL server is online and usable
131+
# Ensure the MySQL5 server is online and usable
131132
echo "${GREEN}Waiting for MySQL 5.7.${NC}"
132133
until docker-compose exec -T mysql57 bash -e -c "mysql -uroot -se \"SELECT EXISTS(SELECT 1 FROM mysql.user WHERE user = 'root')\"" &> /dev/null
133134
do
134135
printf "."
135136
sleep 1
136137
done
137138

139+
# Ensure the MySQL8 server is online and usable
140+
echo "${GREEN}Waiting for MySQL 8.0.${NC}"
141+
until docker-compose exec -T mysql80 bash -e -c "mysql -uroot -se \"SELECT EXISTS(SELECT 1 FROM mysql.user WHERE user = 'root')\"" &> /dev/null
142+
do
143+
printf "."
144+
sleep 1
145+
done
146+
138147
# In the event of a fresh MySQL container, wait a few seconds for the server to restart
139148
# See https://github.com/docker-library/mysql/issues/245 for why this is necessary.
140149
sleep 10
@@ -146,13 +155,23 @@ do
146155
sleep 1
147156
done
148157

149-
echo -e "${GREEN}MySQL ready.${NC}"
158+
echo -e "${GREEN}MySQL5 ready.${NC}"
159+
160+
echo "${GREEN}Waiting for MySQL 8.0 to restart.${NC}"
161+
until docker-compose exec -T mysql80 bash -e -c "mysql -uroot -se \"SELECT EXISTS(SELECT 1 FROM mysql.user WHERE user = 'root')\"" &> /dev/null
162+
do
163+
printf "."
164+
sleep 1
165+
done
150166

167+
echo -e "${GREEN}MySQL8 ready.${NC}"
151168

152169
# Ensure that the MySQL databases and users are created for all IDAs.
153170
# (A no-op for databases and users that already exist).
154171
echo -e "${GREEN}Ensuring MySQL 5.7 databases and users exist...${NC}"
155172
docker-compose exec -T mysql57 bash -e -c "mysql -uroot mysql" < provision.sql
173+
echo -e "${GREEN}Ensuring MySQL 8.0 databases and users exist...${NC}"
174+
docker-compose exec -T mysql80 bash -e -c "mysql -uroot mysql" < provision-mysql80.sql
156175

157176
# If necessary, ensure the MongoDB server is online and usable
158177
# and create its users.

0 commit comments

Comments
 (0)