diff --git a/CHANGELOG.md b/CHANGELOG.md index 4346f2b67c..5a045049e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/tests/test_env.py b/tests/test_env.py index e43afec07c..c884afa6f1 100644 --- a/tests/test_env.py +++ b/tests/test_env.py @@ -43,7 +43,7 @@ def test_render_file(self): 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") diff --git a/tutor/commands/local.py b/tutor/commands/local.py index 9903868f7e..ec6399ef0b 100644 --- a/tutor/commands/local.py +++ b/tutor/commands/local.py @@ -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") diff --git a/tutor/scripts.py b/tutor/scripts.py index a8d07a509b..947d1d75ad 100644 --- a/tutor/scripts.py +++ b/tutor/scripts.py @@ -36,7 +36,7 @@ def iter_plugin_hooks(self, hook): 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( diff --git a/tutor/templates/hooks/mysql-client/init b/tutor/templates/hooks/mysql/init similarity index 100% rename from tutor/templates/hooks/mysql-client/init rename to tutor/templates/hooks/mysql/init diff --git a/tutor/templates/k8s/deployments.yml b/tutor/templates/k8s/deployments.yml index f345380fcf..41ea9bf802 100644 --- a/tutor/templates/k8s/deployments.yml +++ b/tutor/templates/k8s/deployments.yml @@ -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 diff --git a/tutor/templates/kustomization.yml b/tutor/templates/kustomization.yml index 009615799e..04881b651e 100644 --- a/tutor/templates/kustomization.yml +++ b/tutor/templates/kustomization.yml @@ -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") }} \ No newline at end of file diff --git a/tutor/templates/local/docker-compose.yml b/tutor/templates/local/docker-compose.yml index ca1acc80a8..d730cf73c5 100644 --- a/tutor/templates/local/docker-compose.yml +++ b/tutor/templates/local/docker-compose.yml @@ -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) }}