From 5264b615d4c6269a266b5db58b2d4a65854f2ae3 Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Mon, 28 Sep 2020 10:40:50 +0200 Subject: [PATCH 1/3] =?UTF-8?q?Optimizaci=C3=B3n=20docker=20salix-db?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/Dockerfile | 39 ++++++++++++++++++++++++------- db/PASTE_COMMENT_REMINDER | 4 ++++ db/changes/PASTE_COMMENT_REMINDER | 4 ---- db/docker.js | 4 ++-- db/docker/docker-boot.sh | 18 -------------- db/docker/docker-dump.sh | 6 +++++ db/docker/docker-init.sh | 12 ++++------ db/docker/docker-temp-start.sh | 7 ++++++ db/docker/docker-temp-stop.sh | 7 ++++++ 9 files changed, 61 insertions(+), 40 deletions(-) create mode 100644 db/PASTE_COMMENT_REMINDER delete mode 100644 db/changes/PASTE_COMMENT_REMINDER delete mode 100755 db/docker/docker-boot.sh create mode 100755 db/docker/docker-dump.sh create mode 100755 db/docker/docker-temp-start.sh create mode 100755 db/docker/docker-temp-stop.sh diff --git a/db/Dockerfile b/db/Dockerfile index 00d54993a..8980c34f4 100644 --- a/db/Dockerfile +++ b/db/Dockerfile @@ -14,20 +14,41 @@ RUN apt-get update \ && rm -rf /var/lib/apt/lists/* COPY docker/docker.cnf /etc/mysql/conf.d/ -COPY docker/docker-init.sh docker/docker-start.sh /usr/local/bin/ +COPY \ + docker/docker-init.sh \ + docker/docker-temp-start.sh \ + docker/docker-temp-stop.sh \ + docker/docker-dump.sh \ + docker/docker-start.sh \ + /usr/local/bin/ RUN mkdir /mysql-data \ && chown -R mysql:mysql /mysql-data -COPY dump /docker-boot/dump -COPY changes /docker-boot/changes -COPY import-changes.sh config.ini /docker-boot/ +WORKDIR /docker-boot -COPY docker/docker-boot.sh /docker-entrypoint-initdb.d/ +COPY \ + import-changes.sh \ + config.ini \ + dump/mysqlPlugins.sql \ + dump/structure.sql \ + dump/dumpedFixtures.sql \ + ./ +RUN gosu mysql docker-init.sh \ + && docker-dump.sh mysqlPlugins \ + && docker-dump.sh structure \ + && docker-dump.sh dumpedFixtures \ + && gosu mysql docker-temp-stop.sh +COPY changes ./changes +COPY dump/fixtures.sql ./ ARG STAMP=unknown -RUN gosu mysql docker-init.sh mysqld \ - && rm -rf /docker-entrypoint-initdb.d/* \ +RUN gosu mysql docker-temp-start.sh \ + && ./import-changes.sh \ + && docker-dump.sh fixtures \ + && gosu mysql docker-temp-stop.sh + +RUN echo "[INFO] -> Import finished" \ && rm -rf /docker-boot USER mysql @@ -35,5 +56,5 @@ ENTRYPOINT ["docker-start.sh"] CMD ["mysqld"] -HEALTHCHECK --interval=5s --timeout=10s --retries=200 \ - CMD mysqladmin ping -h 127.0.0.1 -u root || exit 1 +HEALTHCHECK --interval=2s --timeout=10s --retries=200 \ + CMD mysqladmin ping -h 127.0.0.1 -u root --password=root || exit 1 diff --git a/db/PASTE_COMMENT_REMINDER b/db/PASTE_COMMENT_REMINDER new file mode 100644 index 000000000..f4468157f --- /dev/null +++ b/db/PASTE_COMMENT_REMINDER @@ -0,0 +1,4 @@ +/** + * Hay una versión en salix que machacará toda esta función/procedimiento avisa + * a ___ de los cambios que quieres hacer. + */ \ No newline at end of file diff --git a/db/changes/PASTE_COMMENT_REMINDER b/db/changes/PASTE_COMMENT_REMINDER deleted file mode 100644 index 07b707920..000000000 --- a/db/changes/PASTE_COMMENT_REMINDER +++ /dev/null @@ -1,4 +0,0 @@ -/* -Hay una versión en salix que machacará toda esta función/procedimiento -avisa a ___ de los cambios que quieres hacer -*/ \ No newline at end of file diff --git a/db/docker.js b/db/docker.js index 0cb912be6..ff330f824 100644 --- a/db/docker.js +++ b/db/docker.js @@ -53,7 +53,7 @@ module.exports = class Docker { this.dbConf.port = netSettings.Ports['3306/tcp'][0]['HostPort']; } - await this.waitForHealthy(); + await this.wait(); } catch (err) { if (this.isRandom) await this.rm(); @@ -147,7 +147,7 @@ module.exports = class Docker { let state; try { - let result = await this.execP(`docker container inspect -f "{{json .State}}" ${this.id}`); + let result = await this.execP(`docker inspect -f "{{json .State}}" ${this.id}`); state = JSON.parse(result.stdout); } catch (err) { return reject(new Error(err.message)); diff --git a/db/docker/docker-boot.sh b/db/docker/docker-boot.sh deleted file mode 100755 index 5e8ad4c6c..000000000 --- a/db/docker/docker-boot.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash - -cd /docker-boot -export MYSQL_PWD=root - -mysql_import() { - FILE=$1 - echo "[INFO] -> Importing $FILE" - mysql -u root --default-character-set=utf8 --comments -f < "$FILE" -} - -mysql_import dump/structure.sql -mysql_import dump/mysqlPlugins.sql -mysql_import dump/dumpedFixtures.sql -./import-changes.sh -mysql_import dump/fixtures.sql - -echo "[INFO] -> Import finished" diff --git a/db/docker/docker-dump.sh b/db/docker/docker-dump.sh new file mode 100755 index 000000000..0d7a379a7 --- /dev/null +++ b/db/docker/docker-dump.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +export MYSQL_PWD=root +FILE="/docker-boot/$1.sql" +echo "[INFO] -> Importing $FILE" +mysql -u root --default-character-set=utf8 --comments -f < "$FILE" diff --git a/db/docker/docker-init.sh b/db/docker/docker-init.sh index f2c9d58d7..ccd14283e 100755 --- a/db/docker/docker-init.sh +++ b/db/docker/docker-init.sh @@ -1,16 +1,14 @@ #!/bin/bash . /usr/local/bin/docker-entrypoint.sh +CMD=mysqld -mysql_check_config "$@" -docker_setup_env "$@" +mysql_check_config "$CMD" +docker_setup_env "$CMD" docker_create_db_directories docker_verify_minimum_env -docker_init_database_dir "$@" -docker_temp_server_start "$@" +docker_init_database_dir "$CMD" +docker_temp_server_start "$CMD" docker_setup_db - docker_process_init_files /docker-entrypoint-initdb.d/* - -docker_temp_server_stop diff --git a/db/docker/docker-temp-start.sh b/db/docker/docker-temp-start.sh new file mode 100755 index 000000000..fc067102f --- /dev/null +++ b/db/docker/docker-temp-start.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +. /usr/local/bin/docker-entrypoint.sh +CMD=mysqld + +docker_setup_env "$CMD" +docker_temp_server_start "$CMD" diff --git a/db/docker/docker-temp-stop.sh b/db/docker/docker-temp-stop.sh new file mode 100755 index 000000000..df66959df --- /dev/null +++ b/db/docker/docker-temp-stop.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +. /usr/local/bin/docker-entrypoint.sh +CMD=mysqld + +docker_setup_env "$CMD" +docker_temp_server_stop From 2c9f664d01e04348907b0b1ed5532f38bc4771bc Mon Sep 17 00:00:00 2001 From: joan Date: Mon, 28 Sep 2020 14:14:14 +0200 Subject: [PATCH 2/3] Enabled back unit tests --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index d07b47809..e08c319ea 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -69,13 +69,13 @@ pipeline { } } } - /* stage('Backend') { + stage('Backend') { steps { nodejs('node-lts') { sh 'gulp backTestOnce --ci' } } - } */ + } } } stage('Build') { From 991bece64a6f1c65139829dd867cf79d18460f15 Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Mon, 28 Sep 2020 21:25:53 +0200 Subject: [PATCH 3/3] SQL fixes --- db/changes/10221-accountModule/00-user_getNameFromId.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/changes/10221-accountModule/00-user_getNameFromId.sql b/db/changes/10221-accountModule/00-user_getNameFromId.sql index ae9ae5941..fc3b721c5 100644 --- a/db/changes/10221-accountModule/00-user_getNameFromId.sql +++ b/db/changes/10221-accountModule/00-user_getNameFromId.sql @@ -13,8 +13,8 @@ BEGIN SELECT `name` INTO vName FROM user - WHERE id = vId; + WHERE id = vSelf; - RETURN vSelf; + RETURN vName; END$$ DELIMITER ;