Giter Site home page Giter Site logo

contenta-ddev's Introduction

ContentaCMS - ContentaJs with Docker managed by ddev

Build Status

This project is a basic Drupal ContentaCMS / ContentaJS environment stack with ddev.

System Requirements

Tested on Ubuntu, see ddev for more details.

Features

Include default ddev stack for Drupal (Nginx, Php 7.1 fpm, Mariadb, PhpMyAdmin, Mailhog) and extra services:

Quick installation

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.

Manual installation

ddev Installation / Update (Linux example)

curl -L https://raw.githubusercontent.com/drud/ddev/master/scripts/install_ddev.sh | bash

Grab this project as a starting point

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

Download ContentaJs

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.
    - '*'

Init ddev project

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

Download ContentaCMS

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/

Install ContentaCMS

# 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:
      - '*'

Restart for ContentaJS to connect to ContentaCMS

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

(Optionnal) React + Next frontend

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

Usage

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

Daily Usage

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...

Issues

ContentaJS:

  • Redis is not used with got (jsonrpc). Proxy is not using Redis.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.