Deploying implementations using Docker

Deploying implementation updates

If you are looking for information on how to install or update your Gentics Content Management Platform, please refer to the installation or update guide.

Gentics CMS implementation

To deploy new implementations replace the Gentics CMS Devtool packages with your latest version and run the Gentics CMS Devtool synchronisation.

Gentics CMS Devtool sync bash script

This bash script can be used to automate the Gentics CMS Devtool synchronisation on deployment.

usage info for syncPackages.sh
This will sync cms devtool packages from fileystem to CMS.

usage: syncPackages.sh [-c | --cmsuri <gentics cms uri>] [-u | --user <username>] [-p | --password <password>] [-z | --zip <path>] [-H | --header <html header value>]

Example:
       syncPackages.sh --cmsuri http://localhost:80 --user node --password node
OR for interactive mode:
       syncPackages.sh -i
syncPackages.sh
#!/bin/bash

set -o nounset
set -o errexit

packages="reference" (1)
cmsuri=
defaultCmsUri="http://localhost"
user=
defaultUser="node"
password=
defaultPassword="node"
zippath=
header=
interactive=

# print usage hint
function usage() {
  echo "This will sync cms devtool packages from fileystem to CMS."
  echo
  echo "usage: $0 [-c | --cmsuri <gentics cms uri>] [-u | --user <username>] [-p | --password <password>] [-z | --zip <path>] [-H | --header <html header value>]"
  echo
  echo "Example:"
  echo "       $0 --cmsuri http://localhost:80 --user node --password node"
  echo "OR for interactive mode:"
  echo "       $0 -i"

  exit 1
}


# handle params as options
if [[ "$#" -ge 1 ]] ; then
  while [ "$1" != "" ]; do
    case $1 in
      -c | --cmsuri )
        shift
        cmsuri=$1
        ;;
      -u | --user )
        shift
        user=$1
        ;;
      -p | --password )
        shift
        password=$1
        ;;
      -z | --zip )
        shift
        zippath=$1
        ;;
      -H | --header )
        shift
        header=$1
        ;;
      -i | --interactive )
        interactive=1
        break
        ;;
      --help )
        usage
        exit
        ;;
      * )
        usage
        exit 1
    esac
    shift
    if [[ $# -lt 1 ]]; then
      break
    fi
  done
fi

# setup interactive mode
if [ "$interactive" = "1" ]; then

  response=

  echo -n "Enter URL to Gentics CMS [$defaultCmsUri ] > "
  read response
  if [ -n "$response" ]; then
    cmsuri=$response
  else
    cmsuri=$defaultCmsUri
  fi

  echo -n "Enter username [$defaultUser] > "
  read response
  if [ -n "$response" ]; then
    user=$response
  else
    user=$defaultUser
  fi

  echo -n "Enter password [$defaultPassword] > "
  read response
  if [ -n "$response" ]; then
    password=$response
  else
    password=$defaultPassword
  fi

  echo -n "Enter path where a zip file of the packages should be created (optional, not set by default) > "
  read response
  if [ -n "$response" ]; then
    zippath=$response
  fi

  echo -n "Enter additional Header (optional, not set by default) > "
  read response
  if [ -n "$response" ]; then
    header=$response
  fi
fi

# call REST API of Gentics CMS to sync DevToolPackages
function syncPackages () {
  local cmsuri=$1
  local user=$2
  local password=$3
  local zippath=
  local header=
  if [[ -n "${5-}" ]]; then
    header="${5}"
  fi
  if [[ -n "${4-}" ]]; then
    zippath="${4}"
    if ! [ -x "$(command -v zip)" ]; then
      echo 'Command zip not found, creation of packages.zip will be skipped'
    else
      echo 'Creating zip ...'
      # check if this is run on a stage environment
      if [ -d "/cms/packages" ]; then
        zip -r -q "${zippath}" /cms/packages
      else
        # check if we are in local environment
        if [ -d "packages" ]; then
          zip -r -q"${zippath}" packages
        else
          echo 'packages directory not found at "/cms/packages" or "packages" - skipping'
        fi
      fi
    fi
  fi
  echo 'Starting Gentics CMS DevTool packages sync ...'
  local resLogin=$(curl --noproxy "localhost" -vks -c /tmp/cookie-jar -H "${header}" -H "Content-Type: application/json" -X POST -d '{"login" : "'$user'", "password" : "'$password'"}' $cmsuri/rest/auth/login)
  local sid=$(echo $resLogin | sed -e 's/.*sid.*:.*"\(.*\)".*/\1/')

  echo "sid $sid"

  for packagename in $packages
  do
    local resSyncPackage=$(curl --noproxy "localhost" -vks -b /tmp/cookie-jar -H "${header}" -w "%{http_code}" -o /dev/null -X PUT $cmsuri/rest/devtools/packages/$packagename/fs2cms?sid=$sid)
    echo "response for syncing package '$packagename': $resSyncPackage"

    if [ "$resSyncPackage" != "200" ] && [ "$resSyncPackage" != "409" ]; then
      echo
      echo "Failed to set sync status - try this manually in CMS and debug"
      echo "check /cms/logs/devtools.log for more info"
      exit 1
    else
      echo
      echo 'DONE syncing Gentics CMS DevTool packages'
    fi
  done

  exit
}

if [[ -n "$cmsuri" ]] && [[ -n "$user" ]] && [[ -n "$password" ]] && [[ -n "$zippath" ]] && [[ -n "$header" ]] ; then
  # use quotes for $header, as this may contain spaces
  syncPackages $cmsuri $user $password $zippath "$header"
fi
if [[ -n "$cmsuri" ]] && [[ -n "$user" ]] && [[ -n "$password" ]] && [[ -n "$header" ]] ; then
  # use quotes for $header, as this may contain spaces
  syncPackages $cmsuri $user $password 0 "$header"
fi
if [[ -n "$cmsuri" ]] && [[ -n "$user" ]] && [[ -n "$password" ]] && [[ -n "$zippath" ]] ; then
  syncPackages $cmsuri $user $password $zippath
fi
if [[ -n "$cmsuri" ]] && [[ -n "$user" ]] && [[ -n "$password" ]] ; then
  syncPackages $cmsuri $user $password
fi
usage
1 change this to your package name, this can also be a space seperated list of package names

Gentics Portal implementation

For your portal implementation there are two types of changes to consider:

  1. Changes in the configuration and template files

    Changes in configuration and template files can be done directly on the filesystem, e.g. via cp or rsync. Consult your docker-compose.yml file to find out where those files are located.

  2. Changes in the portal application

    To speed up deployment we recommend using prebuilt docker images. Please contact your Gentics technical customer consultant for details on how this is best done in your project.