adding image pluie/alpine-mysql
This commit is contained in:
parent
471927be29
commit
be6b49a2dc
1
pluie/alpine-mysql/.gitignore
vendored
Normal file
1
pluie/alpine-mysql/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
files.tar
|
13
pluie/alpine-mysql/Dockerfile
Normal file
13
pluie/alpine-mysql/Dockerfile
Normal file
|
@ -0,0 +1,13 @@
|
|||
FROM pluie/alpine
|
||||
|
||||
MAINTAINER a-Sansara https://github.com/a-sansara
|
||||
|
||||
ADD files.tar /scripts
|
||||
|
||||
RUN bash /scripts/install.sh
|
||||
|
||||
ENV SHENV_NAME=Mysql SHENV_COLOR=132
|
||||
|
||||
EXPOSE 3306
|
||||
|
||||
VOLUME ["/var/lib/mysql", "/dump"]
|
21
pluie/alpine-mysql/build
Executable file
21
pluie/alpine-mysql/build
Executable file
|
@ -0,0 +1,21 @@
|
|||
#!/bin/bash
|
||||
# pluie/docker-images - a-Sansara (https://github.com/a-sansara)
|
||||
|
||||
Ctitle="\033[1;38;5;15;1;48;5;30m"
|
||||
Citem="\033[1;38;5;36m"
|
||||
Coff="\033[m"
|
||||
DOCKDIR=$(dirname "$(readlink -f ${BASH_SOURCE[0]})")
|
||||
DOCKBUILD=$(basename $DOCKDIR)
|
||||
DOCKREPO=$(basename $(dirname $DOCKDIR))
|
||||
DOCKTAG=${1:-"latest"}
|
||||
TMPPWD=$(pwd)
|
||||
indent=" "
|
||||
cd $DOCKDIR
|
||||
echo -e "\n ${Ctitle} Preparing files : ${Coff}${Citem}\n"
|
||||
|
||||
tar -cvf files.tar *.sh pre-init.d/ install.d/ | sed "s/^/${indent}* /"
|
||||
|
||||
echo -e "\n ${Ctitle} Proceed Dockerfile build : ${Coff}\n
|
||||
"
|
||||
docker build --force-rm -t ${DOCKREPO}/${DOCKBUILD}:${DOCKTAG} . | sed "s/^/${indent}/"
|
||||
cd $TMPPWD
|
4
pluie/alpine-mysql/install.d/10-mysql.sh
Executable file
4
pluie/alpine-mysql/install.d/10-mysql.sh
Executable file
|
@ -0,0 +1,4 @@
|
|||
#!/bin/bash
|
||||
# pluie/docker-images - a-Sansara (https://github.com/a-sansara)
|
||||
|
||||
apk --update add mysql mysql-client pwgen \
|
7
pluie/alpine-mysql/main.sh
Executable file
7
pluie/alpine-mysql/main.sh
Executable file
|
@ -0,0 +1,7 @@
|
|||
#!/bin/bash
|
||||
# pluie/docker-images - a-Sansara (https://github.com/a-sansara)
|
||||
|
||||
. /scripts/common.sh
|
||||
|
||||
echo "[[ Starting Mysql Daemon ]]"
|
||||
exec /usr/bin/mysqld --user=mysql --console
|
48
pluie/alpine-mysql/pre-init.d/10-db.sh
Normal file
48
pluie/alpine-mysql/pre-init.d/10-db.sh
Normal file
|
@ -0,0 +1,48 @@
|
|||
#!/bin/bash
|
||||
# pluie/docker-images - a-Sansara (https://github.com/a-sansara)
|
||||
|
||||
if [ ! -d "/run/mysqld" ]; then
|
||||
mkdir -p /run/mysqld
|
||||
chown -R mysql:mysql /run/mysqld
|
||||
fi
|
||||
|
||||
if [ ! -d /var/lib/mysql/mysql ]; then
|
||||
echo "[[ Initialize DB ]]"
|
||||
chown -R mysql:mysql /var/lib/mysql
|
||||
mysql_install_db --user=mysql > /dev/null
|
||||
|
||||
if [ ! -z "$MYSQL_ROOT_PASSWORD" ]; then
|
||||
MYSQL_ROOT_PASSWORD=`pwgen -y -s 18 1`
|
||||
fi
|
||||
|
||||
MYSQL_DATABASE=${MYSQL_DATABASE:-""}
|
||||
MYSQL_USER=${MYSQL_USER:-""}
|
||||
MYSQL_PASSWORD=${MYSQL_PASSWORD:-""}
|
||||
|
||||
tfile=`mktemp`
|
||||
if [ ! -f "$tfile" ]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
cat << EOF > $tfile
|
||||
USE mysql;
|
||||
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;
|
||||
UPDATE user SET password=PASSWORD("$MYSQL_ROOT_PASSWORD") WHERE user='root';
|
||||
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION;
|
||||
UPDATE user SET password=PASSWORD("") WHERE user='root' AND host='localhost';
|
||||
FLUSH PRIVILEGES;
|
||||
EOF
|
||||
|
||||
if [ ! -z "$MYSQL_DATABASE" ]; then
|
||||
echo "[[ Creating DB : $MYSQL_DATABASE ]]"
|
||||
echo "CREATE DATABASE IF NOT EXISTS \`$MYSQL_DATABASE\` CHARACTER SET utf8 COLLATE utf8_general_ci;" >> $tfile
|
||||
|
||||
if [ "$MYSQL_USER" != "" ]; then
|
||||
echo "[[ Creating user : $MYSQL_USER ]]"
|
||||
echo "GRANT ALL ON \`$MYSQL_DATABASE\`.* to '$MYSQL_USER'@'%' IDENTIFIED BY '$MYSQL_PASSWORD';" >> $tfile
|
||||
fi
|
||||
fi
|
||||
|
||||
/usr/bin/mysqld --user=mysql --bootstrap --verbose=0 < $tfile
|
||||
rm -f $tfile
|
||||
fi
|
Loading…
Reference in New Issue
Block a user