-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(SLB-397): deploy drupal to platform.sh
- Loading branch information
Showing
10 changed files
with
366 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
'https://cms.{default}/': | ||
type: upstream | ||
upstream: 'cms:http' | ||
cache: | ||
enabled: true | ||
cookies: ['/^SS?ESS/', '/^Drupal.visitor/'] | ||
|
||
'https://build.{default}/': | ||
type: upstream | ||
upstream: 'website:http' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
db: | ||
type: mariadb:10.11 | ||
disk: 2048 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Statements in this file will be executed (sourced) by the shell in SSH | ||
# sessions, in deploy hooks, in cron jobs, and in the application's runtime | ||
# environment. This file must be placed in the root of the application, not | ||
# necessarily the git repository's root. In case of multiple applications, | ||
# each application can have its own .environment file. | ||
|
||
# Allow executable app dependencies from Composer to be run from the path. | ||
if [ -n "$PLATFORM_APP_DIR" -a -f "$PLATFORM_APP_DIR"/composer.json ] ; then | ||
bin=$(composer config bin-dir --working-dir="$PLATFORM_APP_DIR" --no-interaction 2>/dev/null) | ||
export PATH="${PLATFORM_APP_DIR}/${bin:-vendor/bin}:${PATH}" | ||
fi | ||
|
||
# This should be picked up by Platform's NVM. | ||
NODE_VERSION=18 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
name: 'cms' | ||
|
||
type: 'php:8.2' | ||
|
||
dependencies: | ||
php: | ||
composer/composer: '^2.1' | ||
|
||
relationships: | ||
database: 'db:mysql' | ||
|
||
disk: 2048 | ||
|
||
mounts: | ||
'/web/sites/default/files': | ||
source: local | ||
source_path: 'files' | ||
'/.drush': | ||
source: local | ||
source_path: 'drush' | ||
|
||
build: | ||
flavor: none | ||
|
||
hooks: | ||
build: | | ||
set -ex | ||
composer install --no-dev | ||
cd ../.. | ||
pnpm i | ||
pnpm turbo:prep | ||
deploy: | | ||
set -ex | ||
php ./drush/platformsh_generate_drush_yml.php | ||
cd web | ||
drush -y deploy | ||
web: | ||
locations: | ||
'/': | ||
root: 'web' | ||
expires: 5m | ||
passthru: '/index.php' | ||
# Deny access to all static files, except those specifically allowed below. | ||
allow: false | ||
rules: | ||
'\.(avif|webp|jpe?g|png|gif|svgz?|css|js|map|ico|bmp|eot|woff2?|otf|ttf)$': | ||
allow: true | ||
'^/robots\.txt$': | ||
allow: true | ||
'^/sitemap\.xml$': | ||
allow: true | ||
# Deny direct access to configuration files. | ||
'^/sites/sites\.php$': | ||
scripts: false | ||
'^/sites/[^/]+/settings.*?\.php$': | ||
scripts: false | ||
|
||
'/sites/default/files': | ||
allow: true | ||
expires: 5m | ||
passthru: '/index.php' | ||
root: 'web/sites/default/files' | ||
scripts: false | ||
rules: | ||
'^/sites/default/files/(css|js)': | ||
expires: 2w | ||
# AXXX Check if private files need special handling. | ||
|
||
crons: | ||
cms: | ||
spec: '*/15 * * * *' | ||
commands: | ||
start: 'cd web && drush cron' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<?php | ||
/** | ||
* @file | ||
* A script that creates the .drush/drush.yml file. | ||
*/ | ||
|
||
// This file should only be executed as a PHP-CLI script. | ||
if (PHP_SAPI !== 'cli') { | ||
exit; | ||
} | ||
|
||
require_once(__DIR__ . '/../vendor/autoload.php'); | ||
|
||
/** | ||
* Returns a site URL to use with Drush, if possible. | ||
* | ||
* @return string|NULL | ||
*/ | ||
function _platformsh_drush_site_url() { | ||
$platformsh = new \Platformsh\ConfigReader\Config(); | ||
|
||
if (!$platformsh->inRuntime()) { | ||
return; | ||
} | ||
|
||
$routes = $platformsh->getUpstreamRoutes($platformsh->applicationName); | ||
|
||
// Sort URLs, with the primary route first, then by HTTPS before HTTP, then by length. | ||
usort($routes, function (array $a, array $b) { | ||
// false sorts before true, normally, so negate the comparison. | ||
return | ||
[!$a['primary'], strpos($a['url'], 'https://') !== 0, strlen($a['url'])] | ||
<=> | ||
[!$b['primary'], strpos($b['url'], 'https://') !== 0, strlen($b['url'])]; | ||
}); | ||
|
||
// Return the url of the first one. | ||
return reset($routes)['url'] ?: NULL; | ||
} | ||
|
||
$appRoot = dirname(__DIR__); | ||
$filename = $appRoot . '/.drush/drush.yml'; | ||
|
||
$siteUrl = _platformsh_drush_site_url(); | ||
|
||
if (empty($siteUrl)) { | ||
echo "Failed to find a site URL\n"; | ||
|
||
if (file_exists($filename)) { | ||
echo "The file exists but may be invalid: $filename\n"; | ||
} | ||
|
||
exit(1); | ||
} | ||
|
||
$siteUrlYamlEscaped = json_encode($siteUrl, JSON_UNESCAPED_SLASHES); | ||
$scriptPath = __FILE__; | ||
|
||
$success = file_put_contents($filename, <<<EOF | ||
# Drush configuration file. | ||
# This was automatically generated by the script: | ||
# $scriptPath | ||
options: | ||
# Set the default site URL. | ||
uri: $siteUrlYamlEscaped | ||
EOF | ||
); | ||
if (!$success) { | ||
echo "Failed to write file: $filename\n"; | ||
exit(1); | ||
} | ||
|
||
if (!chmod($filename, 0600)) { | ||
echo "Failed to modify file permissions: $filename\n"; | ||
exit(1); | ||
} | ||
|
||
echo "Created Drush configuration file: $filename\n"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.