add: mariadb docker, wordpress now works :))))

This commit is contained in:
mcolonna 2025-06-12 18:26:18 +02:00
parent b7cb3733ec
commit 49a136c709
9 changed files with 185 additions and 2 deletions

View file

@ -0,0 +1,22 @@
# TODO(any)(latest)
FROM alpine:latest
RUN apk update
RUN apk add mariadb
RUN apk fix
RUN rm -rf /etc/my.cnf.d/
RUN mkdir -p /etc/my.cnf.d/
COPY conf/mariadb-server.cnf /etc/my.cnf.d/mariadb-server.cnf
COPY run.sh /run.sh
# TODO(secret)
RUN addgroup -S www && adduser -S www www
RUN mkdir /db
RUN chmod -R 666 /db
EXPOSE 3306
# start
CMD ["/run.sh"]
#CMD ["ls", "-AlF", "/"]

View file

@ -0,0 +1,10 @@
[client-server]
socket=/tmp/mysql.sock
port=3306
[mysqld]
# fix from https://stackoverflow.com/questions/75696472/aborted-connection-3-to-db-unconnected-user-unauthenticated-host-172-21
skip-grant-tables
[mariadb]
datadir=/db

View file

@ -0,0 +1,34 @@
#!/bin/sh
set -e
echo
dirisempty()
{
[ -z "$( ls -A "$1" )" ]
}
# install database if doesn't exist
if dirisempty /db
then
echo "database doesn't exist. creating it..."
echo
chmod -R 777 /db
mariadb-install-db --user=www --datadir=/db
# TODO(secret)
echo '
FLUSH PRIVILEGES;
CREATE DATABASE wp;
GRANT ALL PRIVILEGES ON wp.* TO wwsw IDENTIFIED BY "ultraPassword";
FLUSH PRIVILEGES;
' | mariadbd -u root --bootstrap
echo
echo "database created!"
echo
fi
echo "to recreate a new database, remove the db volume of this compose."
echo
# run mariadb
mariadbd -u root

View file

@ -20,7 +20,7 @@ RUN printf "%s%s%s%s\n" \
RUN curl -o /tmp/nginx_signing.rsa.pub https://nginx.org/keys/nginx_signing.rsa.pub
RUN mv /tmp/nginx_signing.rsa.pub /etc/apk/keys/
RUN apk update
RUN apk add nginx@nginx
RUN apk add nginx@nginx mysql-client
RUN apk fix
# add config

View file

@ -6,7 +6,7 @@ EXPOSE 9000
# install packages
RUN apk update
RUN apk add php-fpm
RUN apk add php-fpm php-mysqli
RUN apk fix
RUN addgroup -S www