Commit bd7fac18 authored by Alain Takoudjou's avatar Alain Takoudjou Committed by Alain Takoudjou

drupal: add support for next.js

parent b6a5ce52
Listen {{ parameter_dict['ip'] }}:{{ parameter_dict['node-port'] }}
<VirtualHost *:{{ parameter_dict['node-port'] }}>
ServerAdmin admin@example.com
ServerName example.com
SSLProxyEngine on
SSLProxyCheckPeerCN off
ProxyRequests Off
ProxyPreserveHost on
ProxyPass / http://{{ parameter_dict['node-server'] }}/
ProxyPassReverse / http://{{ parameter_dict['node-server'] }}/
ErrorLog "{{ parameter_dict['log-dir'] }}/nodejs-error.log"
CustomLog "{{ parameter_dict['log-dir'] }}/nodejs-access.log" combined
</VirtualHost>
[template-drupal-instance]
filename = drupal-instance.cfg.in
md5sum = 09a421327c11d4715a61516607c9de85
md5sum = 5b1c36160fdf459019785ef2d002a278
[template-settings.php]
filename = default.settings.php.in
......@@ -9,3 +9,11 @@ md5sum = ef6369e834d774dfaeedc993d70aa98f
[template-settings.local.php]
filename = settings.local.php.in
md5sum = 2692b85c568694c618255095ecea11c5
[template-drupal-apache.conf]
filename = apache.conf.in
md5sum = fa1d986228151256cacab67037ce4bfc
[pathauto.pattern.article.yml]
filename = pathauto.pattern.article.yml
md5sum = 92bea34b59f3493336eb593c8957fdc9
uuid: 45442741-d3b7-4aa6-9a19-35b61af63a15
langcode: fr
status: true
dependencies:
module:
- node
id: article
label: Article
type: 'canonical_entities:node'
pattern: 'blog/[node:title]'
selection_criteria:
c58c9f1d-ff1f-458b-8f26-6d3a3f015289:
id: 'entity_bundle:node'
negate: false
uuid: c58c9f1d-ff1f-458b-8f26-6d3a3f015289
context_mapping:
node: node
bundles:
article: article
selection_logic: and
weight: -5
relationships: { }
[apache-php-configuration]
enable-php8 = !py!True
document-root = ${:default-document-root}/docroot
node-port = 8000
node-server = ${next-server:host}:${next-server:port}
[directory]
node = ${:srv}/node
[template-base]
recipe = slapos.recipe.template:jinja2
......@@ -23,9 +29,28 @@ command-line =
${php-bin:wrapper-path} ${directory:www}/vendor/drush/drush/drush
wrapper-path = ${directory:bin}/drush
[drupal-env]
[composer-bin]
recipe = slapos.cookbook:wrapper
command-line =
${php-bin:wrapper-path} {{ composer_location }}/bin/composer-bin
wrapper-path = ${directory:bin}/composer
[blt-bin]
recipe = slapos.cookbook:wrapper
command-line =
${php-bin:wrapper-path} ${directory:www}/vendor/vendor/bin/blt
wrapper-path = ${directory:bin}/blt
[env-base]
recipe = collective.recipe.template
input = inline:
${:env}
output = ${directory:etc}/.${:env-name}.env
mode = 600
[drupal-env]
<= env-base
env =
export DRUPAL_PROFILE=${instance-parameter:site-profile}
export LOCALE=${instance-parameter:site-locale}
export DB_URL=${mariadb-urlparse:url}
......@@ -34,9 +59,54 @@ input = inline:
export ACCOUNT_NAME="${instance-parameter:account-name}"
export ACCOUNT_MAIL=${instance-parameter:account-mail}
export ACCOUNT_PASS=${drupal-admin-passwd:passwd}
export PATH={{ mariadb_location }}/bin:$PATH
output = ${directory:etc}/.site.env
mode = 600
export PATH={{ mariadb_location }}/bin:${directory:bin}:$PATH
env-name = site
[next-env]
<= env-base
env =
export NEXT_PUBLIC_DRUPAL_BASE_URL=${request-frontend:connection-secure_access}
export NEXT_IMAGE_DOMAIN=${request-frontend:connection-domain}
export DRUPAL_PREVIEW_SECRET=
export DRUPAL_REVALIDATE_SECRET=
export DRUPAL_SITE_ID=
export DRUPAL_FRONT_PAGE=
## Authentication (Bearer)
#export DRUPAL_CLIENT_ID=
#export DRUPAL_CLIENT_SECRET=
#
## Authentication (Basic)
#export DRUPAL_USERNAME=
#export DRUPAL_PASSWORD=
env-name = next
[build-next]
recipe = plone.recipe.command
command = if [ -z "$(ls -A ${directory:node})" ]; then
rm -rf ${directory:node};
cp -ax {{ nextjs_app_location }}/ ${directory:node};
fi
export NEXT_PUBLIC_DRUPAL_BASE_URL=${request-frontend:connection-secure_access}
export NEXT_IMAGE_DOMAIN=${request-frontend:connection-domain}
cd ${directory:node}
{{ nodejs_location }}/bin/npm run build
update-command = ${:command}
stop-on-error = true
# Start next.js server
[next-server]
output = ${directory:services}/next.js-server
recipe = collective.recipe.template
mode = 744
input = inline:#!/bin/sh
. ${next-env:output}
export PATH={{ nodejs_location }}/bin:$PATH
cd ${directory:node}
npx next start -p ${:port} -H ${:host}
port = 3001
# Cannot listen on Ipv6
host = ${apache-network-configuration:listening-ip4}
depends = ${build-next:recipe}
[drupal-site-install]
output = ${directory:scripts}/drupal-install
......@@ -54,7 +124,7 @@ input = inline:#!/bin/sh
if [ ! -s "$CONFIG_FILE" ]; then
cp ${settings.php:output} $CONFIG_FILE
fi
${drush-bin:wrapper-path} site:install $DRUPAL_PROFILE \
drush site:install $DRUPAL_PROFILE \
--locale=$LOCALE \
--db-url=$DB_URL \
--site-name="$SITE_NAME" \
......@@ -65,7 +135,16 @@ input = inline:#!/bin/sh
--verbose --yes
# Rebuild all caches.
${drush-bin:wrapper-path} cache:rebuild
drush cache:rebuild
# install modules Next.js and Next.js JSON:API
drush en next next_jsonapi --verbose --yes
# install drush configs
drush config-import --strict=0 --partial \
--source=${directory:www}/drush/config \
--uri=default --root=${directory:www} \
--verbose --yes
drush cache:rebuild
echo "done" > $INSTALL_FILE
chmod 440 $INSTALL_FILE
......@@ -73,11 +152,33 @@ mode = 744
depends =
${settings.php:recipe}
${settings.local.php:recipe}
${composer-bin:recipe}
${drush-bin:recipe}
${next-server:recipe}
${proxy-apache-httpd:recipe}
[drupal-admin-passwd]
recipe = slapos.cookbook:generate.password
storage-path = ${directory:etc}/.admin_pwd
[proxy-apache-httpd]
recipe = slapos.recipe.template:jinja2
url = {{ template_apache_conf }}
output = ${directory:apache.d}/apache-drupal.conf
context =
section parameter_dict apache-php-configuration
[request-nextjs-frontend]
<= slap-connection
recipe = slapos.cookbook:requestoptional
name = Next.js Frontend
# XXX We have hardcoded SR URL here.
software-url = http://git.erp5.org/gitweb/slapos.git/blob_plain/HEAD:/software/apache-frontend/software.cfg
shared = true
config-url = https://[${apache-php-configuration:ip}]:${apache-php-configuration:node-port}
config-https-only = true
return = domain secure_access
[instance-parameter]
tmp-dir = ${directory:tmp}
trusted-host-list =
......@@ -94,6 +195,7 @@ account-mail = ${slap-parameter:instance.account-mail}
[publish-connection-information]
admin-username = ${instance-parameter:account-name}
admin-password = ${drupal-admin-passwd:passwd}
nextjs-url = ${request-nextjs-frontend:connection-secure_access}
[slap-parameter]
instance.site-profile = standard
......
......@@ -10,9 +10,6 @@ parts +=
composer-setup
install-drupal
[nodejs]
<= nodejs-8.9.4
[apache-php]
<= apache-php8.1
......@@ -30,54 +27,23 @@ part-list = drupal-site-install
db-name = drupal_db
db-user = drupal
[composer]
recipe = slapos.recipe.build:download
url = https://getcomposer.org/installer
filename = composer-setup.php
[composer-php.ini]
# A minimal php.ini that will be used for composer
recipe = collective.recipe.template
input =
inline:[PHP]
engine = On
safe_mode = Off
expose_php = Off
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
display_errors = On
display_startup_errors = Off
log_errors = On
zend_extension=opcache
extension=apcu
extension=redis
extension=imagick
apc.enabled=1
[opcache]
opcache.enable=1
opcache.enable_cli=1
output = ${composer:location}/php.ini
[composer-setup]
[create-next-app]
recipe = plone.recipe.command
location = ${buildout:parts-directory}/nextjs
command =
INSTAL_DIR=${composer:location}/bin
PATH=${apache-php:location}/bin:$PATH
mkdir -p $INSTAL_DIR
php ${composer:location}/composer-setup.php --install-dir=$INSTAL_DIR --filename=composer
mkdir -p ${:location}
cd ${:location}
${nodejs:location}/bin/npm install create-next-app
stop-on-error = true
update-command = ${:command}
[composer-bin]
recipe = collective.recipe.template
input = inline:
#!/bin/sh
export PATH=${apache-php:location}/bin:$PATH
php -c ${composer-php.ini:output} ${composer:location}/bin/composer "$@"
output = ${composer:location}/composer
mode = 755
[next.js-app]
recipe = plone.recipe.command
location = ${create-next-app:location}/app
command =
cd ${create-next-app:location}
${nodejs:location}/bin/npx create-next-app app --use-npm -e ${:project-url}
stop-on-error = true
project-url = https://github.com/chapter-three/next-drupal-basic-starter
# Download drupal composer
[application]
......@@ -89,27 +55,33 @@ branch = master
[install-drupal]
recipe = slapos.recipe.cmmi
path = ${application:location}
configure-command =true
configure-command = true
# ${composer-bin:output} config vendor-dir docroot/vendor
make-targets =
make-options =
make-binary =
${composer-bin:output} install
${composer-bin:output} update
${composer-bin:output} require drupal/next
post-install =
mkdir -p drush/config
cp ${pathauto.pattern.article.yml:target} drush/config/
environment =
COMPOSER_HOME=@@LOCATION@@
PATH=${apache-php:location}/bin:%(PATH)s
[template-drupal-instance]
recipe = slapos.recipe.template:jinja2
url = ${:_profile_base_location_}/${:filename}
output = ${buildout:directory}/instance-drupal.cfg
extensions = jinja2.ext.do
context =
key composer_location composer:location
key php_location apache-php:location
key mariadb_location mariadb:location
key nodejs_location nodejs:location
key nextjs_app_location next.js-app:location
key template_apache_conf template-drupal-apache.conf:target
key template_settings_php template-settings.php:target
key template_settings_local template-settings.local.php:target
......@@ -119,10 +91,9 @@ context =
[template-settings.local.php]
<= drupal-download
[template]
recipe =
context =
[template-drupal-apache.conf]
<= drupal-download
[perl-DBD-mariadb]
recipe =
perl-PATH =
[pathauto.pattern.article.yml]
<= template-download-base
url = ${:_profile_base_location_}/config/${:filename}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment