From d01281ae9fd8a86268e0d54ae94a3f4cc9f48fb7 Mon Sep 17 00:00:00 2001 From: Pantelis Roditis Date: Mon, 21 Aug 2023 12:56:32 +0300 Subject: [PATCH 1/3] update the location of mysql-init --- contrib/Dockerfile-mariadb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contrib/Dockerfile-mariadb b/contrib/Dockerfile-mariadb index aaedbdcf1..7ed609615 100644 --- a/contrib/Dockerfile-mariadb +++ b/contrib/Dockerfile-mariadb @@ -8,7 +8,7 @@ ENV MYSQL_DATABASE echoCTF ENV DEBIAN_FRONTEND noninteractive WORKDIR /always-initdb.d/ -COPY contrib/mysql-init.sql /always-initdb.d/99_mysql-init.sql +COPY contrib/mysql-init.sql /etc/mysql-init.sql COPY schemas/echoCTF.sql /docker-entrypoint-initdb.d/01.sql COPY schemas/echoCTF-routines.sql /docker-entrypoint-initdb.d/02.sql COPY schemas/echoCTF-triggers.sql /docker-entrypoint-initdb.d/03.sql @@ -39,7 +39,7 @@ RUN set -ex; \ echo "/usr/bin/memcached -d -M -m ${MEMCACHED_MEM} -p 11211 -u mysql -l 0.0.0.0 -o no_maxconns_fast,no_modern -P /tmp/memcached.pid -L --disable-cas" >> /always-initdb.d/00.sh; \ chmod +x /always-initdb.d/00.sh; \ cat sql/install_functions.sql>> /docker-entrypoint-initdb.d/00.sql; \ - sed -i -e "s/echoCTF/${MYSQL_DATABASE}/g" /always-initdb.d/99_mysql-init.sql; \ + sed -i -e "s/echoCTF/${MYSQL_DATABASE}/g" /etc/mysql-init.sql; \ chmod +x /usr/local/bin/docker-entrypoint.sh; \ apt-get purge -y build-essential gcc autoconf automake git zip unzip mcrypt libmariadb-dev libtool; \ apt-get autoremove -y; \ From 4a66863b09df168b1af257f1794eb91b140ca357 Mon Sep 17 00:00:00 2001 From: Pantelis Roditis Date: Mon, 21 Aug 2023 12:57:08 +0300 Subject: [PATCH 2/3] update the docker-compose and its dock --- docker-compose-novpn-macvlan.yml | 2 +- docker-compose-novpn.yml | 2 +- docker-compose.yml | 2 +- docs/DOCKER-COMPOSE.md | 14 ++++++++++++-- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/docker-compose-novpn-macvlan.yml b/docker-compose-novpn-macvlan.yml index 22f31a14e..88b86aea9 100644 --- a/docker-compose-novpn-macvlan.yml +++ b/docker-compose-novpn-macvlan.yml @@ -7,7 +7,7 @@ services: context: . dockerfile: contrib/Dockerfile-mariadb restart: "always" - command: ["mysqld","--character-set-server=utf8mb4", "--collation-server=utf8mb4_unicode_ci","--skip-character-set-client-handshake","--init_file=/always-initdb.d/99_mysql-init.sql"] + command: ["mysqld","--character-set-server=utf8mb4", "--collation-server=utf8mb4_unicode_ci","--skip-character-set-client-handshake"] #, "--init_file=/etc/mysql-init.sql"] volumes: - data-mysql:/var/lib/mysql environment: diff --git a/docker-compose-novpn.yml b/docker-compose-novpn.yml index f415c073b..3c16bf4f6 100644 --- a/docker-compose-novpn.yml +++ b/docker-compose-novpn.yml @@ -7,7 +7,7 @@ services: context: . dockerfile: contrib/Dockerfile-mariadb restart: "always" - command: ["mysqld","--character-set-server=utf8mb4", "--collation-server=utf8mb4_unicode_ci","--skip-character-set-client-handshake","--init_file=/always-initdb.d/99_mysql-init.sql"] + command: ["mysqld","--character-set-server=utf8mb4", "--collation-server=utf8mb4_unicode_ci","--skip-character-set-client-handshake"] #, "--init_file=/etc/mysql-init.sql"] # ports: # - 3306:3306 # - 11211:11211 diff --git a/docker-compose.yml b/docker-compose.yml index 3e7cd5694..5054df0e0 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,7 +8,7 @@ services: context: . dockerfile: contrib/Dockerfile-mariadb restart: "always" - command: ["mysqld","--character-set-server=utf8mb4", "--collation-server=utf8mb4_unicode_ci","--skip-character-set-client-handshake", "--init_file=/always-initdb.d/99_mysql-init.sql"] + command: ["mysqld","--character-set-server=utf8mb4", "--collation-server=utf8mb4_unicode_ci","--skip-character-set-client-handshake"] #, "--init_file=/etc/mysql-init.sql"] # ports: # - 3306:3306 # - 11211:11211 diff --git a/docs/DOCKER-COMPOSE.md b/docs/DOCKER-COMPOSE.md index 859439992..2e8692b6b 100644 --- a/docs/DOCKER-COMPOSE.md +++ b/docs/DOCKER-COMPOSE.md @@ -43,10 +43,20 @@ chmod a+rw frontend/web/images/{avatars,avatars/badges,targets} docker-compose up ``` -NOTE: You need to pull the images manually with `docker pull`. - The first time you run `docker-compose up` give the containers a few minutes to complete the startup process. +Once the initialization process completes, run the following command to connect the mysql server with the memcached +```shell +docker exec -it echoctfred_db bash -c "mysql < /etc/mysql-init.sql" +``` + +This command will have to be run every time the database server stops or respawned by eg `docker-compose down`. You can make the change permanent by appending `, "--init_file=/etc/mysql-init.sql"` to the db `command` parameters before the closing bracket `]`. +```yaml +command: ["mysqld","--character-set-server=utf8mb4", "--collation-server=utf8mb4_unicode_ci","--skip-character-set-client-handshake", "--init_file=/etc/mysql-init.sql"] +``` + +NOTE: You need to pull the images manually with `docker pull`. + If you'd rather to build your own images make you sure you generate a Github OAuth Token to be used by the composer utility. This is needed in order to avoid hitting Github rate limits on their API, which is used by `composer`. More information From eb7a5168f89e4cd1532ef5baca9b688a40d2ecab Mon Sep 17 00:00:00 2001 From: Pantelis Roditis Date: Mon, 21 Aug 2023 13:00:16 +0300 Subject: [PATCH 3/3] make it clear that only after the systems are init --- docs/DOCKER-COMPOSE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/DOCKER-COMPOSE.md b/docs/DOCKER-COMPOSE.md index 2e8692b6b..cb9a0ea66 100644 --- a/docs/DOCKER-COMPOSE.md +++ b/docs/DOCKER-COMPOSE.md @@ -50,7 +50,7 @@ Once the initialization process completes, run the following command to connect docker exec -it echoctfred_db bash -c "mysql < /etc/mysql-init.sql" ``` -This command will have to be run every time the database server stops or respawned by eg `docker-compose down`. You can make the change permanent by appending `, "--init_file=/etc/mysql-init.sql"` to the db `command` parameters before the closing bracket `]`. +This command will have to be run every time the database server stops or respawned by eg `docker-compose down` and only once the systems are fully initialized. You can make the change permanent by appending `, "--init_file=/etc/mysql-init.sql"` to the db `command` parameters before the closing bracket `]`. ```yaml command: ["mysqld","--character-set-server=utf8mb4", "--collation-server=utf8mb4_unicode_ci","--skip-character-set-client-handshake", "--init_file=/etc/mysql-init.sql"] ```