Last active
May 22, 2025 03:18
-
-
Save thibaut-d/51cf5326e5017233ad4e6c3be77ae4b4 to your computer and use it in GitHub Desktop.
wordpress docker-compose.yml with Redis and Traefik
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3' | |
networks: | |
# enable connection with Traefik | |
traefik: | |
external: true | |
# network for the app | |
backend: | |
services: | |
wordpress: | |
build: | |
# call the Dockerfile in ./wordpress | |
context: ./wordpress | |
restart: always | |
logging: | |
options: | |
max-size: "10m" | |
max-file: "3" | |
environment: | |
# Connect WordPrerss to the database | |
WORDPRESS_DB_HOST: db:3306 | |
WORDPRESS_DB_USER: wordpressuser | |
WORDPRESS_DB_PASSWORD: changeme | |
WORDPRESS_DB_NAME: wordpressdb | |
volumes: | |
# save the content of WordPress an enable local modifications | |
- ./wordpress/data:/var/www/html | |
networks: | |
- traefik | |
- backend | |
depends_on: | |
- db | |
- redis | |
labels: | |
# The labels are usefull for Traefik only | |
- "traefik.enable=true" | |
- "traefik.docker.network=traefik" | |
# Get the routes from http | |
- "traefik.http.routers.wordpresscp.rule=Host(`mysite.com`)" | |
- "traefik.http.routers.wordpresscp.entrypoints=web" | |
# Redirect these routes to https | |
- "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https" | |
- "traefik.http.routers.wordpresscp.middlewares=redirect-to-https@docker" | |
# Get the routes from https | |
- "traefik.http.routers.wordpresscp-secured.rule=Host(`mysite.com`)" | |
- "traefik.http.routers.wordpresscp-secured.entrypoints=web-secure" | |
# Apply autentificiation with http challenge | |
- "traefik.http.routers.wordpresscp-secured.tls=true" | |
- "traefik.http.routers.wordpresscp-secured.tls.certresolver=myhttpchallenge" | |
db: | |
# this is the database used by Wordpress | |
image: mysql:5.7 | |
restart: always | |
logging: | |
options: | |
max-size: "10m" | |
max-file: "3" | |
environment: | |
# Connect WordPrerss to the database | |
MYSQL_DATABASE: wordpressdb | |
MYSQL_USER: wordpressuser | |
MYSQL_PASSWORD: changeme | |
MYSQL_RANDOM_ROOT_PASSWORD: '1' | |
volumes: | |
# Persist the database on disk | |
- ./db:/var/lib/mysql | |
networks: | |
- backend | |
redis: | |
image: redis:6 | |
restart: always | |
logging: | |
options: | |
max-size: "10m" | |
max-file: "3" | |
ports: | |
- "6379:6379" | |
networks: | |
- backend | |
# launch Redis in cache mode with : | |
# - max memory up to 50% of your RAM if needed (--maxmemory 512mb) | |
# - deleting oldest data when max memory is reached (--maxmemory-policy allkeys-lru) | |
entrypoint: redis-server --maxmemory 512mb -maxmemory-policy allkeys-lru |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yes, you are right.
afiter fix this, the redis can boot with warning like this,
follow the message to fix it and it's done.