From 9ca4136a45ab026062867afbb38f5fbd8ba8aacf Mon Sep 17 00:00:00 2001 From: Simon Lindsay Date: Thu, 13 Jun 2019 14:55:30 +0930 Subject: [PATCH 1/5] Don't use mac style networking on linux. (#63) --- docker-compose.linux.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docker-compose.linux.yml b/docker-compose.linux.yml index b14e578..42fd0b6 100644 --- a/docker-compose.linux.yml +++ b/docker-compose.linux.yml @@ -89,6 +89,7 @@ services: selenium: image: selenium/standalone-chrome:3.141.59-oxygen - network_mode: host volumes: - /dev/shm:/dev/shm + networks: + - default From 814edaeb3237cb3c80dffd1fb5a74b00ac26d11d Mon Sep 17 00:00:00 2001 From: Michael Priest Date: Mon, 17 Jun 2019 10:02:37 +0930 Subject: [PATCH 2/5] docker-compose pull must ignore errors for local images and rebuild dev image to account for base image update. (#64) --- dsh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dsh b/dsh index f43e6c5..7ec87ef 100755 --- a/dsh +++ b/dsh @@ -105,7 +105,8 @@ dsh_project() { # Command: ./dsh pull # Fetches all images used by the project. dsh_pull() { - docker-compose -f ${DOCKER_COMPOSE_FILE} pull + docker-compose -f ${DOCKER_COMPOSE_FILE} pull --ignore-pull-failures + docker-compose -f ${DOCKER_COMPOSE_FILE} build } # Command: ./dsh nfs From c3e437028a34f88e012b8c8c1c2e72fa28847472 Mon Sep 17 00:00:00 2001 From: Simon Lindsay Date: Mon, 17 Jun 2019 10:29:03 +0930 Subject: [PATCH 3/5] Add support for supplying redis password via file(secrets) and env var. --- src/Handler.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Handler.php b/src/Handler.php index 2f8e043..9e22730 100644 --- a/src/Handler.php +++ b/src/Handler.php @@ -180,6 +180,9 @@ public function generateSettings() " \$settings['cache']['default'] = 'cache.backend.redis';\n\n" . " \$settings['container_yamls'][] = 'modules/contrib/redis/example.services.yml';\n" . " }\n" . + " if (getenv('REDIS_PASSWORD_FILE') || getenv('REDIS_PASSWORD')) {\n" . + " \$settings['redis.connection']['password'] = getenv('REDIS_PASSWORD_FILE') ? file_get_contents(getenv('REDIS_PASSWORD_FILE')) : getenv('REDIS_PASSWORD');\n" . + " }\n" . "}\n" . "if (getenv('MEMCACHE_ENABLED')) {\n" . " \$settings['memcache']['servers'] = [getenv('MEMCACHE_HOST') . ':11211' => 'default'] ?: ['127.0.0.1:11211' => 'default'];\n" . From 680b7ef0050c0f74351bc70526f83a75d7bdd63b Mon Sep 17 00:00:00 2001 From: Simon Lindsay Date: Mon, 17 Jun 2019 11:14:43 +0930 Subject: [PATCH 4/5] Add sample config to docker-compose files. --- docker-compose.linux.yml | 7 +++++++ docker-compose.osx.yml | 9 ++++++++- src/Handler.php | 2 +- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/docker-compose.linux.yml b/docker-compose.linux.yml index 42fd0b6..17f4a65 100644 --- a/docker-compose.linux.yml +++ b/docker-compose.linux.yml @@ -25,6 +25,7 @@ services: PUBLIC_DIR: /shared/public REDIS_ENABLED: 1 REDIS_HOST: redis + # REDIS_PASSWORD: testing SHEPHERD_SITE_ID: 2 SHEPHERD_INSTALL_PROFILE: ua SHEPHERD_SECRET_PATH: /code/private @@ -66,6 +67,12 @@ services: redis: image: redis:alpine + command: | + redis-server + --maxmemory 512Mi + --maxmemory-policy allkeys-lru + --save "" + # --requirepass password networks: - default diff --git a/docker-compose.osx.yml b/docker-compose.osx.yml index c0a27cd..0b5a3c0 100644 --- a/docker-compose.osx.yml +++ b/docker-compose.osx.yml @@ -21,8 +21,10 @@ services: CONFIG_SYNC_DIRECTORY: /shared/private/random-hash/sync HASH_SALT: random-hash MEMCACHE_ENABLED: 0 + PHP_IDE_CONFIG: serverName=localhost PUBLIC_DIR: /shared/public REDIS_ENABLED: 1 + # REDIS_PASSWORD: testing SHEPHERD_INSTALL_PROFILE: ua SHEPHERD_SITE_ID: 2 SHEPHERD_SECRET_PATH: /code/private @@ -33,7 +35,6 @@ services: SITE_ADMIN_EMAIL: admin@example.com SITE_ADMIN_USERNAME: admin SITE_ADMIN_PASSWORD: password - PHP_IDE_CONFIG: serverName=localhost XDEBUG_CONFIG: "remote_host=docker.for.mac.localhost" volumes: - nfsmount:/code @@ -61,6 +62,12 @@ services: redis: image: redis:alpine + command: | + redis-server + --maxmemory 512Mi + --maxmemory-policy allkeys-lru + --save "" + # --requirepass password network_mode: service:web memcached: diff --git a/src/Handler.php b/src/Handler.php index 9e22730..3edc319 100644 --- a/src/Handler.php +++ b/src/Handler.php @@ -177,7 +177,7 @@ public function generateSettings() " \$settings['cache_prefix']['default'] = getenv('REDIS_PREFIX') ?: '';\n" . " // If we're not installing, include the redis services.\n" . " if (!isset(\$GLOBALS['install_state'])) {\n" . - " \$settings['cache']['default'] = 'cache.backend.redis';\n\n" . + " \$settings['cache']['default'] = 'cache.backend.redis';\n" . " \$settings['container_yamls'][] = 'modules/contrib/redis/example.services.yml';\n" . " }\n" . " if (getenv('REDIS_PASSWORD_FILE') || getenv('REDIS_PASSWORD')) {\n" . From 55bc569499c893a8e2c44da8e896cf5f913667e3 Mon Sep 17 00:00:00 2001 From: Michael Priest Date: Mon, 17 Jun 2019 11:29:07 +0930 Subject: [PATCH 5/5] Remove CONFIG_SYNC_DIRECTORY variable entirely - config will always be in this location. (#65) --- RoboFileBase.php | 15 --------------- docker-compose.linux.yml | 1 - docker-compose.osx.yml | 1 - src/Handler.php | 2 +- 4 files changed, 1 insertion(+), 18 deletions(-) diff --git a/RoboFileBase.php b/RoboFileBase.php index e3c6ae4..6732ca2 100644 --- a/RoboFileBase.php +++ b/RoboFileBase.php @@ -129,7 +129,6 @@ protected function readConfigFromEnv() { // Environment. $config['environment']['hash_salt'] = getenv('HASH_SALT'); - $config['environment']['config_sync_dir'] = getenv('CONFIG_SYNC_DIRECTORY'); // Clean up NULL values and empty arrays. $array_clean = function (&$item) use (&$array_clean) { @@ -155,7 +154,6 @@ public function build() { $start = new DateTime(); $this->devComposerValidate(); $this->buildMake(); - $this->buildCreateConfigSyncDir(); $this->buildSetFilesOwner(); $this->buildInstall(); $this->configImportPlus(); @@ -197,19 +195,6 @@ public function buildMake($flags = '') { $this->checkFail($successful, "Composer install failed."); } - /** - * Create the config sync directory from config. - * - * Drupal will write a .htaccess afterwards in there. - */ - public function buildCreateConfigSyncDir() { - if (isset($this->config['environment']['config_sync_dir'])) { - // Only do this if we have a config sync dir setting available. - $this->say("Creating config sync directory."); - $this->_exec("$this->sudo_cmd mkdir -p " . $this->config['environment']['config_sync_dir']); - } - } - /** * Set the owner and group of all files in the files dir to the web user. */ diff --git a/docker-compose.linux.yml b/docker-compose.linux.yml index 42fd0b6..9160cc2 100644 --- a/docker-compose.linux.yml +++ b/docker-compose.linux.yml @@ -14,7 +14,6 @@ services: ports: - "80:8080" environment: - CONFIG_SYNC_DIRECTORY: /shared/private/random-hash/sync DATABASE_HOST: db DATABASE_USER: user DATABASE_PASSWORD: password diff --git a/docker-compose.osx.yml b/docker-compose.osx.yml index c0a27cd..3eac82d 100644 --- a/docker-compose.osx.yml +++ b/docker-compose.osx.yml @@ -18,7 +18,6 @@ services: - "9990:9990" - "11211:11211" environment: - CONFIG_SYNC_DIRECTORY: /shared/private/random-hash/sync HASH_SALT: random-hash MEMCACHE_ENABLED: 0 PUBLIC_DIR: /shared/public diff --git a/src/Handler.php b/src/Handler.php index 2f8e043..8d9099b 100644 --- a/src/Handler.php +++ b/src/Handler.php @@ -162,7 +162,7 @@ public function generateSettings() "\$settings['file_private_path'] = getenv('PRIVATE_DIR') ?: '/shared/private';\n" . "\$settings['file_temporary_path'] = getenv('TMP_DIR') ?: '/shared/tmp';\n" . "\$settings['hash_salt'] = getenv('HASH_SALT') ?: '" . str_replace(['+', '/', '='], ['-', '_', ''], base64_encode(random_bytes(55))) . "';\n" . - "\$config_directories['sync'] = getenv('CONFIG_SYNC_DIRECTORY') ?: DRUPAL_ROOT . '/../config-export';\n" . + "\$config_directories['sync'] = DRUPAL_ROOT . '/../config-export';\n" . "\$settings['shepherd_site_id'] = getenv('SHEPHERD_SITE_ID');\n" . "\$settings['shepherd_url'] = getenv('SHEPHERD_URL');\n" . "\$settings['shepherd_token'] = getenv('SHEPHERD_TOKEN_FILE') ? file_get_contents(getenv('SHEPHERD_TOKEN_FILE')) : getenv('SHEPHERD_TOKEN');\n\n" .