This project is a basic Drupal ContentaCMS / ContentaJS environment stack with ddev.
Tested on Ubuntu, see ddev for more details.
Include default ddev stack for Drupal (Nginx, Php 7.1 fpm, Mariadb, PhpMyAdmin, Mailhog) and extra services:
- Pm2 to run ContentaJS
- Redis (WIP), to connect with ContentaJS
- Portainer for Docker administration
If you are on Ubuntu 16+/Debian, you can try to use the install.sh script included to perform an installation of ContentaCMS, ContentaJS and Contenta React Next.
curl -fSL https://github.com/mogtofu33/contenta-ddev/archive/master.tar.gz -o contenta-ddev.tar.gz
tar -xzf contenta-ddev.tar.gz && mv contenta-ddev-master contenta-ddev
cd contenta-ddev
chmod a+x install.sh
./install.sh
If everything is good go to section Usage.
If it fail you can follow manual steps below.
curl -L https://raw.githubusercontent.com/drud/ddev/master/scripts/install_ddev.sh | bash
curl -fSL https://github.com/mogtofu33/contenta-ddev/archive/master.tar.gz -o contenta-ddev.tar.gz
tar -xzf contenta-ddev.tar.gz && mv contenta-ddev-master contenta-ddev
cd contenta-ddev
curl -fSL https://github.com/contentacms/contentajs/archive/master.tar.gz -o contentajs.tar.gz
tar -xzf contentajs.tar.gz && mv contentajs-master contentajs
Edit contentajs/package.json and replace start with:
"start": "npm run build && PM2_HOME=/home/node/app pm2-runtime start ecosystem.config.js --name contentajs --no-auto-exit",
Edit contentajs/ecosystem.config.js set watch to true for dev and add ignore_watch:
watch: true,
ignore_watch: ["node_modules", "client/img", "logs", "pids", "touch", "pm2.pid", "rpc.sock", "pub.sock"],
Create a local config in contentajs/config/local.yml
cms:
host: http://contenta.ddev.site
got:
applicationCache:
activePlugin: redis
plugins:
redis:
host: redis
port: 6379
prefix: 'contentajs::'
cors:
origin:
# It's OK to use '*' in local development.
- '*'
Prepare contentaCMS folders and init the project
mkdir -p ./contentacms/web/sites/default
ddev config --projecttype drupal8 --projectname contenta --docroot contentacms/web \
--additional-hostnames front-react,contentajs
Copy specific Contenta files from ddev-files in .ddev folder
cp ddev-files/*.yaml .ddev
Note: Nodejs is included in the docker service and used to install ContentaJs, if you want to install the project locally (eg: npm install), edit and switch command line in .ddev/docker-compose.pm2.yaml file. To avoid re-install on each restart you can switch the command after the first launch.
If you have composer locally you can share the cache folder by editing .ddev/docker-compose.overrride.yaml file and set your cache.
ddev start
Install with Composer within ddev
ddev exec composer create-project contentacms/contenta-jsonapi-project /tmp/contentacms \
--stability dev --no-interaction --remove-vcs --no-progress --prefer-dist -v
ddev exec cp -r /tmp/contentacms/ /var/www/html/
ddev exec rm -rf /tmp/contentacms/
Create tmp folder and copy ContentaCMS config to match ddev requirements
mkdir -p contentacms/web/sites/default/files/tmp && mkdir -p contentacms/web/sites/default/files/sync
cp -r contentacms/web/profiles/contrib/contenta_jsonapi/config/sync/ contentacms/web/sites/default/files/
# Ensure settings and permissions by running ddev config again.
ddev config --projecttype drupal8 --projectname contenta --docroot contentacms/web \
--additional-hostnames front-react,contentajs
Install ContentaCMS
ddev exec drush si contenta_jsonapi --account-pass=admin --verbose
Open CORS on ContentaCMS, edit contentacms/web/sites/default/services.yml and replace allowedOrigins
allowedOrigins:
- '*'
Before restarting, ensure ContentaJS is installed by checking if there is a file contentajs/pm2.pid. If not, wait until this file is created. You can check logs with:
ddev logs -s pm2
Note: You can edit and switch command line in .ddev/docker-compose.pm2.yaml file. To avoid re-install on restart.
ddev restart
curl -fSL https://github.com/contentacms/contenta_react_next/archive/master.tar.gz -o contenta_react_next.tar.gz
tar -xzf contenta_react_next.tar.gz && mv contenta_react_next-master/reactjs contenta_react_next
cp ddev-files/docker-compose.react_next.yaml.dis .ddev/docker-compose.react_next.yaml
Note: Yarn is included in the docker service and used to install this project, if you want to install the project locally (yarn install), edit and switch command line in .ddev/docker-compose.react_next.yaml file. To avoid re-install on each restart you can switch the command after the first launch.
Copy the env file and edit the backend url
cp contenta_react_next/.env.default contenta_react_next/.env
BACKEND_URL=http://contentajs.ddev.site:3000
ddev start
For all ddev commands see https://ddev.readthedocs.io/en/latest/users/cli-usage
ContentaCMS Backoffice
ContentaJS
If installed, access the React frontend
Docker web UI, you can access it on port 9000
Redis commander on port 8081
PhpMyAdmin on port 8036
Mailhog on port 8025
Drush with ContentaCMS
ddev exec drush status
ddev exec drush cr
Re-build ContentaJS (see contentajs/package.json for more commands)
ddev exec -s pm2 npm run prepare
Use Composer with ContentaCMS
ddev exec composer --working-dir=/var/www/html/contentacms show -i contentacms/contenta_jsonapi
View logs, ssh in a container...
ContentaJS:
- Redis is not used with got (jsonrpc). Proxy is not using Redis.