Окончено внедрение докера для развёртывания dev-окружения

This commit is contained in:
ErickSkrauch
2016-05-10 01:49:50 +03:00
parent 7b7ed0ad51
commit 23d6975399
28 changed files with 425 additions and 117 deletions

13
docker/mariadb/Dockerfile Normal file
View File

@@ -0,0 +1,13 @@
FROM mariadb:10.0
COPY mariadb.cnf /etc/mysql/conf.d
# Add script to create default users / vhosts
ADD init.sh /init.sh
ADD run.sh /run.sh
# Run rabbitmq, execute init configuration and then shutdown
RUN chmod +x /init.sh /run.sh \
&& /init.sh
ENTRYPOINT "/run.sh"

34
docker/mariadb/init.sh Normal file
View File

@@ -0,0 +1,34 @@
#!/bin/bash
# Копипаста. Я не знаю, что тут происходит
set -e
set -x
mysql_install_db
# Start the MySQL daemon in the background.
/usr/sbin/mysqld &
mysql_pid=$!
until mysqladmin ping &>/dev/null; do
echo -n "."; sleep 0.2
done
# Конец рандомной копипасты
# Устаналиваем беспарольный доступ для рута
mysql -e "GRANT ALL ON *.* TO root@'%' IDENTIFIED BY '' WITH GRANT OPTION"
# Создаём базу данных для приложения и для тестов
mysql -e "CREATE DATABASE IF NOT EXISTS ely_accounts CHARACTER SET utf8 COLLATE utf8_general_ci"
mysql -e "CREATE DATABASE IF NOT EXISTS ely_accounts_test CHARACTER SET utf8 COLLATE utf8_general_ci"
# Tell the MySQL daemon to shutdown.
mysqladmin shutdown
# Wait for the MySQL daemon to exit.
wait $mysql_pid
# Сохраняем состояние базы данных
tar czvf default_mysql.tar.gz /var/lib/mysql

View File

9
docker/mariadb/run.sh Normal file
View File

@@ -0,0 +1,9 @@
#!/bin/bash
set -e
set -x
# first, if the /var/lib/mysql directory is empty, unpack it from our predefined db
[ "$(ls -A /var/lib/mysql)" ] && echo "Running with existing database in /var/lib/mysql" || ( echo 'Populate initial db'; tar xpzvf default_mysql.tar.gz )
/usr/sbin/mysqld