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

View File

@ -5,4 +5,10 @@ WORDPRESS_DB_HOST=mariadb
WORDPRESS_DB_NAME=wordpress WORDPRESS_DB_NAME=wordpress
WORDPRESS_DB_USER=${MARIADB_USER} WORDPRESS_DB_USER=${MARIADB_USER}
WORDPRESS_DB_PASSWORD=${MARIADB_PASSWORD} 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 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 { function upmariadb {
if [[ $MARIADB_ACTIVATE == 1 && $MARIADB_LOCAL == 1 ]] if [[ $MARIADB_ACTIVATE == 1 && $MARIADB_LOCAL == 1 ]]
then then
Title "MARIADB" Title "MARIADB"
EchoVert "CONTAINER"
upservice $MARIADB_SERVICE_NAME upservice $MARIADB_SERVICE_NAME
createdatabase Echo
fi fi
} }
@ -209,13 +171,14 @@ function upopenldap {
if [[ $LDAP_ACTIVATE == 1 && $LDAP_LOCAL == 1 ]] if [[ $LDAP_ACTIVATE == 1 && $LDAP_LOCAL == 1 ]]
then then
Title ${OPENLDAP_SERVICE_NAME^^} Title ${OPENLDAP_SERVICE_NAME^^}
EchoVert "CONTAINER"
mkdir -p ./volume/openldap/data mkdir -p ./volume/openldap/data
chmod a+wr ./volume/openldap/data chmod a+wr ./volume/openldap/data
upservice $OPENLDAP_SERVICE_NAME upservice $OPENLDAP_SERVICE_NAME
$PODCOMPOSEBIN exec $OPENLDAP_SERVICE_NAME /envole/init.sh $PODCOMPOSEBIN exec $OPENLDAP_SERVICE_NAME /envole/init.sh
echo Echo
fi fi
} }
@ -223,8 +186,19 @@ function upkeycloak {
if [[ $CAS_ACTIVATE == 1 && $CAS_LOCAL == 1 ]] if [[ $CAS_ACTIVATE == 1 && $CAS_LOCAL == 1 ]]
then then
Title ${KEYCLOAK_SERVICE_NAME^^} 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 upservice $KEYCLOAK_SERVICE_NAME
echo Echo
fi fi
} }
@ -232,9 +206,19 @@ function upninegate {
if [[ $NINEGATE_ACTIVATE == 1 && $NINEGATE_LOCAL == 1 ]] if [[ $NINEGATE_ACTIVATE == 1 && $NINEGATE_LOCAL == 1 ]]
then then
Title ${NINEGATE_SERVICE_NAME^^} 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} upservice ${NINEGATE_SERVICE_NAME}
chmod -R a+wr ./volume/ninegate/data chmod -R a+wr ./volume/ninegate/data
echo Echo
fi fi
} }
@ -242,9 +226,19 @@ function upnineboard {
if [[ $NINEBOARD_ACTIVATE == 1 && $NINEBOARD_LOCAL == 1 ]] if [[ $NINEBOARD_ACTIVATE == 1 && $NINEBOARD_LOCAL == 1 ]]
then then
Title ${NINEBOARD_SERVICE_NAME^^} 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} upservice ${NINEBOARD_SERVICE_NAME}
chmod -R a+wr ./volume/nineboard/data chmod -R a+wr ./volume/nineboard/data
echo Echo
fi fi
} }
@ -252,8 +246,18 @@ function upnextcloud {
if [[ $NEXTCLOUD_ACTIVATE == 1 && $NEXTCLOUD_LOCAL == 1 ]] if [[ $NEXTCLOUD_ACTIVATE == 1 && $NEXTCLOUD_LOCAL == 1 ]]
then then
Title ${NEXTCLOUD_SERVICE_NAME^^} 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} upservice ${NEXTCLOUD_SERVICE_NAME}
echo Echo
fi fi
} }
@ -262,8 +266,18 @@ function upwordpress {
if [[ $WORDPRESS_ACTIVATE == 1 && $WORDPRESS_LOCAL == 1 ]] if [[ $WORDPRESS_ACTIVATE == 1 && $WORDPRESS_LOCAL == 1 ]]
then then
Title ${WORDPRESS_SERVICE_NAME^^} 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} upservice ${WORDPRESS_SERVICE_NAME}
echo Echo
fi fi
} }
@ -271,8 +285,9 @@ function upadminer {
if [[ $ADMINER_ACTIVATE == 1 && $ADMINER_LOCAL == 1 ]] if [[ $ADMINER_ACTIVATE == 1 && $ADMINER_LOCAL == 1 ]]
then then
Title ${ADMINER_SERVICE_NAME^^} Title ${ADMINER_SERVICE_NAME^^}
EchoVert "CONTAINER"
$PODCOMPOSEBIN up -d ${ADMINER_SERVICE_NAME} $PODCOMPOSEBIN up -d ${ADMINER_SERVICE_NAME}
echo Echo
fi fi
} }
@ -280,8 +295,9 @@ function upphpldapadmin {
if [[ $PHPLDAPADMIN_ACTIVATE == 1 && $PHPLDAPADMIN_LOCAL == 1 ]] if [[ $PHPLDAPADMIN_ACTIVATE == 1 && $PHPLDAPADMIN_LOCAL == 1 ]]
then then
Title ${PHPLDAPADMIN_SERVICE_NAME^^} Title ${PHPLDAPADMIN_SERVICE_NAME^^}
EchoVert "CONTAINER"
$PODCOMPOSEBIN up -d ${PHPLDAPADMIN_SERVICE_NAME} $PODCOMPOSEBIN up -d ${PHPLDAPADMIN_SERVICE_NAME}
echo Echo
fi fi
} }
@ -289,8 +305,9 @@ function upnineapache {
if [[ $NINEAPACHE_ACTIVATE == 1 && $NINEAPACHE_LOCAL == 1 ]] if [[ $NINEAPACHE_ACTIVATE == 1 && $NINEAPACHE_LOCAL == 1 ]]
then then
Title ${NINEAPACHE_SERVICE_NAME^^} Title ${NINEAPACHE_SERVICE_NAME^^}
EchoVert "CONTAINER"
$PODCOMPOSEBIN up -d ${NINEAPACHE_SERVICE_NAME} $PODCOMPOSEBIN up -d ${NINEAPACHE_SERVICE_NAME}
echo Echo
fi fi
} }
@ -351,11 +368,6 @@ up(){
upnineapache upnineapache
else else
env ${1} env ${1}
if [[ $1 != "mariadb" ]]
then
createdatabase
fi
up${1} up${1}
fi 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 DOMAIN_CURRENT_SITE ${WORDPRESS_DOMAINE}
wp config set --allow-root PATH_CURRENT_SITE ${WORDPRESS_ALIAS} wp config set --allow-root PATH_CURRENT_SITE ${WORDPRESS_ALIAS}
wp config set --allow-root FORCE_ADMIN_SSL false 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 # On fait croire à WP qu'il est en https
if grep -qF "_SERVER['HTTPS']='on'" "wp-config.php"; then if grep -qF "_SERVER['HTTPS']='on'" "wp-config.php"; then
@ -58,4 +59,9 @@ else
fi fi
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 $@ 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 COPY wp-cli.phar /usr/local/bin/wp
RUN chmod +x /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 COPY apache.conf /etc/apache2/conf.d/zapp.conf
# Installation des sources wordpress
RUN wp core download --path=/app/public --locale=fr_FR 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 RUN mkdir /docker
COPY entrypoint.sh /docker/entrypoint.sh COPY entrypoint.sh /docker/entrypoint.sh
RUN chmod +x /docker/entrypoint.sh RUN chmod +x /docker/entrypoint.sh
RUN chown -R apache:apache /app/public # CMD
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 /docker/entrypoint.sh && /etc/apache2/apache2.sh

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

@ -4,6 +4,8 @@ set -eo pipefail
cd /app/public cd /app/public
if [[ ! -f /app/public/wp-config.php ]]
then
wp config create \ wp config create \
--allow-root \ --allow-root \
--dbhost="${WORDPRESS_DB_HOST}" \ --dbhost="${WORDPRESS_DB_HOST}" \
@ -12,14 +14,73 @@ wp config create \
--dbpass="${WORDPRESS_DB_PASSWORD}" \ --dbpass="${WORDPRESS_DB_PASSWORD}" \
--dbcharset="utf8mb4" \ --dbcharset="utf8mb4" \
--locale="fr_FR" --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 \ wp core multisite-install \
--allow-root \ --allow-root \
--url="${WORDPRESS_WEBURL}" \ --url="${WORDPRESS_PROTOCOL}://${WORDPRESS_DOMAINE}" \
--title="${WORDPRESS_TITLE}" \ --title="${WORDPRESS_TITLE}" \
--admin_user="${WORDPRESS_USER}" \ --admin_user="${WORDPRESS_USER}" \
--admin_password="${WORDPRESS_PASSWORD}" \ --admin_password="${WORDPRESS_PASSWORD}" \
--admin_email="${WORDPRESS_EMAIL}" \ --admin_email="${WORDPRESS_EMAIL}" \
--skip-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 $@ exec $@

View File

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