Update DB
This commit is contained in:
parent
65e804e828
commit
c6da89460b
46
README.md
46
README.md
@ -38,12 +38,16 @@ Delete service : `docker-compose rm <container_name>`
|
||||
Prune all: `docker-compose down`
|
||||
|
||||
## Start and stop
|
||||
`docker-compose start`
|
||||
`docker-compose stop`
|
||||
```bash
|
||||
docker-compose start
|
||||
docker-compose stop
|
||||
```
|
||||
|
||||
## Viewing log
|
||||
`docker-compose logs -f`
|
||||
`docker-compose logs <container_name>`
|
||||
```bash
|
||||
docker-compose logs -f
|
||||
docker-compose logs <container_name>
|
||||
```
|
||||
|
||||
## View running container
|
||||
`docker-compose ps`
|
||||
@ -61,15 +65,43 @@ docker-compose exec -u fpm <container_name>
|
||||
```
|
||||
To avoid permissions problem
|
||||
|
||||
Update composer or an admin command
|
||||
Update composer or an admin command
|
||||
```bash
|
||||
docker-compose exec <container_name>
|
||||
```
|
||||
|
||||
## PHP-FPM & Apache vhosts
|
||||
```
|
||||
# Redirect to local php-fpm if mod_php is not available
|
||||
<IfModule !mod_php7.c>
|
||||
<IfModule proxy_fcgi_module>
|
||||
# Enable http authorization headers
|
||||
<IfModule setenvif_module>
|
||||
SetEnvIfNoCase ^Authorization$ "(.+)" HTTP_AUTHORIZATION=$1
|
||||
</IfModule>
|
||||
|
||||
<FilesMatch ".+\.ph(p[3457]?|t|tml)$">
|
||||
SetHandler "proxy:fcgi://fpm70/:9000
|
||||
</FilesMatch>
|
||||
<FilesMatch ".+\.phps$">
|
||||
# Deny access to raw php sources by default
|
||||
# To re-enable it's recommended to enable access to the files
|
||||
# only in specific virtual host or directory
|
||||
Require all denied
|
||||
</FilesMatch>
|
||||
# Deny access to files without filename (e.g. '.php')
|
||||
<FilesMatch "^\.ph(p[3457]?|t|tml|ps)$">
|
||||
Require all denied
|
||||
</FilesMatch>
|
||||
</IfModule>
|
||||
</IfModule>
|
||||
```
|
||||
|
||||
## Database
|
||||
Database files are store in `<workspace>/database`.
|
||||
Even if you delete your container date are preserved.
|
||||
|
||||
Read the doc official MariaDB: `https://hub.docker.com/_/mariadb/`
|
||||
|
||||
## HTTPd
|
||||
|
||||
@ -78,7 +110,9 @@ Even if you delete your container date are preserved.
|
||||
# Additional
|
||||
## Ip Address
|
||||
See all ip addresses in one command
|
||||
`docker inspect --format='{{.Name}} - {{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $(docker ps -aq)`
|
||||
```bash
|
||||
docker inspect --format='{{.Name}} - {{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $(docker ps -aq)
|
||||
```
|
||||
|
||||
|
||||
## ctop
|
||||
|
@ -6,15 +6,27 @@ ENV DEBIAN_FRONTEND noninteractive
|
||||
ENV TZ=Europe/Paris
|
||||
|
||||
# Installation
|
||||
RUN apt-get update && apt-get -y install software-properties-common procps gnupg pwgen nano && \
|
||||
apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 0xF1656F24C74CD1D8 && \
|
||||
add-apt-repository 'deb [arch=amd64] http://ftp.igh.cnrs.fr/pub/mariadb/repo/10.2/debian stretch main' && \
|
||||
apt-get update && apt-get -y upgrade && apt-get -y install mariadb-server-10.2 && \
|
||||
sed -i -e 's/log_bin[ \t]*= \/var\/log\/mysql\/mariadb-bin/#log_bin[ \t]*= \/var\/log\/mysql\/mariadb-bin/g' /etc/mysql/my.cnf && \
|
||||
sed -i -e 's/log_bin_index[ \t]*= \/var\/log\/mysql\/mariadb-bin.index/#log_bin_index[ \t]*= \/var\/log\/mysql\/mariadb-bin.index/g' /etc/mysql/my.cnf && \
|
||||
ln -s /dev/stderr /var/log/errorlog.err && chown mysql: /var/lib/mysql && \
|
||||
apt-get clean && rm -rf /var/lib/apt/lists/* && \
|
||||
echo "Europe/Paris" > /etc/timezone && dpkg-reconfigure -f noninteractive tzdata
|
||||
RUN apt-get update && apt-get -y install software-properties-common procps gnupg pwgen nano \
|
||||
&& apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 0xF1656F24C74CD1D8 \
|
||||
&& add-apt-repository 'deb [arch=amd64] http://ftp.igh.cnrs.fr/pub/mariadb/repo/10.2/debian stretch main' \
|
||||
&& { \
|
||||
echo "mariadb-server-10.2" mysql-server/root_password password 'unused'; \
|
||||
echo "mariadb-server-10.2" mysql-server/root_password_again password 'unused'; \
|
||||
} | debconf-set-selections \
|
||||
&& apt-get update && apt-get -y upgrade && apt-get -y install mariadb-server-10.2 \
|
||||
# comment out any "user" entires in the MySQL config ("docker-entrypoint.sh" or "--user" will handle user switching)
|
||||
&& sed -ri 's/^user\s/#&/' /etc/mysql/my.cnf /etc/mysql/conf.d/* \
|
||||
# purge and re-create /var/lib/mysql with appropriate ownership
|
||||
&& apt-get clean && rm -rf /var/lib/apt/lists/* \
|
||||
&& rm -rf /var/lib/mysql && mkdir -p /var/lib/mysql /var/run/mysqld \
|
||||
&& chown -R mysql:mysql /var/lib/mysql /var/run/mysqld \
|
||||
# ensure that /var/run/mysqld (used for socket and lock files) is writable regardless of the UID our mysqld instance ends up having at runtime
|
||||
&& chmod 777 /var/run/mysqld \
|
||||
# comment out a few problematic configuration values
|
||||
&& sed -i -e 's/log_bin[ \t]*= \/var\/log\/mysql\/mariadb-bin/#log_bin[ \t]*= \/var\/log\/mysql\/mariadb-bin/g' /etc/mysql/my.cnf \
|
||||
&& sed -i -e 's/log_bin_index[ \t]*= \/var\/log\/mysql\/mariadb-bin.index/#log_bin_index[ \t]*= \/var\/log\/mysql\/mariadb-bin.index/g' /etc/mysql/my.cnf \
|
||||
&& ln -s /dev/stderr /var/log/errorlog.err \
|
||||
&& echo "Europe/Paris" > /etc/timezone && dpkg-reconfigure -f noninteractive tzdata
|
||||
|
||||
# Add MySQL configuration
|
||||
ADD *.cnf /etc/mysql/conf.d/
|
||||
|
@ -1,8 +1,8 @@
|
||||
[mysqld]
|
||||
bind-address=0.0.0.0
|
||||
skip-host-cache
|
||||
skip_name_resolve
|
||||
skip-name-resolve
|
||||
skip_external_locking
|
||||
log_error=/var/log/errorlog.err
|
||||
#server-id
|
||||
#log-bin
|
||||
#log-bin
|
||||
|
@ -6,19 +6,19 @@ ENV DEBIAN_FRONTEND noninteractive
|
||||
ENV TZ=Europe/Paris
|
||||
|
||||
# Installation
|
||||
RUN apt-get update && apt-get -y install software-properties-common gnupg procps nano pwgen && \
|
||||
echo "Europe/Paris" > /etc/timezone && dpkg-reconfigure -f noninteractive tzdata
|
||||
RUN apt-get update && apt-get -y install software-properties-common gnupg procps nano pwgen \
|
||||
&& echo "Europe/Paris" > /etc/timezone && dpkg-reconfigure -f noninteractive tzdata
|
||||
|
||||
# Add MySQL configuration
|
||||
ADD *.cnf /etc/mysql/conf.d/
|
||||
RUN chmod 644 /etc/mysql/conf.d/*.cnf
|
||||
#ADD *.cnf /etc/mysql/conf.d/
|
||||
#RUN chmod 644 /etc/mysql/conf.d/*.cnf
|
||||
|
||||
# Add cli to run
|
||||
ADD init_user.sh /home/init_user.sh
|
||||
RUN chmod 775 /home/*.sh
|
||||
ADD init_user.sh /docker-entrypoint-initdb.d/
|
||||
RUN chmod 775 /docker-entrypoint-initdb.d/init_user.sh
|
||||
|
||||
# Add VOLUMEs to allow backup of config and databases
|
||||
VOLUME ["/etc/mysql", "/var/lib/mysql"]
|
||||
VOLUME ["/var/lib/mysql"]
|
||||
|
||||
# Expose and Run
|
||||
EXPOSE 3306
|
||||
|
@ -1,18 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
/usr/bin/mysqld_safe > /dev/null 2>&1 &
|
||||
|
||||
RET=1
|
||||
while [[ RET -ne 0 ]]; do
|
||||
echo "=> Waiting for confirmation of MariaDB service startup"
|
||||
sleep 5
|
||||
mysql -uroot -e "status" > /dev/null 2>&1
|
||||
RET=$?
|
||||
done
|
||||
|
||||
|
||||
PASS=${MARIADB_PASS:-$(pwgen -s 12 1)}
|
||||
_word=$( [ ${MARIADB_PASS} ] && echo "preset" || echo "random" )
|
||||
PASS=${MYSQL_ROOT_PASSWORD:-$(pwgen -s 12 1)}
|
||||
_word=$( [ ${MYSQL_ROOT_PASSWORD} ] && echo "preset" || echo "random" )
|
||||
echo "=> Creating MariaDB admin user with ${_word} password"
|
||||
|
||||
mysql -uroot -e "CREATE USER 'admin'@'%' IDENTIFIED BY '$PASS'"
|
||||
@ -28,5 +17,3 @@ echo ""
|
||||
echo "Please remember to change the above password as soon as possible!"
|
||||
echo "MariaDB user 'root' has no password but only allows local connections"
|
||||
echo "========================================================================"
|
||||
|
||||
mysqladmin -uroot shutdown
|
||||
|
@ -1,8 +0,0 @@
|
||||
[mysqld]
|
||||
bind-address=0.0.0.0
|
||||
skip-host-cache
|
||||
skip_name_resolve
|
||||
skip_external_locking
|
||||
log_error=/var/log/errorlog.err
|
||||
#server-id
|
||||
#log-bin
|
Loading…
Reference in New Issue
Block a user