如何在本地开发中对drupal 8多站点进行docker化?

时间:2018-08-03 14:36:31

标签: php docker drupal docker-compose drupal-8

我正在尝试使用docker容器化我现有的drupal 8多站点。我将docker-compose文件基于docker4drupal。我也在关注docker4drupal More Multisite Questions #299,但仍然无法在Mac OS本地开发中仅使用一个数据库来解决我的drupal 8多站点。我正在按照这个Drupalize.me Dockerize an Existing Project来容器化我现有的drupal 8多站点,并使用Wodby的Deploy all sites in one instance文档来设置当前的多站点。

我能够访问portainer.localhost,whoami.docker.localhost,pma.localhost,mailhog.localhost和traefik(localhost:8080 / dashboard /)。我无法访问的是:reverse-proxy.drupalsites.localhost,php.drupalsites.localhost,mariadb.drupalsites.localhost和localhost。我访问时在页面上显示的错误是“找不到404页面”。访问本地主机的错误是“找不到文件”。

这是我的docker-compose.yml文件。

version: "3"

services:
  mariadb:
    image: wodby/mariadb:$MARIADB_TAG
    container_name: "${PROJECT_NAME}_mariadb"
    stop_grace_period: 30s
    environment:
      MYSQL_ROOT_PASSWORD: $DB_ROOT_PASSWORD
      MYSQL_DATABASE: $DB_NAME
      MYSQL_USER: $DB_USER
      MYSQL_PASSWORD: $DB_PASSWORD
    volumes:
      - ./db-backups:/var/lib/backups:delegated
    ports:
      - "3306:3306"
  php:
    image: wodby/drupal-php:$PHP_TAG
    container_name: "${PROJECT_NAME}_php"
    environment:
      PHP_SENDMAIL_PATH: /usr/sbin/sendmail -t -i -S mailhog:1025
      DB_HOST: $DB_HOST
      DB_USER: $DB_USER
      DB_PASSWORD: $DB_PASSWORD
      DB_NAME: $DB_NAME
      DB_DRIVER: $DB_DRIVER
    volumes:
      - ./docroot:/var/www/html:cached

  nginx:
    image: wodby/drupal-nginx:$NGINX_TAG
    container_name: "${PROJECT_NAME}_nginx"
    depends_on:
      - php
    environment:
#      NGINX_PAGESPEED: "on"
      NGINX_STATIC_CONTENT_OPEN_FILE_CACHE: "off"
      NGINX_ERROR_LOG_LEVEL: debug
      NGINX_BACKEND_HOST: php
      NGINX_SERVER_ROOT: /var/www/html/web
    volumes:
      - ./docroot:/var/www/html
    labels:
      - 'traefik.backend=nginx'
      - 'traefik.port=80'
      - 'traefik.frontend.rule=Host:${PROJECT_BASE_URL}'

  mailhog:
    image: mailhog/mailhog
    container_name: "${PROJECT_NAME}_mailhog"
    labels:
      - 'traefik.backend=mailhog'
      - 'traefik.port=8025'
      - 'traefik.frontend.rule=Host:mailhog.${PROJECT_BASE_URL}'

  pma:
    image: phpmyadmin/phpmyadmin
    container_name: "${PROJECT_NAME}_pma"
    environment:
      PMA_HOST: $DB_HOST
      PMA_USER: $PMA_USER
      PMA_PASSWORD: $DB_PASSWORD
      PHP_UPLOAD_MAX_FILESIZE: 1G
      PHP_MAX_INPUT_VARS: 1G
    labels:
      - 'traefik.backend=pma'
      - 'traefik.port=80'
      - 'traefik.frontend.rule=Host:pma.${PROJECT_BASE_URL}'
    ports:
      - "8001:80"

  portainer:
    image: portainer/portainer
    container_name: "${PROJECT_NAME}_portainer"
    command: --no-auth -H unix:///var/run/docker.sock
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    labels:
      - 'traefik.backend=portainer'
      - 'traefik.port=9000'
      - 'traefik.frontend.rule=Host:portainer.${PROJECT_BASE_URL}'

  reverse-proxy:
    image: traefik #The official Traefik docker image
    container_name: "${PROJECT_NAME}_traefik"
    command: --api --docker #Enables the web UI and tells Træfik to listen to docker
    ports:
      - "80:80" #The HTTP port
      - "8080:8080" #The Web UI (enabled by --api)
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock # So that Traefik can listen to the Docker events

  whoami:
      image: emilevauge/whoami # A container that exposes an API to show its IP address
      labels:
        - "traefik.frontend.rule=Host:whoami.docker.localhost"

这是我的环境变量。

#Set environment default values for each site in multi-site

###PROJECT SETTINGS
PROJECT_NAME=docker-project
PROJECT_BASE_URL=localhost

DB_ROOT_PASSWORD=123456
DB_NAME=example
DB_USER=admin
DB_PASSWORD=654321
DB_HOST=mariadb
DB_DRIVER=mysql
PMA_USER=admin

### --- MARIADB ---
MARIADB_TAG=10.3

### --- Drupal 8 ---
DRUPAL_TAG=8-7.2-4.6.0

### --- PHP ---
PHP_TAG=7.2

### -- NGINX ---
NGINX_TAG=1.15

0 个答案:

没有答案