Docker compose 一键部署Drupal开发环境

Published on Aug. 22, 2023, 12:11 p.m.

version: '2'
services:
  mariadb:
    image: docker.io/bitnami/mariadb:10.6
    environment:
      # ALLOW_EMPTY_PASSWORD is recommended only for development.
      - ALLOW_EMPTY_PASSWORD=yes
      - MARIADB_USER=bn_drupal
      - MARIADB_DATABASE=bitnami_drupal
    volumes:
      - 'mariadb_data:/bitnami/mariadb'
  drupal:
    image: docker.io/bitnami/drupal:9
    ports:
      - '80:8080'
      - '443:8443'
    environment:
      # - DRUPAL_PASSWORD=test
      # https://github.com/napoler/bitnami-docker-drupal#user-and-site-configuration
      - DRUPAL_DATABASE_HOST=mariadb
      - DRUPAL_DATABASE_PORT_NUMBER=3306
      - DRUPAL_DATABASE_USER=bn_drupal
      - DRUPAL_DATABASE_NAME=bitnami_drupal
      # ALLOW_EMPTY_PASSWORD is recommended only for development.
      - ALLOW_EMPTY_PASSWORD=yes
    volumes:
      - 'drupal_data:/bitnami/drupal'
    depends_on:
      - mariadb
volumes:
  mariadb_data:
    driver: local
  drupal_data:
    driver: local

$ curl -sSL https://raw.githubusercontent.com/bitnami/bitnami-docker-drupal/master/docker-compose.yml > docker-compose.yml
$ docker-compose up -d
更动配置文件
https://github.com/napoler/bitnami-docker-drupal#user-and-site-configuration

User and Site configuration
  • DRUPAL_PROFILE: Drupal installation profile. Default: standard
  • DRUPAL_SITE_NAME: Drupal blog name. Default: My blog
  • DRUPAL_SKIP_BOOTSTRAP: Whether to skip performing the initial bootstrapping for the application. Default: no
  • DRUPAL_ENABLE_MODULES: Comma or space separated list of installed modules to enable during the first initialization. No defaults.
  • DRUPAL_USERNAME: Drupal application username. Default: user 这里默认用户
  • DRUPAL_PASSWORD: Drupal application password. Default: bitnami 这里是默认用户名
  • DRUPAL_EMAIL: Drupal application email. Default: **[email protected]**
  • DRUPAL_CONFIG_SYNC_DIR: Drupal sync configuration directory location. Only used when DRUPAL_SKIP_BOOTSTRAP is enabled. No defaults.
  • DRUPAL_HASH_SALT: Drupal string used to generate random values. Only used when DRUPAL_SKIP_BOOTSTRAP is enabled. No defaults.
Use an existing database
  • DRUPAL_DATABASE_HOST: Hostname for MariaDB server. Default: mariadb
  • DRUPAL_DATABASE_PORT_NUMBER: Port used by MariaDB server. Default: 3306
  • DRUPAL_DATABASE_NAME: Database name that Drupal will use to connect with the database. Default: bitnami_drupal
  • DRUPAL_DATABASE_USER: Database user that Drupal will use to connect with the database. Default: bn_drupal
  • DRUPAL_DATABASE_PASSWORD: Database password that Drupal will use to connect with the database. No defaults.
  • DRUPAL_DATABASE_TLS_CA_FILE: TLS CA certificate for connections. No defaults.
  • ALLOW_EMPTY_PASSWORD: It can be used to allow blank passwords. Default: no
Create a database for Drupal using mysql-client
  • MYSQL_CLIENT_FLAVOR: SQL database flavor. Valid values: mariadb or mysql. Default: mariadb.
  • MYSQL_CLIENT_DATABASE_HOST: Hostname for MariaDB server. Default: mariadb
  • MYSQL_CLIENT_DATABASE_PORT_NUMBER: Port used by MariaDB server. Default: 3306
  • MYSQL_CLIENT_DATABASE_ROOT_USER: Database admin user. Default: root
  • MYSQL_CLIENT_DATABASE_ROOT_PASSWORD: Database password for the database admin user. No defaults.
  • MYSQL_CLIENT_CREATE_DATABASE_NAME: New database to be created by the mysql client module. No defaults.
  • MYSQL_CLIENT_CREATE_DATABASE_USER: New database user to be created by the mysql client module. No defaults.
  • MYSQL_CLIENT_CREATE_DATABASE_PASSWORD: Database password for the MYSQL_CLIENT_CREATE_DATABASE_USER user. No defaults.
  • MYSQL_CLIENT_CREATE_DATABASE_CHARACTER_SET: Character set to use for the new database. No defaults.
  • MYSQL_CLIENT_CREATE_DATABASE_COLLATE: Database collation to use for the new database. No defaults.
  • MYSQL_CLIENT_CREATE_DATABASE_PRIVILEGES: Database privileges to grant for the user specified in MYSQL_CLIENT_CREATE_DATABASE_USER to the database specified in MYSQL_CLIENT_CREATE_DATABASE_NAME. No defaults.
  • MYSQL_CLIENT_ENABLE_SSL_WRAPPER: Whether to force SSL connections to the database via the mysql CLI tool. Useful for applications that rely on the CLI instead of APIs. Default: no
  • MYSQL_CLIENT_ENABLE_SSL: Whether to force SSL connections for the database. Default: no
  • MYSQL_CLIENT_SSL_CA_FILE: Path to the SSL CA file for the new database. No defaults
  • MYSQL_CLIENT_SSL_CERT_FILE: Path to the SSL CA file for the new database. No defaults
  • MYSQL_CLIENT_SSL_KEY_FILE: Path to the SSL CA file for the new database. No defaults
  • ALLOW_EMPTY_PASSWORD: It can be used to allow blank passwords. Default: no
SMTP Configuration

To configure Drupal to send email using SMTP you can set the following environment variables:

  • DRUPAL_SMTP_HOST: SMTP host.
  • DRUPAL_SMTP_PORT: SMTP port.
  • DRUPAL_SMTP_USER: SMTP account user.
  • DRUPAL_SMTP_PASSWORD: SMTP account password.
  • DRUPAL_SMTP_PROTOCOL: SMTP protocol. (standard, tls, ssl).
PHP configuration
  • PHP_ENABLE_OPCACHE: Enable OPcache for PHP scripts. No default.
  • PHP_EXPOSE_PHP: Enables HTTP header with PHP version. No default.
  • PHP_MAX_EXECUTION_TIME: Maximum execution time for PHP scripts. No default.
  • PHP_MAX_INPUT_TIME: Maximum input time for PHP scripts. No default.
  • PHP_MAX_INPUT_VARS: Maximum amount of input variables for PHP scripts. No default.
  • PHP_MEMORY_LIMIT: Memory limit for PHP scripts. Default: 256M
  • PHP_POST_MAX_SIZE: Maximum size for PHP POST requests. No default.
  • PHP_UPLOAD_MAX_FILESIZE: Maximum file size for PHP uploads. No default.

后期
加入插件开发工具
https://drupalconsole.com/
drush
https://www.specbee.com/blogs/accelerating-drupal-development-with-drupal-console-and-drush