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

@ -63,6 +63,10 @@ uninstall :
echoo "Removing $(WWW_PATH)..."
rm -r $(WWW_PATH) || true
# TODO(ugly)
-docker container prune
-docker volume rm my-awesome-compose_db
## 'uninstall' then 'install'
re : uninstall install

3
TODO Normal file
View file

@ -0,0 +1,3 @@
TODO later
- dependencies between containers and check if its is working
- volume www to normal volume, and create it in docker

View file

@ -16,6 +16,13 @@ services:
build: ./requirements/wordpress
volumes:
- www:/www:rw
depends_on:
- mariadb
mariadb:
build: ./requirements/mariadb
volumes:
- db:/db:rw
volumes:
www:
@ -24,6 +31,7 @@ volumes:
o: bind
type: none
device: "${INCEPTION_WWW_PATH:?error}"
db:
### services ###
# image:

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

102
srcs/www/wp-config.php Normal file
View file

@ -0,0 +1,102 @@
<?php
/**
* The base configuration for WordPress
*
* The wp-config.php creation script uses this file during the installation.
* You don't have to use the website, you can copy this file to "wp-config.php"
* and fill in the values.
*
* This file contains the following configurations:
*
* * Database settings
* * Secret keys
* * Database table prefix
* * ABSPATH
*
* @link https://developer.wordpress.org/advanced-administration/wordpress/wp-config/
*
* @package WordPress
*/
// ** Database settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define( 'DB_NAME', 'wp' );
/** Database username */
define( 'DB_USER', 'www' );
/** Database password */
define( 'DB_PASSWORD', 'ultraPassword' ); # TODO(secret)
/** Database hostname */
define( 'DB_HOST', 'mariadb:3306' );
/** Database charset to use in creating database tables. */
define( 'DB_CHARSET', 'utf8' );
/** The database collate type. Don't change this if in doubt. */
define( 'DB_COLLATE', '' );
/**#@+
* Authentication unique keys and salts.
*
* Change these to different unique phrases! You can generate these using
* the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}.
*
* You can change these at any point in time to invalidate all existing cookies.
* This will force all users to have to log in again.
*
* @since 2.6.0
*/
define('AUTH_KEY', 'Uy[FLsUl1v7j]g;Wki6Wm`Bj-eaN(U-7Bi:*?V^kw4AGljWA{0@7_5f$$ziS;OiP');
define('SECURE_AUTH_KEY', '_$gvxQP0M4okT|-`/r$np!2zmdb[|YMo@7.kY.N![6SD.-U#[]<)ErHH-p2}nzh<');
define('LOGGED_IN_KEY', 'F~X|uM-i4asv*i>c]EE<+5<X;L0D@W+,:$^g]V1$T|V2>BAo{3/)5Oc|(U30#2An');
define('NONCE_KEY', 'EwQ+Jo#/Zr-I_,nJu|)i1.Bfzm:b!5d.ku%%+Ihw.)l-]0y 2^;=4HR1XB$B!;m66');
define('AUTH_SALT', 'p_&.BA.mTs]RQEM(Q@F0yB`.@INfW@6L-<%%cd*@I-w iOlEqC@[I0aLbuYNLk}O9');
define('SECURE_AUTH_SALT', '$H?b*kvJ:uA6DyPLwAJsh8:n}P.:[-N<,$/zl?,|`Vu++qC}F,{YKw&8CM`@@d*t');
define('LOGGED_IN_SALT', ',6~y7[-Z}Hj/d&C!M[_|FD]R0>YMTO)s}xD`?.{ Ich:>5j!W`T9~~wef-WLJ:U#');
define('NONCE_SALT', '%%-8d||zvI0s,giZmR7Lk(nhG|uH8c~U{kdB|2.v?Z+@3hr&nlk<@V22;.Ef8chSv');
/**#@-*/
/**
* WordPress database table prefix.
*
* You can have multiple installations in one database if you give each
* a unique prefix. Only numbers, letters, and underscores please!
*
* At the installation time, database tables are created with the specified prefix.
* Changing this value after WordPress is installed will make your site think
* it has not been installed.
*
* @link https://developer.wordpress.org/advanced-administration/wordpress/wp-config/#table-prefix
*/
$table_prefix = 'wp_';
/**
* For developers: WordPress debugging mode.
*
* Change this to true to enable the display of notices during development.
* It is strongly recommended that plugin and theme developers use WP_DEBUG
* in their development environments.
*
* For information on other constants that can be used for debugging,
* visit the documentation.
*
* @link https://developer.wordpress.org/advanced-administration/debug/debug-wordpress/
*/
define( 'WP_DEBUG', true ); # TODO(debug)
/* Add any custom values between this line and the "stop editing" line. */
/* That's all, stop editing! Happy publishing. */
/** Absolute path to the WordPress directory. */
if ( ! defined( 'ABSPATH' ) ) {
define( 'ABSPATH', __DIR__ . '/' );
}
/** Sets up WordPress vars and included files. */
require_once ABSPATH . 'wp-settings.php';