wordpress

This commit is contained in:
afornerot 2024-03-06 08:48:50 +01:00
parent 02bf178c36
commit 3e5dfcd49e
8 changed files with 166 additions and 89 deletions

View File

@ -116,7 +116,7 @@ services:
- ./volume/nineboard/data/public:/app/public/uploads
wordpress:
image: wordpress
image: reg.cadoles.com/envole/wordpress
container_name: envole-wordpress
restart: always
healthcheck:
@ -129,7 +129,7 @@ services:
ports:
- "9003:80"
volumes:
- ./volume/wordpress/data:/var/www/html
- ./volume/wordpress/data:/app/public
adminer:
image: docker.io/library/adminer

View File

@ -5,4 +5,10 @@ WORDPRESS_DB_HOST=mariadb
WORDPRESS_DB_NAME=wordpress
WORDPRESS_DB_USER=${MARIADB_USER}
WORDPRESS_DB_PASSWORD=${MARIADB_PASSWORD}
WORDPRESS_TITLE=wordpress
WORDPRESS_USER=${ADMIN_USER}
WORDPRESS_PASSWORD=${ADMIN_PASSWORD}
WORDPRESS_EMAIL=${ADMIN_USER}@noreply.fr
WORDPRESS_PROTOCOL=${PROTOCOLE}
WORDPRESS_DOMAINE=${WEB_URL}
WORDPRESS_ALIAS=/wordpress/

View File

