Migrate to a docker-compose config with a few persistence.
./data/nginx/ for nginx host configurations. ./data/mysql/ for mysql databases.
This commit is contained in:
parent
057d154730
commit
ce0f70d648
15
Dockerfile
15
Dockerfile
@ -6,19 +6,6 @@ RUN apt-get update && \
|
|||||||
apt-get install -y systemd systemd-sysv cron anacron nano wget curl git mariadb-server mariadb-client nginx php-fpm php-common php-gd php-mysql php-imap php-cli php-cgi libapache2-mod-fcgid apache2-suexec-pristine php-pear mcrypt imagemagick libruby libapache2-mod-python php-curl php-intl php-pspell php-sqlite3 php-tidy php-xmlrpc php-xsl memcached php-memcache php-imagick php-zip php-mbstring memcached libapache2-mod-passenger php-soap php-opcache php-apcu libapache2-reload-perl php-mcrypt && \
|
apt-get install -y systemd systemd-sysv cron anacron nano wget curl git mariadb-server mariadb-client nginx php-fpm php-common php-gd php-mysql php-imap php-cli php-cgi libapache2-mod-fcgid apache2-suexec-pristine php-pear mcrypt imagemagick libruby libapache2-mod-python php-curl php-intl php-pspell php-sqlite3 php-tidy php-xmlrpc php-xsl memcached php-memcache php-imagick php-zip php-mbstring memcached libapache2-mod-passenger php-soap php-opcache php-apcu libapache2-reload-perl php-mcrypt && \
|
||||||
apt-get clean
|
apt-get clean
|
||||||
|
|
||||||
# Instalamos phpmyadmin y definimos la contraseña de root de mariadb en blanco para @localhost.
|
|
||||||
RUN service mariadb start && \
|
|
||||||
export DEBIAN_FRONTEND=noninteractive && \
|
|
||||||
apt-get -yq install phpmyadmin && \
|
|
||||||
mysql -e "SET PASSWORD FOR 'root'@'localhost' = PASSWORD(''); FLUSH PRIVILEGES;" && \
|
|
||||||
service mariadb stop
|
|
||||||
|
|
||||||
# Permitimos el que se pueda loguear sin contraseña para usar el usuario root de ese modo
|
|
||||||
RUN sed -i "s/ \/\/ \$cfg\['Servers'\]\[\$i\]\['AllowNoPassword'\]/ \$cfg\['Servers'\]\[\$i\]\['AllowNoPassword'\]/" /etc/phpmyadmin/config.inc.php
|
|
||||||
|
|
||||||
# Añadimos las reglas nginx para poder ver phpmyadmin en http://localhost/phpmyadmin
|
|
||||||
RUN sed -i "s/server_name _;/server_name _;\n\nlocation \/phpmyadmin {\n root \/usr\/share\/;\n index index.php index.html index.htm;\n location ~ \^\/phpmyadmin\/\(.+\.php\)\$ {\n try_files \$uri =404;\n root \/usr\/share\/;\n fastcgi_pass unix:\/var\/run\/php\/php8.2-fpm.sock;\n fastcgi_index index.php;\n fastcgi_param SCRIPT_FILENAME \$request_filename;\n include \/etc\/nginx\/fastcgi_params;\n fastcgi_param PATH_INFO \$fastcgi_script_name;\n fastcgi_buffer_size 128k;\n fastcgi_buffers 256 4k;\n fastcgi_busy_buffers_size 256k;\n fastcgi_temp_file_write_size 256k;\n fastcgi_intercept_errors on;\n }\n location ~* \^\/phpmyadmin\/\(.+\\.\(jpg\|jpeg\|gif\|css\|png\|js\|ico\|html\|xml\|txt\)\)\$ {\n root \/usr\/share\/;\n }\n}\nlocation \/phpMyAdmin {\n rewrite \^\/* \/phpmyadmin last;\n}/g" /etc/nginx/sites-available/default
|
|
||||||
|
|
||||||
# Mostrar los errores en PHP
|
# Mostrar los errores en PHP
|
||||||
RUN sed -i 's/display_errors = Off/display_errors = On/' /etc/php/8.2/fpm/php.ini && \
|
RUN sed -i 's/display_errors = Off/display_errors = On/' /etc/php/8.2/fpm/php.ini && \
|
||||||
sed -i 's/error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT/error_reporting = E_ALL/' /etc/php/8.2/fpm/php.ini
|
sed -i 's/error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT/error_reporting = E_ALL/' /etc/php/8.2/fpm/php.ini
|
||||||
@ -48,6 +35,8 @@ COPY bin/adddomain /usr/local/bin/adddomain
|
|||||||
RUN chmod +x /usr/local/bin/adddomain
|
RUN chmod +x /usr/local/bin/adddomain
|
||||||
COPY bin/addsubdomain /usr/local/bin/addsubdomain
|
COPY bin/addsubdomain /usr/local/bin/addsubdomain
|
||||||
RUN chmod +x /usr/local/bin/addsubdomain
|
RUN chmod +x /usr/local/bin/addsubdomain
|
||||||
|
COPY bin/mysql_configure /usr/local/bin/mysql_configure
|
||||||
|
RUN chmod +x /usr/local/bin/mysql_configure
|
||||||
|
|
||||||
# Colocamos dentro el certificado SSL
|
# Colocamos dentro el certificado SSL
|
||||||
COPY ssl /etc/nginx/ssl
|
COPY ssl /etc/nginx/ssl
|
||||||
|
30
bin/mysql_configure
Normal file
30
bin/mysql_configure
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Verificamos si ya está todo configurado
|
||||||
|
if test -f /etc/phpmyadmin/config.inc.php; then
|
||||||
|
echo "Parece que ya está todo configurado (se hace nada)."
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Definiendo una contraseña vacía para root
|
||||||
|
echo "Definiendo contraseña para root (contraseña en blanco)."
|
||||||
|
systemctl start mariadb
|
||||||
|
export DEBIAN_FRONTEND=noninteractive
|
||||||
|
apt-get update
|
||||||
|
apt-get -yq install phpmyadmin
|
||||||
|
mysql -e "SET PASSWORD FOR 'root'@'localhost' = PASSWORD(''); FLUSH PRIVILEGES;"
|
||||||
|
|
||||||
|
# Permitimos el que se pueda loguear sin contraseña para usar el usuario root en phpmyadmin
|
||||||
|
sed -i "s/ \/\/ \$cfg\['Servers'\]\[\$i\]\['AllowNoPassword'\]/ \$cfg\['Servers'\]\[\$i\]\['AllowNoPassword'\]/" /etc/phpmyadmin/config.inc.php
|
||||||
|
|
||||||
|
# Añadimos las reglas nginx para poder ver phpmyadmin en http://localhost/phpmyadmin
|
||||||
|
if grep -e "phpmyadmin" /etc/nginx/sites-available/default >/dev/null
|
||||||
|
then
|
||||||
|
echo "Se detectó que nginx ya tiene una configuración para PHPmyadmin (se hace nada)"
|
||||||
|
else
|
||||||
|
echo "Configurando Nginx..."
|
||||||
|
sed -i "s/server_name _;/server_name _;\n\nlocation \/phpmyadmin {\n root \/usr\/share\/;\n index index.php index.html index.htm;\n location ~ \^\/phpmyadmin\/\(.+\.php\)\$ {\n try_files \$uri =404;\n root \/usr\/share\/;\n fastcgi_pass unix:\/var\/run\/php\/php8.2-fpm.sock;\n fastcgi_index index.php;\n fastcgi_param SCRIPT_FILENAME \$request_filename;\n include \/etc\/nginx\/fastcgi_params;\n fastcgi_param PATH_INFO \$fastcgi_script_name;\n fastcgi_buffer_size 128k;\n fastcgi_buffers 256 4k;\n fastcgi_busy_buffers_size 256k;\n fastcgi_temp_file_write_size 256k;\n fastcgi_intercept_errors on;\n }\n location ~* \^\/phpmyadmin\/\(.+\\.\(jpg\|jpeg\|gif\|css\|png\|js\|ico\|html\|xml\|txt\)\)\$ {\n root \/usr\/share\/;\n }\n}\nlocation \/phpMyAdmin {\n rewrite \^\/* \/phpmyadmin last;\n}/g" /etc/nginx/sites-available/default
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
echo "Finalizado :)."
|
40
data/nginx/sites-available/default
Normal file
40
data/nginx/sites-available/default
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
server {
|
||||||
|
listen 80 default_server;
|
||||||
|
listen [::]:80 default_server;
|
||||||
|
|
||||||
|
root /var/www/html;
|
||||||
|
|
||||||
|
index index.html index.htm index.nginx-debian.html;
|
||||||
|
|
||||||
|
server_name _;
|
||||||
|
|
||||||
|
location /phpmyadmin {
|
||||||
|
root /usr/share/;
|
||||||
|
index index.php index.html index.htm;
|
||||||
|
location ~ ^/phpmyadmin/(.+.php)$ {
|
||||||
|
try_files $uri =404;
|
||||||
|
root /usr/share/;
|
||||||
|
fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
|
||||||
|
fastcgi_index index.php;
|
||||||
|
fastcgi_param SCRIPT_FILENAME $request_filename;
|
||||||
|
include /etc/nginx/fastcgi_params;
|
||||||
|
fastcgi_param PATH_INFO $fastcgi_script_name;
|
||||||
|
fastcgi_buffer_size 128k;
|
||||||
|
fastcgi_buffers 256 4k;
|
||||||
|
fastcgi_busy_buffers_size 256k;
|
||||||
|
fastcgi_temp_file_write_size 256k;
|
||||||
|
fastcgi_intercept_errors on;
|
||||||
|
}
|
||||||
|
location ~* ^/phpmyadmin/(.+.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
|
||||||
|
root /usr/share/;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
location /phpMyAdmin {
|
||||||
|
rewrite ^/* /phpmyadmin last;
|
||||||
|
}
|
||||||
|
|
||||||
|
location / {
|
||||||
|
try_files $uri $uri/ =404;
|
||||||
|
}
|
||||||
|
}
|
1
data/nginx/sites-enabled/default
Symbolic link
1
data/nginx/sites-enabled/default
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
/etc/nginx/sites-available/default
|
14
docker-compose.yml
Normal file
14
docker-compose.yml
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
version: '3'
|
||||||
|
|
||||||
|
services:
|
||||||
|
nginx:
|
||||||
|
image: nginx-dev
|
||||||
|
network_mode: host
|
||||||
|
build: .
|
||||||
|
container_name: nginx
|
||||||
|
hostname: nginx
|
||||||
|
volumes:
|
||||||
|
- ~/.mnt/Nginx:/var/www:Z
|
||||||
|
- ./data/nginx/sites-available:/etc/nginx/sites-available:Z
|
||||||
|
- ./data/nginx/sites-enabled:/etc/nginx/sites-enabled:Z
|
||||||
|
- ./data/mysql/data:/var/lib/mysql/data:Z
|
3
install.sh
Executable file
3
install.sh
Executable file
@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
podman-compose up -d
|
||||||
|
podman exec -it nginx /usr/local/bin/mysql_configure
|
2
uninstall.sh
Executable file
2
uninstall.sh
Executable file
@ -0,0 +1,2 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
podman-compose down
|
Loading…
Reference in New Issue
Block a user