This repository has been archived by the owner on Nov 29, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 249
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from tutumcloud/staging
refactored tags, created tests
- Loading branch information
Showing
16 changed files
with
155 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,10 @@ FROM ubuntu:trusty | |
MAINTAINER Fernando Mayo <[email protected]>, Feng Honglin <[email protected]> | ||
|
||
# Install packages | ||
RUN apt-get update | ||
RUN DEBIAN_FRONTEND=noninteractive apt-get -y install mysql-server pwgen | ||
ENV DEBIAN_FRONTEND noninteractive | ||
RUN apt-get update && \ | ||
apt-get -yq install mysql-server-5.5 pwgen && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
# Remove pre-installed database | ||
RUN rm -rf /var/lib/mysql/* | ||
|
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
FROM ubuntu:trusty | ||
MAINTAINER Fernando Mayo <[email protected]>, Feng Honglin <[email protected]> | ||
|
||
# Install packages | ||
ENV DEBIAN_FRONTEND noninteractive | ||
RUN apt-get update && \ | ||
apt-get -yq install mysql-server-5.6 pwgen && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
# Remove pre-installed database | ||
RUN rm -rf /var/lib/mysql/* | ||
|
||
# Add MySQL configuration | ||
ADD my.cnf /etc/mysql/conf.d/my.cnf | ||
ADD mysqld_charset.cnf /etc/mysql/conf.d/mysqld_charset.cnf | ||
|
||
# Add MySQL scripts | ||
ADD create_mysql_admin_user.sh /create_mysql_admin_user.sh | ||
ADD import_sql.sh /import_sql.sh | ||
ADD run.sh /run.sh | ||
RUN chmod 755 /*.sh | ||
|
||
# Exposed ENV | ||
ENV MYSQL_USER admin | ||
ENV MYSQL_PASS **Random** | ||
|
||
# Add VOLUMEs to allow backup of config and databases | ||
VOLUME ["/etc/mysql", "/var/lib/mysql"] | ||
|
||
EXPOSE 3306 | ||
CMD ["/run.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/bash | ||
|
||
if [[ $# -eq 0 ]]; then | ||
echo "Usage: $0 <db_name>" | ||
exit 1 | ||
fi | ||
|
||
/usr/bin/mysqld_safe > /dev/null 2>&1 & | ||
|
||
echo "=> Creating database $1" | ||
RET=1 | ||
while [[ RET -ne 0 ]]; do | ||
sleep 5 | ||
mysql -uroot -e "CREATE DATABASE $1" | ||
RET=$? | ||
done | ||
|
||
mysqladmin -uroot shutdown | ||
|
||
echo "=> Done!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/bin/bash | ||
|
||
/usr/bin/mysqld_safe > /dev/null 2>&1 & | ||
|
||
RET=1 | ||
while [[ RET -ne 0 ]]; do | ||
echo "=> Waiting for confirmation of MySQL service startup" | ||
sleep 5 | ||
mysql -uroot -e "status" > /dev/null 2>&1 | ||
RET=$? | ||
done | ||
|
||
if [ "$MYSQL_PASS" = "**Random**" ]; then | ||
unset MYSQL_PASS | ||
fi | ||
|
||
PASS=${MYSQL_PASS:-$(pwgen -s 12 1)} | ||
_word=$( [ ${MYSQL_PASS} ] && echo "preset" || echo "random" ) | ||
echo "=> Creating MySQL user ${MYSQL_USER} with ${_word} password" | ||
|
||
mysql -uroot -e "CREATE USER '${MYSQL_USER}'@'%' IDENTIFIED BY '$PASS'" | ||
mysql -uroot -e "GRANT ALL PRIVILEGES ON *.* TO '${MYSQL_USER}'@'%' WITH GRANT OPTION" | ||
|
||
|
||
echo "=> Done!" | ||
|
||
echo "========================================================================" | ||
echo "You can now connect to this MySQL Server using:" | ||
echo "" | ||
echo " mysql -u$MYSQL_USER -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 "========================================================================" | ||
|
||
mysqladmin -uroot shutdown |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/bash | ||
|
||
if [[ $# -ne 2 ]]; then | ||
echo "Usage: $0 <password> </path/to/sql_file.sql>" | ||
exit 1 | ||
fi | ||
|
||
echo "=> Starting MySQL Server" | ||
/usr/bin/mysqld_safe > /dev/null 2>&1 & | ||
sleep 5 | ||
echo " Started with PID $!" | ||
|
||
echo "=> Importing SQL file" | ||
mysql -uadmin -p"$1" < "$2" | ||
|
||
echo "=> Stopping MySQL Server" | ||
mysqladmin -uadmin -p"$1" shutdown | ||
|
||
echo "=> Done!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[mysqld] | ||
bind-address=0.0.0.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[mysqld] | ||
character_set_server=utf8 | ||
character_set_filesystem=utf8 | ||
collation-server=utf8_general_ci | ||
init-connect='SET NAMES utf8' | ||
init_connect='SET collation_connection = utf8_general_ci' | ||
skip-character-set-client-handshake |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/bin/bash | ||
|
||
VOLUME_HOME="/var/lib/mysql" | ||
|
||
if [[ ! -d $VOLUME_HOME/mysql ]]; then | ||
echo "=> An empty or uninitialized MySQL volume is detected in $VOLUME_HOME" | ||
echo "=> Installing MySQL ..." | ||
if [ ! -f /usr/share/mysql/my-default.cnf ] ; then | ||
cp /etc/mysql/my.cnf /usr/share/mysql/my-default.cnf | ||
fi | ||
mysql_install_db > /dev/null 2>&1 | ||
echo "=> Done!" | ||
/create_mysql_admin_user.sh | ||
else | ||
echo "=> Using an existing volume of MySQL" | ||
fi | ||
|
||
exec mysqld_safe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
machine: | ||
services: | ||
- docker | ||
dependencies: | ||
override: | ||
- docker build -t mysql-5.5 5.5/ | ||
- docker build -t mysql-5.6 5.6/ | ||
test: | ||
override: | ||
- docker run -d -p 13306:3306 -e MYSQL_USER="user" -e MYSQL_PASS="test" mysql-5.5; sleep 20 | ||
- mysqladmin -uuser -ptest ping -h127.0.0.1 -P13306 | grep -c "mysqld is alive" | ||
- docker run -d -p 13307:3306 -e MYSQL_USER="user" -e MYSQL_PASS="test" mysql-5.6; sleep 20 | ||
- mysqladmin -uuser -ptest ping -h127.0.0.1 -P13307 | grep -c "mysqld is alive" |