@ -157,51 +157,13 @@ upservice(){
wait_for_container $1
}
createdatabase(){
# DATABASE
if [[ $MARIADB_ACTIVATE == 1 && $MARIADB_LOCAL == 1 ]]
then
Title "DATABASE"
# CREATE BDD
if [[ $CAS_ACTIVATE == 1 && $CAS_LOCAL == 1 ]]
then
EchoVert ${KEYCLOAK_SERVICE_NAME^^}
$PODCOMPOSEBIN exec $MARIADB_SERVICE_NAME /envole/init.sh $KEYCLOAK_SERVICE_NAME
fi
if [[ $NINEGATE_ACTIVATE == 1 && $NINEGATE_LOCAL == 1 ]]
then
EchoVert ${NINEGATE_SERVICE_NAME^^}
$PODCOMPOSEBIN exec $MARIADB_SERVICE_NAME /envole/init.sh $NINEGATE_SERVICE_NAME
fi
if [[ $NINEBOARD_ACTIVATE == 1 && $NINEBOARD_LOCAL == 1 ]]
then
EchoVert ${NINEBOARD_SERVICE_NAME^^}
$PODCOMPOSEBIN exec $MARIADB_SERVICE_NAME /envole/init.sh $NINEBOARD_SERVICE_NAME
fi
if [[ $NEXTCLOUD_ACTIVATE == 1 && $NEXTCLOUD_LOCAL == 1 ]]
then
EchoVert ${NEXTCLOUD_SERVICE_NAME^^}
$PODCOMPOSEBIN exec $MARIADB_SERVICE_NAME /envole/init.sh $NEXTCLOUD_SERVICE_NAME
fi
if [[ $WORDPRESS_ACTIVATE == 1 && $WORDPRESS_LOCAL == 1 ]]
then
EchoVert ${WORDPRESS_SERVICE_NAME^^}
$PODCOMPOSEBIN exec $MARIADB_SERVICE_NAME /envole/init.sh $WORDPRESS_SERVICE_NAME
fi
fi
}
function upmariadb {
if [[ $MARIADB_ACTIVATE == 1 && $MARIADB_LOCAL == 1 ]]
then
Title "MARIADB"
EchoVert "CONTAINER"
upservice $MARIADB_SERVICE_NAME
createdatabase
Echo
fi
}
@ -209,13 +171,14 @@ function upopenldap {
if [[ $LDAP_ACTIVATE == 1 && $LDAP_LOCAL == 1 ]]
then
Title ${OPENLDAP_SERVICE_NAME^^}
EchoVert "CONTAINER"
mkdir -p ./volume/openldap/data
chmod a+wr ./volume/openldap/data
upservice $OPENLDAP_SERVICE_NAME
$PODCOMPOSEBIN exec $OPENLDAP_SERVICE_NAME /envole/init.sh
echo
Echo
fi
}
@ -223,8 +186,19 @@ function upkeycloak {
if [[ $CAS_ACTIVATE == 1 && $CAS_LOCAL == 1 ]]
then
Title ${KEYCLOAK_SERVICE_NAME^^}
# CREATE BDD
if [[ $MARIADB_ACTIVATE == 1 && $MARIADB_LOCAL == 1 ]]
then
EchoVert "DATABASE"
Echo ${KEYCLOAK_SERVICE_NAME^^}
$PODCOMPOSEBIN exec $MARIADB_SERVICE_NAME /envole/init.sh $KEYCLOAK_SERVICE_NAME
Echo
fi
EchoVert "CONTAINER"
upservice $KEYCLOAK_SERVICE_NAME
echo
Echo
fi
}
@ -232,9 +206,19 @@ function upninegate {
if [[ $NINEGATE_ACTIVATE == 1 && $NINEGATE_LOCAL == 1 ]]
then
Title ${NINEGATE_SERVICE_NAME^^}
if [[ $MARIADB_ACTIVATE == 1 && $MARIADB_LOCAL == 1 ]]
then
EchoVert "DATABASE"
Echo ${NINEGATE_SERVICE_NAME^^}
$PODCOMPOSEBIN exec $MARIADB_SERVICE_NAME /envole/init.sh $NINEGATE_SERVICE_NAME
Echo
fi
EchoVert "CONTAINER"
upservice ${NINEGATE_SERVICE_NAME}
chmod -R a+wr ./volume/ninegate/data
echo
Echo
fi
}
@ -242,9 +226,19 @@ function upnineboard {
if [[ $NINEBOARD_ACTIVATE == 1 && $NINEBOARD_LOCAL == 1 ]]
then
Title ${NINEBOARD_SERVICE_NAME^^}
if [[ $MARIADB_ACTIVATE == 1 && $MARIADB_LOCAL == 1 ]]
then
EchoVert "DATABASE"
Echo ${NINEBOARD_SERVICE_NAME^^}
$PODCOMPOSEBIN exec $MARIADB_SERVICE_NAME /envole/init.sh $NINEBOARD_SERVICE_NAME
Echo
fi
EchoVert "CONTAINER"
upservice ${NINEBOARD_SERVICE_NAME}
chmod -R a+wr ./volume/nineboard/data
echo
Echo
fi
}
@ -252,8 +246,18 @@ function upnextcloud {
if [[ $NEXTCLOUD_ACTIVATE == 1 && $NEXTCLOUD_LOCAL == 1 ]]
then
Title ${NEXTCLOUD_SERVICE_NAME^^}
if [[ $MARIADB_ACTIVATE == 1 && $MARIADB_LOCAL == 1 ]]
then
EchoVert "DATABASE"
Echo ${NEXTCLOUD_SERVICE_NAME^^}
Echo
$PODCOMPOSEBIN exec $MARIADB_SERVICE_NAME /envole/init.sh $NEXTCLOUD_SERVICE_NAME
fi
EchoVert "CONTAINER"
upservice ${NEXTCLOUD_SERVICE_NAME}
echo
Echo
fi
}
@ -262,8 +266,18 @@ function upwordpress {
if [[ $WORDPRESS_ACTIVATE == 1 && $WORDPRESS_LOCAL == 1 ]]
then
Title ${WORDPRESS_SERVICE_NAME^^}
if [[ $MARIADB_ACTIVATE == 1 && $MARIADB_LOCAL == 1 ]]
then
EchoVert "DATABASE"
Echo ${WORDPRESS_SERVICE_NAME^^}
$PODCOMPOSEBIN exec $MARIADB_SERVICE_NAME /envole/init.sh $WORDPRESS_SERVICE_NAME
Echo
fi
EchoVert "CONTAINER"
upservice ${WORDPRESS_SERVICE_NAME}
echo
Echo
fi
}
@ -271,8 +285,9 @@ function upadminer {
if [[ $ADMINER_ACTIVATE == 1 && $ADMINER_LOCAL == 1 ]]
then
Title ${ADMINER_SERVICE_NAME^^}
EchoVert "CONTAINER"
$PODCOMPOSEBIN up -d ${ADMINER_SERVICE_NAME}
echo
Echo
fi
}
@ -280,8 +295,9 @@ function upphpldapadmin {
if [[ $PHPLDAPADMIN_ACTIVATE == 1 && $PHPLDAPADMIN_LOCAL == 1 ]]
then
Title ${PHPLDAPADMIN_SERVICE_NAME^^}
EchoVert "CONTAINER"
$PODCOMPOSEBIN up -d ${PHPLDAPADMIN_SERVICE_NAME}
echo
Echo
fi
}
@ -289,8 +305,9 @@ function upnineapache {
if [[ $NINEAPACHE_ACTIVATE == 1 && $NINEAPACHE_LOCAL == 1 ]]
then
Title ${NINEAPACHE_SERVICE_NAME^^}
EchoVert "CONTAINER"
$PODCOMPOSEBIN up -d ${NINEAPACHE_SERVICE_NAME}
echo
Echo
fi
}
@ -351,11 +368,6 @@ up(){
upnineapache
else
env ${1}
if [[ $1 != "mariadb" ]]
then
createdatabase
fi
up${1}
fi
}

