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

Commit 5e13ef5

Browse files
committed
feat: mysql 8 with credentials
1 parent f7dad96 commit 5e13ef5

4 files changed

Lines changed: 96 additions & 4 deletions

File tree

docker-compose.yml

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,23 @@ services:
254254
volumes:
255255
- mysql57_data:/var/lib/mysql
256256

257+
mysql80:
258+
command: mysqld --character-set-server=utf8 --collation-server=utf8_general_ci
259+
container_name: "edx.${COMPOSE_PROJECT_NAME:-devstack}.mysql80"
260+
hostname: mysql80.devstack.edx
261+
environment:
262+
MYSQL_ROOT_PASSWORD: ""
263+
MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
264+
image: mysql:latest
265+
networks:
266+
default:
267+
aliases:
268+
- edx.devstack.mysql80
269+
ports:
270+
- "3406:3306"
271+
volumes:
272+
- mysql80_data:/var/lib/mysql
273+
257274
redis:
258275
container_name: "edx.${COMPOSE_PROJECT_NAME:-devstack}.redis"
259276
hostname: redis.devstack.edx
@@ -309,13 +326,13 @@ services:
309326
depends_on:
310327
- lms
311328
- memcached
312-
- mysql57
329+
- mysql80
313330
# Allows attachment to the credentials service using 'docker attach <containerID>'.
314331
stdin_open: true
315332
tty: true
316333
environment:
317334
CACHE_LOCATION: edx.devstack.memcached:11211
318-
DB_HOST: edx.devstack.mysql57
335+
DB_HOST: edx.devstack.mysql80
319336
SOCIAL_AUTH_EDX_OIDC_URL_ROOT: http://edx.devstack.lms:18000/oauth2
320337
ENABLE_DJANGO_TOOLBAR: 1
321338
DJANGO_WATCHMAN_TIMEOUT: 30
@@ -867,3 +884,4 @@ volumes:
867884
mongo_data:
868885
opensearch12_data:
869886
mysql57_data:
887+
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
@@ -124,18 +124,27 @@ echo -e "${GREEN}Will provision the following:\n ${to_provision_ordered}${NC}"
124124

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

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

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

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

168+
echo -e "${GREEN}MySQL8 ready.${NC}"
152169

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

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

0 commit comments

Comments
 (0)