Optimización docker salix-db

This commit is contained in:
Juan Ferrer 2020-09-28 10:40:50 +02:00
parent 2d1cf566f8
commit 5264b615d4
9 changed files with 61 additions and 40 deletions

View File

@ -14,20 +14,41 @@ RUN apt-get update \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
COPY docker/docker.cnf /etc/mysql/conf.d/ 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 \ RUN mkdir /mysql-data \
&& chown -R mysql:mysql /mysql-data && chown -R mysql:mysql /mysql-data
COPY dump /docker-boot/dump WORKDIR /docker-boot
COPY changes /docker-boot/changes
COPY import-changes.sh config.ini /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 ARG STAMP=unknown
RUN gosu mysql docker-init.sh mysqld \ RUN gosu mysql docker-temp-start.sh \
&& rm -rf /docker-entrypoint-initdb.d/* \ && ./import-changes.sh \
&& docker-dump.sh fixtures \
&& gosu mysql docker-temp-stop.sh
RUN echo "[INFO] -> Import finished" \
&& rm -rf /docker-boot && rm -rf /docker-boot
USER mysql USER mysql
@ -35,5 +56,5 @@ ENTRYPOINT ["docker-start.sh"]
CMD ["mysqld"] CMD ["mysqld"]
HEALTHCHECK --interval=5s --timeout=10s --retries=200 \ HEALTHCHECK --interval=2s --timeout=10s --retries=200 \
CMD mysqladmin ping -h 127.0.0.1 -u root || exit 1 CMD mysqladmin ping -h 127.0.0.1 -u root --password=root || exit 1

View File

@ -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.
*/

View File

@ -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
*/

View File

@ -53,7 +53,7 @@ module.exports = class Docker {
this.dbConf.port = netSettings.Ports['3306/tcp'][0]['HostPort']; this.dbConf.port = netSettings.Ports['3306/tcp'][0]['HostPort'];
} }
await this.waitForHealthy(); await this.wait();
} catch (err) { } catch (err) {
if (this.isRandom) if (this.isRandom)
await this.rm(); await this.rm();
@ -147,7 +147,7 @@ module.exports = class Docker {
let state; let state;
try { 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); state = JSON.parse(result.stdout);
} catch (err) { } catch (err) {
return reject(new Error(err.message)); return reject(new Error(err.message));

View File

@ -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"

6
db/docker/docker-dump.sh Executable file
View File

@ -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"

View File

@ -1,16 +1,14 @@
#!/bin/bash #!/bin/bash
. /usr/local/bin/docker-entrypoint.sh . /usr/local/bin/docker-entrypoint.sh
CMD=mysqld
mysql_check_config "$@" mysql_check_config "$CMD"
docker_setup_env "$@" docker_setup_env "$CMD"
docker_create_db_directories docker_create_db_directories
docker_verify_minimum_env docker_verify_minimum_env
docker_init_database_dir "$@" docker_init_database_dir "$CMD"
docker_temp_server_start "$@" docker_temp_server_start "$CMD"
docker_setup_db docker_setup_db
docker_process_init_files /docker-entrypoint-initdb.d/* docker_process_init_files /docker-entrypoint-initdb.d/*
docker_temp_server_stop

7
db/docker/docker-temp-start.sh Executable file
View File

@ -0,0 +1,7 @@
#!/bin/bash
. /usr/local/bin/docker-entrypoint.sh
CMD=mysqld
docker_setup_env "$CMD"
docker_temp_server_start "$CMD"

7
db/docker/docker-temp-stop.sh Executable file
View File

@ -0,0 +1,7 @@
#!/bin/bash
. /usr/local/bin/docker-entrypoint.sh
CMD=mysqld
docker_setup_env "$CMD"
docker_temp_server_stop