Skip to content
This repository was archived by the owner on Nov 29, 2020. It is now read-only.

Commit edf77b0

Browse files
committed
Merge pull request #22 from tutumcloud/staging
refactored tags, created tests
2 parents 780d306 + ebfadd1 commit edf77b0

16 files changed

+155
-6
lines changed

Dockerfile renamed to 5.5/Dockerfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ FROM ubuntu:trusty
22
MAINTAINER Fernando Mayo <[email protected]>, Feng Honglin <[email protected]>
33

44
# Install packages
5-
RUN apt-get update
6-
RUN DEBIAN_FRONTEND=noninteractive apt-get -y install mysql-server pwgen
5+
ENV DEBIAN_FRONTEND noninteractive
6+
RUN apt-get update && \
7+
apt-get -yq install mysql-server-5.5 pwgen && \
8+
rm -rf /var/lib/apt/lists/*
79

810
# Remove pre-installed database
911
RUN rm -rf /var/lib/mysql/*
File renamed without changes.
File renamed without changes.
File renamed without changes.

my.cnf renamed to 5.5/my.cnf

File renamed without changes.
File renamed without changes.

run.sh renamed to 5.5/run.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ VOLUME_HOME="/var/lib/mysql"
55
if [[ ! -d $VOLUME_HOME/mysql ]]; then
66
echo "=> An empty or uninitialized MySQL volume is detected in $VOLUME_HOME"
77
echo "=> Installing MySQL ..."
8+
if [ ! -f /usr/share/mysql/my-default.cnf ] ; then
9+
cp /etc/mysql/my.cnf /usr/share/mysql/my-default.cnf
10+
fi
811
mysql_install_db > /dev/null 2>&1
912
echo "=> Done!"
1013
/create_mysql_admin_user.sh

5.6/Dockerfile

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
FROM ubuntu:trusty
2+
MAINTAINER Fernando Mayo <[email protected]>, Feng Honglin <[email protected]>
3+
4+
# Install packages
5+
ENV DEBIAN_FRONTEND noninteractive
6+
RUN apt-get update && \
7+
apt-get -yq install mysql-server-5.6 pwgen && \
8+
rm -rf /var/lib/apt/lists/*
9+
10+
# Remove pre-installed database
11+
RUN rm -rf /var/lib/mysql/*
12+
13+
# Add MySQL configuration
14+
ADD my.cnf /etc/mysql/conf.d/my.cnf
15+
ADD mysqld_charset.cnf /etc/mysql/conf.d/mysqld_charset.cnf
16+
17+
# Add MySQL scripts
18+
ADD create_mysql_admin_user.sh /create_mysql_admin_user.sh
19+
ADD import_sql.sh /import_sql.sh
20+
ADD run.sh /run.sh
21+
RUN chmod 755 /*.sh
22+
23+
# Exposed ENV
24+
ENV MYSQL_USER admin
25+
ENV MYSQL_PASS **Random**
26+
27+
# Add VOLUMEs to allow backup of config and databases
28+
VOLUME ["/etc/mysql", "/var/lib/mysql"]
29+
30+
EXPOSE 3306
31+
CMD ["/run.sh"]

5.6/create_db.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
3+
if [[ $# -eq 0 ]]; then
4+
echo "Usage: $0 <db_name>"
5+
exit 1
6+
fi
7+
8+
/usr/bin/mysqld_safe > /dev/null 2>&1 &
9+
10+
echo "=> Creating database $1"
11+
RET=1
12+
while [[ RET -ne 0 ]]; do
13+
sleep 5
14+
mysql -uroot -e "CREATE DATABASE $1"
15+
RET=$?
16+
done
17+
18+
mysqladmin -uroot shutdown
19+
20+
echo "=> Done!"

5.6/create_mysql_admin_user.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/bash
2+
3+
/usr/bin/mysqld_safe > /dev/null 2>&1 &
4+
5+
RET=1
6+
while [[ RET -ne 0 ]]; do
7+
echo "=> Waiting for confirmation of MySQL service startup"
8+
sleep 5
9+
mysql -uroot -e "status" > /dev/null 2>&1
10+
RET=$?
11+
done
12+
13+
if [ "$MYSQL_PASS" = "**Random**" ]; then
14+
unset MYSQL_PASS
15+
fi
16+
17+
PASS=${MYSQL_PASS:-$(pwgen -s 12 1)}
18+
_word=$( [ ${MYSQL_PASS} ] && echo "preset" || echo "random" )
19+
echo "=> Creating MySQL user ${MYSQL_USER} with ${_word} password"
20+
21+
mysql -uroot -e "CREATE USER '${MYSQL_USER}'@'%' IDENTIFIED BY '$PASS'"
22+
mysql -uroot -e "GRANT ALL PRIVILEGES ON *.* TO '${MYSQL_USER}'@'%' WITH GRANT OPTION"
23+
24+
25+
echo "=> Done!"
26+
27+
echo "========================================================================"
28+
echo "You can now connect to this MySQL Server using:"
29+
echo ""
30+
echo " mysql -u$MYSQL_USER -p$PASS -h<host> -P<port>"
31+
echo ""
32+
echo "Please remember to change the above password as soon as possible!"
33+
echo "MySQL user 'root' has no password but only allows local connections"
34+
echo "========================================================================"
35+
36+
mysqladmin -uroot shutdown

0 commit comments

Comments
 (0)