Files
DOCKER_wordpress/srcs/docker-compose.yml
2024-04-02 11:37:41 +02:00

115 lines
3.8 KiB
YAML

# doc : https://docs.docker.com/compose/compose-file/compose-versioning/
# version : https://docs.docker.com/compose/compose-file/compose-versioning/
# version to download : https://github.com/docker/compose/releases/
# had to remove the apt version because it was not up to date (sudo apt remove docker-compose)
# 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"
services:
# ---------------------------------
nginx:
restart: on-failure
networks:
- local-wp
ports:
- "${WP_PORT}:443"
volumes:
- wp_volume:${WP_VOLUME_DIR}
- wp_plugins:${WP_VOLUME_PLUGINS}
build:
context: ./requirements/nginx
args:
- WP_URL=${WP_URL}
- SERVER_MAX_UPLOAD_SIZE=${SERVER_MAX_UPLOAD_SIZE}
- WP_VOLUME_DIR=${WP_VOLUME_DIR}
- WP_VOLUME_PLUGINS=${WP_VOLUME_PLUGINS}
- NG_CERTS_DIR=${NG_CERTS_DIR}
image: nginx
container_name: nginx_container
depends_on:
wordpress:
condition: service_started
# ---------------------------------
mariadb:
restart: on-failure
env_file: .env
networks:
- local-wp
volumes:
- db_volume:${DB_VOLUME_DIR}
build:
context: ./requirements/mariadb
args:
- DB_HOST=${DB_HOST}
- DB_NAME=${DB_NAME}
- DB_USER=${DB_USER}
- DB_PSWD=${DB_PSWD}
- DB_VOLUME_DIR=${DB_VOLUME_DIR}
healthcheck:
test: mariadb -h ${DB_HOST} -u ${DB_USER} -p"${DB_PSWD}" -e exit 2> /dev/null
interval: 1s
timeout: 10s
retries: 10
image: mariadb
container_name: mariadb_container
# ---------------------------------
wordpress:
restart: on-failure
env_file: .env
networks:
- local-wp
volumes:
- wp_volume:${WP_VOLUME_DIR}
- wp_plugins:${WP_VOLUME_PLUGINS}
build:
context: ./requirements/wordpress
args:
- WP_VOLUME_DIR=${WP_VOLUME_DIR}
- WP_VOLUME_PLUGINS=${WP_VOLUME_PLUGINS}
- SERVER_MAX_UPLOAD_SIZE=${SERVER_MAX_UPLOAD_SIZE}
- SERVER_EXECUTION_TIME=${SERVER_EXECUTION_TIME}
image: wordpress
container_name: wordpress_container
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
volumes:
db_volume:
driver: local
driver_opts:
type: none
o: "bind"
device: ${HOST_VOLUME_DB}
wp_volume:
driver: local
driver_opts:
type: none
o: "bind"
device: ${HOST_VOLUME_WP}
wp_plugins:
driver: local
driver_opts:
type: none
o: "bind"
device: ${HOST_VOLUME_PLUGINS}
# error_logs:
# driver: local
# driver_opts:
# type: none
# o: "bind"
# device: ${HOST_VOLUME_ERROR_LOGS}
networks:
local-wp: