6
0
mirror of https://github.com/ChristianLight/tutor.git synced 2024-12-12 06:07:56 +00:00

Get rid of mysql-client container

This has an impact on plugin hooks. Plugin hooks that needed to run
inside mysql-client now need to run inside mysql container. This
simplifies the deployment, as we no longer have an empty mysql-client
container sitting around.

When mysql is not enabled (ACTIVATE_MYSQL=False) the mysql container is
simply a mysql client.
This commit is contained in:
Régis Behmo 2019-09-03 10:36:10 +02:00
parent 14dd9e54a9
commit 0c0db78310
8 changed files with 33 additions and 54 deletions

View File

@ -4,6 +4,7 @@ Note: Breaking changes between versions are indicated by "💥".
## Latest
- 💥[Improvement] Get rid of mysql-client container
- [Improvement] Add "local-docker-compose-lms/cms-dependencies" plugin patches
- [Improvement] Use "exec" instead of "run" to initialise local platform

View File

@ -43,7 +43,7 @@ class EnvTests(unittest.TestCase):
config = {}
tutor_config.merge(config, tutor_config.load_defaults())
config["MYSQL_ROOT_PASSWORD"] = "testpassword"
rendered = env.render_file(config, "hooks", "mysql-client", "init")
rendered = env.render_file(config, "hooks", "mysql", "init")
self.assertIn("testpassword", rendered)
@unittest.mock.patch.object(tutor_config.fmt, "echo")

View File

@ -41,6 +41,7 @@ def quickstart(root, non_interactive, pullimages_):
start.callback(root, True, [])
click.echo(fmt.title("Database creation and migrations"))
init.callback(root)
echo_platform_info(config)
@click.command(help="Update docker images")
@ -62,25 +63,22 @@ def start(root, detach, services):
config = tutor_config.load(root)
docker_compose(root, config, *command, *services)
if detach:
fmt.echo_info("The Open edX platform is now running in detached mode")
http = "https" if config["ACTIVATE_HTTPS"] else "http"
urls = []
if not config["ACTIVATE_HTTPS"] and not config["WEB_PROXY"]:
urls += ["http://localhost", "http://studio.localhost"]
urls.append(
"{http}://{lms_host}".format(http=http, lms_host=config["LMS_HOST"])
)
urls.append(
"{http}://{cms_host}".format(http=http, cms_host=config["CMS_HOST"])
)
fmt.echo_info(
"""Your Open edX platform is ready and can be accessed at the following urls:
def echo_platform_info(config):
fmt.echo_info("The Open edX platform is now running in detached mode")
http = "https" if config["ACTIVATE_HTTPS"] else "http"
urls = []
if not config["ACTIVATE_HTTPS"] and not config["WEB_PROXY"]:
urls += ["http://localhost", "http://studio.localhost"]
urls.append("{http}://{lms_host}".format(http=http, lms_host=config["LMS_HOST"]))
urls.append("{http}://{cms_host}".format(http=http, cms_host=config["CMS_HOST"]))
fmt.echo_info(
"""Your Open edX platform is ready and can be accessed at the following urls:
{}""".format(
"\n ".join(urls)
)
"\n ".join(urls)
)
)
@click.command(help="Stop a running platform")

View File

@ -36,7 +36,7 @@ class BaseRunner:
def initialise(runner):
fmt.echo_info("Initialising all services...")
runner.run("mysql-client", "hooks", "mysql-client", "init")
runner.run("mysql", "hooks", "mysql", "init")
for plugin_name, hook in runner.iter_plugin_hooks("pre-init"):
for service in hook:
fmt.echo_info(

View File

@ -295,7 +295,6 @@ spec:
persistentVolumeClaim:
claimName: mongodb
{% endif %}
{% if ACTIVATE_MYSQL %}
---
apiVersion: apps/v1
kind: Deployment
@ -317,7 +316,12 @@ spec:
containers:
- name: mysql
image: {{ DOCKER_REGISTRY }}{{ DOCKER_IMAGE_MYSQL }}
{% if ACTIVATE_MYSQL %}
args: ["mysqld", "--character-set-server=utf8", "--collation-server=utf8_general_ci"]
{% else %}
command: ["sh", "-e", "-c"]
args: ["echo 'ready'; while true; do sleep 60; done"]
{% endif %}
env:
- name: MYSQL_ROOT_PASSWORD
valueFrom:
@ -326,6 +330,7 @@ spec:
key: MYSQL_ROOT_PASSWORD
ports:
- containerPort: 3306
{% if ACTIVATE_MYSQL %}
volumeMounts:
- mountPath: /var/lib/mysql
name: data
@ -333,28 +338,7 @@ spec:
- name: data
persistentVolumeClaim:
claimName: mysql
{% endif %}
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: mysql-client
labels:
app.kubernetes.io/name: mysql-client
spec:
selector:
matchLabels:
app.kubernetes.io/name: mysql-client
template:
metadata:
labels:
app.kubernetes.io/name: mysql-client
spec:
containers:
- name: mysql
image: {{ DOCKER_REGISTRY }}{{ DOCKER_IMAGE_MYSQL }}
command: ["sh", "-e", "-c"]
args: ["echo 'ready'; while true; do sleep 60; done"]
{% endif %}
{% if ACTIVATE_SMTP %}
---
apiVersion: apps/v1

View File

@ -34,8 +34,8 @@ configMapGenerator:
- name: nginx-config
files:{% for file in "apps/nginx"|walk_templates %}
- {{ file }}{% endfor %}
{% if ACTIVATE_MYSQL %}- name: mysql-config
env: apps/mysql/auth.env{% endif %}
- name: mysql-config
env: apps/mysql/auth.env
{{ patch("kustomization-configmapgenerator") }}
{{ patch("kustomization") }}

View File

@ -19,22 +19,18 @@ services:
- ../../data/mongodb:/data/db
{% endif %}
{% if ACTIVATE_MYSQL %}
mysql:
image: {{ DOCKER_REGISTRY }}{{ DOCKER_IMAGE_MYSQL }}
{% if ACTIVATE_MYSQL %}
command: mysqld --character-set-server=utf8 --collation-server=utf8_general_ci
{% else %}
entrypoint: ["sh", "-e", "-c"]
command: ["echo 'ready'; while true; do sleep 60; done"]
{% endif %}
restart: unless-stopped
volumes:
- ../../data/mysql:/var/lib/mysql
env_file: ../apps/mysql/auth.env
{% endif %}
mysql-client:
image: {{ DOCKER_REGISTRY }}{{ DOCKER_IMAGE_MYSQL }}
entrypoint: ["sh", "-e", "-c"]
command: ["echo 'ready'; while true; do sleep 60; done"]
restart: unless-stopped
{% if ACTIVATE_MYSQL%}depends_on:
- mysql{% endif %}
{% if ACTIVATE_ELASTICSEARCH %}
elasticsearch:
@ -123,11 +119,11 @@ services:
- ../../data/lms:/openedx/data
- ../../data/openedx-media:/openedx/media
depends_on:
- mysql
{% if ACTIVATE_ELASTICSEARCH %}- elasticsearch{% endif %}
{% if ACTIVATE_FORUM %}- forum{% endif %}
{% if ACTIVATE_MEMCACHED %}- memcached{% endif %}
{% if ACTIVATE_MONGODB %}- mongodb{% endif %}
{% if ACTIVATE_MYSQL %}- mysql{% endif %}
{% if ACTIVATE_RABBITMQ %}- rabbitmq{% endif %}
{% if ACTIVATE_SMTP %}- smtp{% endif %}
{{ patch("local-docker-compose-lms-dependencies")|indent(6) }}
@ -147,10 +143,10 @@ services:
- ../../data/cms:/openedx/data
- ../../data/openedx-media:/openedx/media
depends_on:
- mysql
{% if ACTIVATE_ELASTICSEARCH %}- elasticsearch{% endif %}
{% if ACTIVATE_MEMCACHED %}- memcached{% endif %}
{% if ACTIVATE_MONGODB %}- mongodb{% endif %}
{% if ACTIVATE_MYSQL %}- mysql{% endif %}
{% if ACTIVATE_RABBITMQ %}- rabbitmq{% endif %}
{% if ACTIVATE_SMTP %}- smtp{% endif %}
{{ patch("local-docker-compose-cms-dependencies")|indent(6) }}