View File

@ -39,7 +39,8 @@ wp config set --allow-root SUBDOMAIN_INSTALL false
wp config set --allow-root DOMAIN_CURRENT_SITE ${WORDPRESS_DOMAINE}
wp config set --allow-root PATH_CURRENT_SITE ${WORDPRESS_ALIAS}
wp config set --allow-root FORCE_ADMIN_SSL false
wp config set --allow-root SITE_ID_CURRENT_SITE 1
wp config set --allow-root BLOG_ID_CURRENT_SITE 1
# On fait croire à WP qu'il est en https
if grep -qF "_SERVER['HTTPS']='on'" "wp-config.php"; then
@ -58,4 +59,9 @@ else
fi
fi
# Mise à jour theme / plugin / network
wp theme update --allow-root --all
wp plugin update --allow-root --all
wp core update-db --network
exec $@

View File

@ -1,11 +0,0 @@
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]

View File

@ -7,17 +7,19 @@ RUN apk add php81-mysqli
COPY wp-cli.phar /usr/local/bin/wp
RUN chmod +x /usr/local/bin/wp
# Installation des sources wordpress
# Configuration apache
RUN cd /app/public
COPY apache.conf /etc/apache2/conf.d/zapp.conf
# Installation des sources wordpress
RUN wp core download --path=/app/public --locale=fr_FR
#COPY .htaccess /app/public/.htaccess
RUN chown -R apache:apache /app/public
RUN find /app/public -type d -exec chmod 755 {} +
RUN find /app/public -type f -exec chmod 644 {} +
RUN mkdir /docker
COPY entrypoint.sh /docker/entrypoint.sh
RUN chmod +x /docker/entrypoint.sh
RUN chown -R apache:apache /app/public
RUN find /app/public -type d -exec chmod 755 {} +
RUN find /app/public -type f -exec chmod 644 {} +
CMD /docker/entrypoint.sh && /etc/apache2/apache2.sh
# CMD
CMD /docker/entrypoint.sh && /etc/apache2/apache2.sh

81
misc/wordpress/containers/wordpress/entrypoint.sh Normal file → Executable file
View File

