add redis cache to wordpress
This commit is contained in:
parent
41e05fdb12
commit
10c9645099
5 changed files with 39 additions and 1 deletions
|
@ -42,6 +42,15 @@ services:
|
||||||
aliases:
|
aliases:
|
||||||
- $DOMAIN_NAME
|
- $DOMAIN_NAME
|
||||||
env_file: .env
|
env_file: .env
|
||||||
|
redis:
|
||||||
|
restart: on-failure
|
||||||
|
build:
|
||||||
|
context: ./requirements/bonus/redis
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
networks:
|
||||||
|
- inception
|
||||||
|
secrets:
|
||||||
|
- redis_password
|
||||||
wordpress:
|
wordpress:
|
||||||
restart: on-failure
|
restart: on-failure
|
||||||
depends_on:
|
depends_on:
|
||||||
|
@ -58,6 +67,7 @@ services:
|
||||||
secrets:
|
secrets:
|
||||||
- db_password
|
- db_password
|
||||||
- admin_password
|
- admin_password
|
||||||
|
- redis_password
|
||||||
env_file: .env
|
env_file: .env
|
||||||
adminer:
|
adminer:
|
||||||
restart: on-failure
|
restart: on-failure
|
||||||
|
@ -81,6 +91,8 @@ secrets:
|
||||||
file: ../secrets/db_root_password.txt
|
file: ../secrets/db_root_password.txt
|
||||||
admin_password:
|
admin_password:
|
||||||
file: ../secrets/credentials.txt
|
file: ../secrets/credentials.txt
|
||||||
|
redis_password:
|
||||||
|
file: ../secrets/redis_password.txt
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
inception:
|
inception:
|
||||||
|
|
14
srcs/requirements/bonus/redis/Dockerfile
Normal file
14
srcs/requirements/bonus/redis/Dockerfile
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
FROM alpine:3.21.2
|
||||||
|
|
||||||
|
LABEL org.opencontainers.image.authors="alier@student.42mulhouse.fr"
|
||||||
|
|
||||||
|
RUN apk add redis
|
||||||
|
|
||||||
|
HEALTHCHECK --start-period=5s \
|
||||||
|
CMD [ "$(cat /run/secrets/redis_password | redis-cli --askpass ping)" = "PONG" ]
|
||||||
|
|
||||||
|
COPY tools/setup_redis.sh /setup_redis.sh
|
||||||
|
|
||||||
|
EXPOSE 6379
|
||||||
|
|
||||||
|
ENTRYPOINT ["sh", "setup_redis.sh"]
|
6
srcs/requirements/bonus/redis/tools/setup_redis.sh
Normal file
6
srcs/requirements/bonus/redis/tools/setup_redis.sh
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
echo "requirepass $(cat /run/secrets/redis_password)
|
||||||
|
bind * -::*" >> /etc/redis.conf
|
||||||
|
|
||||||
|
exec redis-server /etc/redis.conf
|
|
@ -3,7 +3,7 @@ FROM alpine:3.21.2
|
||||||
LABEL org.opencontainers.image.authors="alier@student.42mulhouse.fr"
|
LABEL org.opencontainers.image.authors="alier@student.42mulhouse.fr"
|
||||||
|
|
||||||
RUN apk add php84 php84-phar php84-fpm php84-mysqli php84-iconv php84-curl php84-dom php84-exif \
|
RUN apk add php84 php84-phar php84-fpm php84-mysqli php84-iconv php84-curl php84-dom php84-exif \
|
||||||
php84-fileinfo php84-pecl-imagick php84-mbstring php84-zip php84-gd php84-intl fcgi curl
|
php84-fileinfo php84-pecl-imagick php84-mbstring php84-zip php84-gd php84-intl php84-tokenizer fcgi curl
|
||||||
|
|
||||||
RUN ln -s /usr/bin/php84 /usr/bin/php && \
|
RUN ln -s /usr/bin/php84 /usr/bin/php && \
|
||||||
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar && \
|
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar && \
|
||||||
|
|
|
@ -5,8 +5,14 @@ if [ ! -e '/var/www/wordpress/wp-config.php' ]; then
|
||||||
|
|
||||||
cd /var/www/wordpress
|
cd /var/www/wordpress
|
||||||
wp config create --dbname="$DB_DB" --dbuser="$DB_USER" --dbpass="$(cat /run/secrets/db_password)" --dbhost=mariadb
|
wp config create --dbname="$DB_DB" --dbuser="$DB_USER" --dbpass="$(cat /run/secrets/db_password)" --dbhost=mariadb
|
||||||
|
wp config set WP_REDIS_HOST "redis"
|
||||||
|
wp config set WP_REDIS_PORT "6379"
|
||||||
|
wp config set WP_REDIS_DATABASE "0"
|
||||||
|
wp config set WP_REDIS_PASSWORD "$(cat /run/secrets/redis_password)"
|
||||||
wp core install --url="$DOMAIN_NAME" --title="$TITLE" --admin_user="$ADMIN_USER" --admin_email="$ADMIN_EMAIL" \
|
wp core install --url="$DOMAIN_NAME" --title="$TITLE" --admin_user="$ADMIN_USER" --admin_email="$ADMIN_EMAIL" \
|
||||||
--admin_password="$(cat /run/secrets/admin_password)"
|
--admin_password="$(cat /run/secrets/admin_password)"
|
||||||
|
wp plugin install redis-cache --activate
|
||||||
|
wp redis enable
|
||||||
wp option update siteurl "https://$DOMAIN_NAME"
|
wp option update siteurl "https://$DOMAIN_NAME"
|
||||||
wp option update home "https://$DOMAIN_NAME"
|
wp option update home "https://$DOMAIN_NAME"
|
||||||
wp user create bob bob@example.org
|
wp user create bob bob@example.org
|
||||||
|
|
Loading…
Add table
Reference in a new issue