Skip to content
Snippets Groups Projects
Verified Commit 8e328d93 authored by Manuel Herrmann's avatar Manuel Herrmann
Browse files

use official mariadb docker image for dev env

parent 47af610c
No related branches found
No related tags found
No related merge requests found
......@@ -21,15 +21,15 @@ pma:
- "8090:80"
db:
build: docker
dockerfile: DockerfileMariaDB
image: mariadb:10.1
environment:
- MYSQL_DATABASE=fsfahrt
- MYSQL_USER=fsfahrt
- MYSQL_PASSWORD=9Lug*96q
- MYSQL_RANDOM_ROOT_PASSWORD=yes
expose:
- "3306"
volumes:
- ./mysql_data:/var/lib/mysql
- ./registration-system/other/sqlDumps/init_20180118.sql:/dump.sql:ro
- ./registration-system/other/sqlDumps/init_20180118.sql:/docker-entrypoint-initdb.d/dump.sql:ro
FROM ubuntu:latest
MAINTAINER Dennis Micky Jensen <root@mewm.org>
# Download MariaDB
RUN apt-get update && \
apt-get install -y mariadb-server pwgen && \
rm -rf /var/lib/mysql/* && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Set bind address to 0.0.0.0 and enforce port
RUN sed -i -r 's/bind-address.*$/bind-address = 0.0.0.0/' /etc/mysql/mariadb.conf.d/50-server.cnf
#RUN sed -i -r 's/port.*$/port = 3306'/ /etc/mysql/my.cnf
# Add bash scripts for creating a user and run server
ADD create-mariadb-user.sh /create-mariadb-user.sh
ADD run-mariadb.sh /run-mariadb.sh
RUN chmod 775 /*.sh
# To avoid mysql whining about this variable
ENV TERM dumb
EXPOSE "3306"
# Set default entry point
CMD ["/run-mariadb.sh"]
See http://blog.mewm.org/ghost-mariadb-with-docker-fig/
#!/bin/bash
/usr/bin/mysqld_safe > /dev/null 2>&1 &
RET=1
while [[ RET -ne 0 ]]; do
sleep 5
mysql -uroot -e "status" > /dev/null 2>&1
RET=$?
done
mysql -uroot -e "CREATE USER '$MYSQL_USER'@'%' IDENTIFIED BY '$MYSQL_PASSWORD'"
mysql -uroot -e "GRANT ALL PRIVILEGES ON *.* TO '$MYSQL_USER'@'%' WITH GRANT OPTION"
mysql -uroot -e "CREATE DATABASE $MYSQL_DATABASE"
echo " -> SQL Dump Import ..."
mysql -uroot $MYSQL_DATABASE < /dump.sql
echo " -> SQL Dump OK"
mysqladmin -uroot shutdown
#!/bin/bash
VOLUME_HOME="/var/lib/mysql"
if find ${VOLUME_HOME} -maxdepth 0 -empty | read v; then
echo " -> Setting up new installation in $VOLUME_HOME"
echo " -> Installing MariaDB"
mysql_install_db > /dev/null 2>&1
echo " -> MySQL Setup Done!"
/create-mariadb-user.sh
echo " -> DB Setup Done!"
else
echo "-> Booting on existing volume!"
fi
exec mysqld_safe
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment