Skip to content

Commit

Permalink
Merge pull request #984 from proditis/master
Browse files Browse the repository at this point in the history
make sure we dont fail on brand new startups
  • Loading branch information
proditis authored Aug 21, 2023
2 parents c86c39e + eb7a516 commit ff27e94
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 7 deletions.
4 changes: 2 additions & 2 deletions contrib/Dockerfile-mariadb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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; \
Expand Down
2 changes: 1 addition & 1 deletion docker-compose-novpn-macvlan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion docker-compose-novpn.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 12 additions & 2 deletions docs/DOCKER-COMPOSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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` 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"]
```
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
Expand Down

0 comments on commit ff27e94

Please sign in to comment.