fixed the pbm of wp cron job not working

This commit is contained in:
asus
2024-04-02 11:37:41 +02:00
parent 3c0a32e6ac
commit ce6d6b442a
3 changed files with 18 additions and 3 deletions

View File

@@ -5,7 +5,7 @@
# then install as recommended : curl -SL https://github.com/docker/compose/releases/download/v2.10.2/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose
# or (neat) : https://github.com/docker/compose/releases/download/v2.10.2/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
version: "3.8"
#version: "3.8"
services:
# ---------------------------------
@@ -75,6 +75,10 @@ services:
depends_on:
mariadb:
condition: service_healthy
# i was trying to resolve the wp_cron not working, I used the 'crontrol' plugin, it informed me curl didn't work, so i tried in the wordpress docker : 'curl <url of my local website>' and indeed it failed. I finally added this mapping to my /etc/hosts file in the wordpress container '172.17.0.1 <url of my local website>' (but i'm not sure '172.17.0.1' will always work, it seems to be constant for the default bridge network : https://docs.docker.com/network/network-tutorial-standalone/)
# https://stackoverflow.com/questions/24319662/from-inside-of-a-docker-container-how-do-i-connect-to-the-localhost-of-the-mach?rq=2
# extra_hosts:
# - "host.docker.internal:host-gateway"
# specify path to named volumes : https://docs.docker.com/compose/compose-file/compose-file-v3/#volume-configuration-reference
# local driver options : https://stackoverflow.com/questions/62232676/docker-local-volume-driver-options
@@ -104,6 +108,7 @@ volumes:
# o: "bind"
# device: ${HOST_VOLUME_ERROR_LOGS}
networks:
local-wp:

View File

@@ -1,4 +1,3 @@
FROM alpine:3.15
RUN apk update
@@ -49,4 +48,3 @@ RUN curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli
COPY ./conf/wp_entrypoint.sh ./
ENTRYPOINT [ "sh", "wp_entrypoint.sh" ]

View File

@@ -12,6 +12,18 @@ RESET="\e[0m"
# it gets the ENV variables from .env because specified in the docker-compose.yml file
# this is to make the wp_cron job works
# ! it might not be a very strong solution
#
# somehow it didn't work if the local adress is not accessible from inside the wordpress container :
# if : `curl <PROJECT_URL>` don't work, the cron job does not either (why ?)
# to make it work, i mapped the docker network gateway ip to the url (without understanding what i'm doing)
# the default network is named bridge, and it's gateway is 172.17.0.1 : https://docs.docker.com/network/network-tutorial-standalone/
# also might help, even though i didn't use, it helped me find the ip 172.17.0.1 : https://stackoverflow.com/questions/24319662/from-inside-of-a-docker-container-how-do-i-connect-to-the-localhost-of-the-mach?rq=2
echo "172.17.0.1 ${PROJECT_URL}" >> /etc/hosts
# install wordpress with cli : https://make.wordpress.org/cli/handbook/how-to-install/
# commands : https://developer.wordpress.org/cli/commands/
# bug with wp commands : https://github.com/wp-cli/config-command/issues/31