@ -4,22 +4,83 @@ set -eo pipefail
cd /app/public
wp config create \
--allow-root \
--dbhost="${WORDPRESS_DB_HOST}" \
--dbname="${WORDPRESS_DB_NAME}" \
--dbuser="${WORDPRESS_DB_USER}" \
--dbpass="${WORDPRESS_DB_PASSWORD}" \
--dbcharset="utf8mb4" \
--locale="fr_FR"
if [[ ! -f /app/public/wp-config.php ]]
then
wp config create \
--allow-root \
--dbhost="${WORDPRESS_DB_HOST}" \
--dbname="${WORDPRESS_DB_NAME}" \
--dbuser="${WORDPRESS_DB_USER}" \
--dbpass="${WORDPRESS_DB_PASSWORD}" \
--dbcharset="utf8mb4" \
--locale="fr_FR"
fi
wp config set --allow-root DB_HOST ${WORDPRESS_DB_HOST}
wp config set --allow-root DB_NAME ${WORDPRESS_DB_NAME}
wp config set --allow-root DB_USER ${WORDPRESS_DB_USER}
wp config set --allow-root DB_PASSWORD ${WORDPRESS_DB_PASSWORD}
wp config set --allow-root WP_HOME ${WORDPRESS_PROTOCOL}://${WORDPRESS_DOMAINE}${WORDPRESS_ALIAS}
wp config set --allow-root WP_SITEURL ${WORDPRESS_PROTOCOL}://${WORDPRESS_DOMAINE}${WORDPRESS_ALIAS}
wp config set --allow-root WP_ALLOW_MULTISITE true
wp config set --allow-root MULTISITE true
wp config set --allow-root SUBDOMAIN_INSTALL false
wp config set --allow-root DOMAIN_CURRENT_SITE ${WORDPRESS_DOMAINE}
wp config set --allow-root PATH_CURRENT_SITE ${WORDPRESS_ALIAS}
wp config set --allow-root FORCE_ADMIN_SSL false
wp config set --allow-root SITE_ID_CURRENT_SITE 1
wp config set --allow-root BLOG_ID_CURRENT_SITE 1
# On fait croire à WP qu'il est en https
if grep -qF "_SERVER['HTTPS']='on'" "wp-config.php"; then
if [[ "${WORDPRESS_PROTOCOL}" == "https" ]]
then
echo "FORCE HTTPS already set"
fi
else
if [[ "${WORDPRESS_PROTOCOL}" == "https" ]]
then
echo "FORCE HTTPS set"
head -n 1 "wp-config.php" > "wp-config.tmp"
echo "\$_SERVER['HTTPS']='on';" >> "wp-config.tmp"
tail -n +2 "wp-config.php" >> "wp-config.tmp"
mv "wp-config.tmp" "wp-config.php"
fi
fi
# Install multisite
wp core multisite-install \
--allow-root \
--url="${WORDPRESS_WEBURL}" \
--url="${WORDPRESS_PROTOCOL}://${WORDPRESS_DOMAINE}" \
--title="${WORDPRESS_TITLE}" \
--admin_user="${WORDPRESS_USER}" \
--admin_password="${WORDPRESS_PASSWORD}" \
--admin_email="${WORDPRESS_EMAIL}" \
--skip-email
# Switch language
wp site switch-language fr_FR
# Install plugin
if [[ "${MODE_AUTH}" == "CAS" && "${CAS_ACTIVATE}" == "1" ]]
then
wp plugin install wp-cassify
wp plugin activate wp-cassify --network
else
wp plugin delete wp-cassify
fi
# Mise à jour theme / plugin / network
wp theme update --allow-root --all
wp plugin update --allow-root --all
wp language core update
wp language theme update --all
wp language plugin update --all
# Mise à jour du network
wp core update-db --network
exec $@

View File

@ -11,7 +11,7 @@ services:
MYSQL_ROOT_PASSWORD: changeme
MYSQL_DATABASE: wordpress
MYSQL_USER: user
MYSQL_PASSWORD: changeme
MYSQL_PASSWORD: changeme
volumes:
- mariadb-data:/var/lib/mysql
@ -20,6 +20,7 @@ services:
context: ./containers/wordpress
image: reg.cadoles.com/envole/wordpress
container_name: wordpress-app
restart: always
depends_on:
- mariadb
ports:
@ -38,7 +39,7 @@ services:
- WORDPRESS_ALIAS=/wordpress/
volumes:
- ./containers/volume:/docker
- ./containers/data:/app/public/wp-content/plugins/wp-cas
adminer:
image: docker.io/library/adminer