pilasguru

Traefik + Wordpress docker-compose.yaml

Sep 22nd, 2021
1,200
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. version: '3'
  2.  
  3. services:
  4.   database:
  5.     image: mariadb:latest
  6.     container_name: database
  7.     restart: unless-stopped
  8.     volumes:
  9.      - $PWD/database:/var/lib/mysql
  10.     environment:
  11.       MARIADB_RANDOM_ROOT_PASSWORD: '1'
  12.       MARIADB_USER: blog
  13.       MARIADB_PASSWORD: AxTR59I
  14.       MARIADB_DATABASE: blog
  15.     networks:
  16.      - wp
  17.  
  18.   wordpress:
  19.     depends_on:
  20.      - database
  21.       - traefik
  22.     image: wordpress
  23.     container_name: wordpress
  24.     restart: unless-stopped
  25.     networks:
  26.      - proxy
  27.       - wp
  28.     volumes:
  29.      - $PWD/html:/var/www/html
  30.     environment:
  31.       WORDPRESS_DB_HOST: database
  32.       WORDPRESS_DB_USER: blog
  33.       WORDPRESS_DB_PASSWORD: AxTR59I
  34.       WORDPRESS_DB_NAME: blog
  35.     labels:
  36.      - "traefik.enable=true"
  37.       - "traefik.http.routers.blog.entrypoints=http"
  38.       - "traefik.http.routers.blog.rule=Host(`blog.doma.in`)"
  39.       - "traefik.http.middlewares.blog-https-redirect.redirectscheme.scheme=https"
  40.       - "traefik.http.routers.blog.middlewares=blog-https-redirect"
  41.       - "traefik.http.routers.blog-secure.entrypoints=https"
  42.       - "traefik.http.routers.blog-secure.rule=Host(`blog.doma.in`)"
  43.       - "traefik.http.routers.blog-secure.tls=true"
  44.       - "traefik.http.routers.blog-secure.tls.certresolver=http"
  45.       - "traefik.http.routers.blog-secure.service=blog"
  46.       - "traefik.http.services.blog.loadbalancer.server.port=80"
  47.       - "traefik.docker.network=proxy"
  48.  
  49.   traefik:
  50.     image: traefik:v2.1
  51.     container_name: traefik
  52.     restart: unless-stopped
  53.     security_opt:
  54.      - no-new-privileges:true
  55.     networks:
  56.      - proxy
  57.     ports:
  58.      - 80:80
  59.       - 443:443
  60.     volumes:
  61.      - /etc/localtime:/etc/localtime:ro
  62.       - /var/run/docker.sock:/var/run/docker.sock:ro
  63.       - $PWD/traefik-proxy/traefik.yml:/traefik.yml:ro
  64.       - $PWD/traefik-proxy/acme.json:/acme.json
  65.     labels:
  66.      - "traefik.enable=true"
  67.       - "traefik.http.routers.traefik.entrypoints=http"
  68.       - "traefik.http.routers.traefik.rule=Host(`traefik.doma.in`)"
  69.       - "traefik.http.middlewares.traefik-auth.basicauth.users=admin:$$apr1$$yvJi96A$$Q20oIPsstfBc8.ZFeW41"
  70.       - "traefik.http.middlewares.traefik-https-redirect.redirectscheme.scheme=https"
  71.       - "traefik.http.routers.traefik.middlewares=traefik-https-redirect"
  72.       - "traefik.http.routers.traefik-secure.entrypoints=https"
  73.       - "traefik.http.routers.traefik-secure.rule=Host(`traefik.doma.in`)"
  74.       - "traefik.http.routers.traefik-secure.middlewares=traefik-auth"
  75.       - "traefik.http.routers.traefik-secure.tls=true"
  76.       - "traefik.http.routers.traefik-secure.tls.certresolver=http"
  77.       - "traefik.http.routers.traefik-secure.service=api@internal"
  78.  
  79. networks:
  80.   proxy:
  81.   wp:
  82. ## -----------------------------------------
  83.  
  84. ## cat traefik-proxy/traefik.yml
  85. #debug: "true"
  86. #logLevel: "DEBUG"
  87.  
  88. api:
  89.   dashboard: true
  90.  
  91. entryPoints:
  92.   http:
  93.     address: ":80"
  94.   https:
  95.     address: ":443"
  96.  
  97. providers:
  98.   docker:
  99.     endpoint: "unix:///var/run/docker.sock"
  100.     exposedByDefault: false
  101.  
  102. certificatesResolvers:
  103.   http:
  104.     acme:
  105.       email: mail@doma.in
  106.       storage: acme.json
  107.       httpChallenge:
  108.         entryPoint: http
RAW Paste Data