Merge pull request #437 from philtrep/fix-mysql-change-env
Added proper creation of mysql user, removal of default homestead user
This commit is contained in:
commit
e5a8fb9c95
@ -112,16 +112,17 @@ services:
|
||||
### MySQL Container #########################################
|
||||
|
||||
mysql:
|
||||
build: ./mysql
|
||||
build:
|
||||
context: ./mysql
|
||||
args:
|
||||
- MYSQL_DATABASE=homestead
|
||||
- MYSQL_USER=homestead
|
||||
- MYSQL_PASSWORD=secret
|
||||
- MYSQL_ROOT_PASSWORD=root
|
||||
volumes:
|
||||
- mysql:/var/lib/mysql
|
||||
ports:
|
||||
- "3306:3306"
|
||||
environment:
|
||||
MYSQL_DATABASE: homestead
|
||||
MYSQL_USER: homestead
|
||||
MYSQL_PASSWORD: secret
|
||||
MYSQL_ROOT_PASSWORD: root
|
||||
|
||||
### MariaDB Container #######################################
|
||||
|
||||
|
@ -2,8 +2,26 @@ FROM mysql:5.6
|
||||
|
||||
MAINTAINER Mahmoud Zalt <mahmoud@zalt.me>
|
||||
|
||||
ADD startup /etc/mysql/startup
|
||||
|
||||
RUN chown -R mysql:root /var/lib/mysql/
|
||||
|
||||
ARG MYSQL_DATABASE=homestead
|
||||
ARG MYSQL_USER=homestead
|
||||
ARG MYSQL_PASSWORD=secret
|
||||
ARG MYSQL_ROOT_PASSWORD=root
|
||||
|
||||
ENV MYSQL_DATABASE=$MYSQL_DATABASE
|
||||
ENV MYSQL_USER=$MYSQL_USER
|
||||
ENV MYSQL_PASSWORD=$MYSQL_PASSWORD
|
||||
ENV MYSQL_ROOT_PASSWORD=$MYSQL_ROOT_PASSWORD
|
||||
|
||||
RUN sed -i 's/MYSQL_DATABASE/'$MYSQL_DATABASE'/g' /etc/mysql/startup && \
|
||||
sed -i 's/MYSQL_USER/'$MYSQL_USER'/g' /etc/mysql/startup && \
|
||||
sed -i 's/MYSQL_PASSWORD/'$MYSQL_PASSWORD'/g' /etc/mysql/startup
|
||||
|
||||
ADD my.cnf /etc/mysql/conf.d/my.cnf
|
||||
|
||||
CMD ["mysqld"]
|
||||
CMD ["mysqld", "--init-file=/etc/mysql/startup"]
|
||||
|
||||
EXPOSE 3306
|
||||
|
3
mysql/startup
Normal file
3
mysql/startup
Normal file
@ -0,0 +1,3 @@
|
||||
DROP USER 'homestead';
|
||||
CREATE DATABASE IF NOT EXISTS MYSQL_DATABASE;
|
||||
GRANT ALL ON `MYSQL_DATABASE`.* TO 'MYSQL_USER'@'%' IDENTIFIED BY 'MYSQL_PASSWORD';
|
Loading…
Reference in New Issue
Block a user