Skip to content

Instantly share code, notes, and snippets.

@scupython
Last active August 29, 2015 13:57
Show Gist options
  • Save scupython/9614912 to your computer and use it in GitHub Desktop.
Save scupython/9614912 to your computer and use it in GitHub Desktop.
FROM elex/supervisor
RUN yum -y -q install mysql-server.x86_64 pwgen.x86_64
RUN yum -q clean all
ADD my.cnf /etc
ADD startup_mysql.sh /usr/bin
EXPOSE 3306
RUN echo -e [program:mysql]\\ncommand=/usr/bin/pidproxy /var/run/mysqld/mysqld.pid /usr/bin/mysqld_safe\\nautostart=true\\nautorestart=true\\nstartsecs=30\\nstartretries=3 >> /etc/supervisord.conf
CMD /bin/bash /usr/bin/startup_mysql.sh
[client]
port = 3306
socket = /var/lib/mysql/mysql.sock
[mysqld]
port = 3306
socket = /var/lib/mysql/mysql.sock
back_log = 50
max_connections = 100
max_connect_errors = 10
table_open_cache = 2048
max_allowed_packet = 16M
binlog_cache_size = 1M
max_heap_table_size = 64M
read_buffer_size = 2M
read_rnd_buffer_size = 16M
sort_buffer_size = 8M
join_buffer_size = 8M
thread_cache_size = 8
thread_concurrency = 8
query_cache_size = 64M
query_cache_limit = 2M
ft_min_word_len = 4
default-storage-engine = MYISAM
thread_stack = 192K
transaction_isolation = REPEATABLE-READ
tmp_table_size = 64M
log-bin=mysql-bin
binlog_format=mixed
slow_query_log
long_query_time = 2
server-id = 1
key_buffer_size = 32M
bulk_insert_buffer_size = 64M
myisam_sort_buffer_size = 128M
myisam_max_sort_file_size = 10G
myisam_repair_threads = 1
myisam_recover
innodb_additional_mem_pool_size = 16M
innodb_buffer_pool_size = 2G
innodb_data_file_path = ibdata1:10M:autoextend
innodb_file_io_threads = 4
innodb_thread_concurrency = 16
innodb_flush_log_at_trx_commit = 1
innodb_log_buffer_size = 8M
innodb_log_file_size = 256M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 90
innodb_lock_wait_timeout = 120
[mysqldump]
quick
max_allowed_packet = 16M
[mysql]
no-auto-rehash
[myisamchk]
key_buffer_size = 512M
sort_buffer_size = 512M
read_buffer = 8M
write_buffer = 8M
[mysqlhotcopy]
interactive-timeout
[mysqld_safe]
open-files-limit = 8192
socket= /var/run/mysqld/mysqld.sock
#/bin/bash
if [ ! -d /var/run/mysqld ]; then
install -m 755 -o mysql -g root -d /var/run/mysqld
fi
if [ ! -f /var/lib/mysql/ibdata1 ]; then
mysql_install_db
/usr/bin/mysqld_safe > /dev/null 2>&1 &
PASS=${MYSQL_PASS:-$(pwgen -s 12 1)}
_word=$( [ ${MYSQL_PASS} ] && echo "preset" || echo "random" )
echo "=> Creating MySQL admin user with ${_word} password"
RET=1
while [[ RET -ne 0 ]]; do
sleep 5
mysql -uroot -e "CREATE USER 'admin'@'%' IDENTIFIED BY '$PASS'"
RET=$?
done
mysql -uroot -e "GRANT ALL PRIVILEGES ON *.* TO 'admin'@'%' WITH GRANT OPTION"
mysqladmin -uroot shutdown
echo "=> Done!"
echo "========================================================================"
echo "You can now connect to this MySQL Server using:"
echo ""
echo " mysql -uadmin -p$PASS -h<host> -P<port>"
echo ""
echo "Please remember to change the above password as soon as possible!"
echo "MySQL user 'root' has no password but only allows local connections"
echo "========================================================================"
fi
/usr/bin/mysqld_safe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment