This commit is contained in:
Danny Houtworm 2023-08-14 01:00:42 +00:00
parent 8b40da9fd2
commit 2bce8efb23
8 changed files with 59 additions and 15 deletions

View File

@ -2,15 +2,11 @@ all: up
build:
sudo docker network create --subnet=172.20.30.0/24 wordpress
sudo mkdir -p ./build /home/djonker/data/adminer
sudo curl -f https://wordpress.org/latest.tar.gz --output /home/djonker/data/latest.tar.gz
sudo tar -xvf /home/djonker/data/latest.tar.gz
sudo mv wordpress /home/djonker/data/wordpress
sudo cp srcs/requirements/wordpress/srcs/wordpress.conf /home/djonker/data/wordpress/wp-config.php
sudo curl -f https://downloads.wordpress.org/plugin/w3-total-cache.2.4.1.zip --output /home/djonker/data/rediscache.zip
sudo unzip /home/djonker/data/rediscache.zip
sudo mv w3-total-cache /home/djonker/data/wordpress/wp-content/plugins/w3-total-cache
sudo chown -R 33:33 /home/djonker/data/wordpress
sudo mkdir -p ./build /home/djonker/data/adminer /home/djonker/data/wordpress
sudo cp srcs/requirements/wordpress/srcs/wordpress.conf /home/djonker/data/wordpress/wp-config.php.temp
sudo curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
sudo mv wp-cli.phar /home/djonker/data/wordpress/wp-cli.phar
sudo chmod +x /home/djonker/data/wordpress/wp-cli.phar
sudo curl -L https://github.com/vrana/adminer/releases/download/v4.8.1/adminer-4.8.1.php --output /home/djonker/data/adminer/adminer.php
up: build

View File

@ -1,3 +1,9 @@
WORDPRESSDATABASEPASSWD=password
WORDPRESSDATABASEUSER=wordpress
WORDPRESSDATABASE=wordpress
WPADMINUSER=djonker
WPADMINPASSWD=password
WPADMINEMAIL=danny@houtworm.email
WPUSERUSER=user42
WPUSERPASSWD=password
WPUSEREMAIL=user42@houtworm.email

View File

@ -33,6 +33,17 @@ services:
ipv4_address: 172.20.30.20
wordpress:
build: ./requirements/wordpress
environment:
- WORDPRESSDATABASE=${WORDPRESSDATABASE}
- WORDPRESSDATABASEUSER=${WORDPRESSDATABASEUSER}
- WORDPRESSDATABASEPASSWD=${WORDPRESSDATABASEPASSWD}
- WPADMINUSER=${WPADMINUSER}
- WPADMINPASSWD=${WPADMINPASSWD}
- WPADMINEMAIL=${WPADMINEMAIL}
- WPUSERUSER=${WPUSERUSER}
- WPUSERPASSWD=${WPUSERPASSWD}
- WPUSEREMAIL=${WPUSEREMAIL}
init: true
container_name: wordpress
restart: always
volumes:

View File

@ -6,7 +6,7 @@ else
mysql_install_db --user=mysql --datadir=/var/lib/mysql
mysqld & sleep 10
mysql -e "CREATE DATABASE $WORDPRESSDATABASE"
mysql wordpress < wordpress.sql
#mysql wordpress < wordpress.sql
mysql -e "GRANT ALL PRIVILEGES ON $WORDPRESSDATABASE.* TO $WORDPRESSDATABASEUSER@172.20.30.30 IDENTIFIED BY '$WORDPRESSDATABASEPASSWD'"
mysql -e "GRANT ALL PRIVILEGES ON $WORDPRESSDATABASE.* TO $WORDPRESSDATABASEUSER@172.20.30.40 IDENTIFIED BY '$WORDPRESSDATABASEPASSWD'"
killall mysqld

View File

@ -3,4 +3,5 @@ RUN sleep 10
RUN apk update
RUN apk add redis
WORKDIR /root/
CMD sh redis-server
CMD redis-server --protected-mode no
EXPOSE 6379/tcp

View File

@ -1,4 +1,10 @@
FROM alpine
ARG WORDPRESSDATABASE=${WORDPRESSDATABASE}
ARG WORDPRESSDATABASEUSER=${WORDPRESSDATABASEUSER}
ARG WORDPRESSDATABASEPASSWD=${WORDPRESSDATABASEPASSWD}
ARG WPADMINUSER=${WPADMINUSER}
ARG WPADMINPASSWD=$(WPADMINPASSWD)
ARG WPADMINEMAIL=$(WPADMINEMAIL)
RUN sleep 10
RUN apk update
RUN apk add openssl
@ -11,8 +17,10 @@ RUN apk add php-curl
RUN apk add php-json
RUN apk add php-xml
RUN apk add php-zip
RUN apk add php-phar
COPY srcs/start.sh /root/start.sh
COPY srcs/www.conf /etc/php81/php-fpm.d/www.conf
COPY srcs/wordpress.conf /var/www/wordpress/wp-config.php
WORKDIR /root/
CMD php-fpm81 -F -R
CMD sh start.sh
EXPOSE 9000/tcp

View File

@ -0,0 +1,20 @@
#!/bin/sh
if cat /var/www/wordpress/wp-config.php
then
touch /var/www/wordpress/wp-config.php
else
sleep 15
cd /var/www/wordpress
mv wp-cli.phar /usr/bin/wpcli
mv wp-config.php.temp wp-config.php
sed -i "23i define( 'DB_NAME', '${WORDPRESSDATABASE}' );" wp-config.php
sed -i "26i define( 'DB_USER', '${WORDPRESSDATABASEUSER}' );" wp-config.php
sed -i "29i define( 'DB_PASSWORD', '${WORDPRESSDATABASEPASSWD}' );" wp-config.php
wpcli core download
wpcli core install --url=https://djonker.42.fr --title=Wordpress --admin_user=${WPADMINUSER} --admin_password=${WPADMINPASSWD} --admin_email=${WPADMINEMAIL}
wpcli user create ${WPUSERUSER} ${WPUSEREMAIL} --user_pass=${WPUSERPASSWD} --role=subscriber
wpcli plugin install redis-cache --activate
chown -R 1000:1000 /var/www/wordpress
fi
wpcli redis enable
php-fpm81 -F -R

View File

@ -20,13 +20,10 @@
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define( 'DB_NAME', 'wordpress' );
/** MySQL database username */
define( 'DB_USER', 'wordpress' );
/** MySQL database password */
define( 'DB_PASSWORD', 'password' );
/** MySQL hostname */
define( 'DB_HOST', '172.20.30.20' );
@ -81,6 +78,11 @@ $table_prefix = 'wp_';
* @link https://wordpress.org/support/article/debugging-in-wordpress/
*/
define( 'WP_DEBUG', false );
define( 'WP_REDIS_HOST', '172.20.30.50' );
define( 'WP_REDIS_PORT', 6379 );
define( 'WP_REDIS_TIMEOUT', 1 );
define( 'WP_REDIS_READ_TIMEOUT', 1 );
define( 'WP_REDIS_DATABASE', 0 );
/* That's all, stop editing! Happy publishing. */
/** Absolute path to the WordPress directory. */