version: '3'

services:
  wordpress:
    container_name: peek
    logging:
      driver: "json-file"
      options:
        max-size: "5m"
        max-file: "3"
    depends_on:
      - db_peek
    image: wordpress:5.6.0-apache
    volumes:
      - ${DIR_LOCAL}/peekskog/wp:/var/www/html
      - ./wp/php.conf.ini:/usr/local/etc/php/conf.d/uploads.ini
    ports:
      - "8008:80"
    networks:
      - backend
    restart: always
    environment:
      WORDPRESS_DB_HOST: db_peek:3306
      WORDPRESS_DB_USER: wordpress
      WORDPRESS_DB_PASSWORD: peekskog
    labels:
      - diun.enable=true
      - "traefik.enable=true"
        # middleware to redirect www to non-www
      - "traefik.http.middlewares.www-redirect.redirectregex.regex=^https://www.peekskog.se/(.*)"
      - "traefik.http.middlewares.www-redirect.redirectregex.replacement=https://peekskog.se/$${1}"
      - "traefik.http.middlewares.www-redirect.redirectregex.permanent=true"
        # https router
      - "traefik.http.routers.peek-secure.entrypoints=web-secure"
      - "traefik.http.routers.peek-secure.rule=Host(`peekskog.se`) || Host(`www.peekskog.se`)"
      - "traefik.http.routers.peek-secure.middlewares=www-redirect,peek-middle"
      - "traefik.http.routers.peek-secure.middlewares=peek-middle"
      - "traefik.http.middlewares.peek-middle.headers.contentSecurityPolicy=frame-ancestors 'self' peekskog.se"
      - "traefik.http.middlewares.peek-middle.headers.framedeny=true"
      - "traefik.http.middlewares.peek-middle.headers.stsSeconds=155520011"
      - "traefik.http.middlewares.peek-middle.headers.stsIncludeSubdomains=true"
      - "traefik.http.middlewares.peek-middle.headers.stsPreload=true"
      - "traefik.http.middlewares.peek-middle.headers.customFrameOptionsValue=SAMEORIGIN"
      - "traefik.http.middlewares.peek-middle.headers.referrerPolicy=no-referrer"
      - "traefik.http.middlewares.peek-middle.headers.SSLRedirect=true"
      - "traefik.http.middlewares.peek-middle.headers.forceSTSHeader=true"
      - "traefik.http.middlewares.peek-middle.headers.browserXSSFilter=true"
      - "traefik.http.middlewares.peek-middle.headers.contentTypeNosniff=true"
#- "traefik.http.routers.peek-secure.rule=Host(`${DOMAIN_PEEK}`)"
      - "traefik.http.routers.peek-secure.tls.certresolver=peek"
      - "traefik.http.routers.peek-secure.tls=true"

  db_peek:
    container_name: db_peek
    image: mysql:5.7
    logging:
      driver: "json-file"
      options:
        max-size: "5m"
        max-file: "3"
    volumes:
      - ${DIR_LOCAL}/peekskog/db:/var/lib/mysql
    restart: always
    networks:
      - backend
    environment:
      MYSQL_ROOT_PASSWORD: peekskog
      MYSQL_DATABASE: wordpress
      MYSQL_USER: wordpress
      MYSQL_PASSWORD: peekskog

  phpmyadmin_peek:
    depends_on:
      - db_peek
    image: phpmyadmin/phpmyadmin
    container_name: phpmyadmin_peek
    logging:
      driver: "json-file"
      options:
        max-size: "5m"
        max-file: "3"
    restart: always
    networks:
      - backend
    ports:
      - '8007:80'
    environment:
      PMA_HOST: db_peek
    labels:
      - "traefik.enable=false"


networks:
  frontend:
    external: true
  backend:
    external: false

