Only helpful and interesting posts

Alfresco Docker SDK

Sergey Palyukh
21. Dec ‘18

blog-docker-alfresco-sdk.jpg

Since Alfresco released with Dockerized deployment old Alfresco SDK became inconvenient for fast development. Also it was not supposed to release new tool for developers from Alfresco team side. That is why our team focused to create new SDK that can support hot deploy to docker containers.

And I am glad to present you our work.

Main things you can do with new SDK:

  • develop on linux and windows
  • hot reload Java classes
  • hot reload resources (webscripts as well as browser js,css)
  • override default resources if it is necessary
  • read logs from docker containers
  • get ready to deploy AMP file (Repository and Share apps)

How to start

To create new project use Maven. At first place archetype-catalog.xml to your local maven repository {MAVEN_HOME}/repository (all about this file is described here) so that you can use FlexSolution Maven repository:

<?xml version="1.0" encoding="UTF-8"?>
<archetype-catalog
       xsi:schemaLocation="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-catalog/1.0.0 http://maven.apache.org/xsd/archetype-catalog-1.0.0.xsd"
       xmlns="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-catalog/1.0.0"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <archetypes>
       <archetype>
           <groupId>com.flexsolution</groupId>
           <artifactId>alfresco-docker-sdk-archetype</artifactId>
           <version>LATEST</version>
           <repository>http://flex-solution.com:16080/artifactory/public</repository>
       </archetype>
   </archetypes>
</archetype-catalog>

After that you can generate new project using this archetype

mvn archetype:generate -Dfilter=com.flexsolution:

Structure overview

Project configuration files:

  • linux and windows folders contain system dependent start/stop scripts and docker-compose executable directly
  • docker-compose.yml here is all alfresco docker images configuration
  • logs.txt this file holds logs from all docker containers started by this build

Alfresco Repository:

  • src/main/java java classes mapped to /WEB-INF/classes
  • src/main/resources other resources mapped to /WEB-INF/classes
  • target/lib maven dependencies mapped to /WEB-INF/lib

Alfresco Share:

  • src/main/java java classes mapped to /WEB-INF/classes
  • src/main/resources other resources mapped to /WEB-INF/classes
  • src/main/resources/web browser resources mapped to /
  • target/lib maven dependencies mapped to /WEB-INF/lib

How to launch project

The main condition to make build work is to have Docker installed

Use start.sh or start.bat script to launch docker containers

Applications are accessible by following URLs:

  • Repository url http://localhost:8082/alfresco
  • Share url http://localhost:8080/share

You can debug java code using remote dubugger:

  • Repository debug port is 5005
  • Share debug port is 5006

For example launch command for linux environment can look like this:

_docker/linux/start.sh && tail -f _docker/logs.txt

Also you can configure project to use with IDE. I will show on Intelij Idea example

Use Remote configuration

Add new before launch configuration

Point at start script as executable program

Pipe logs to IDE

How does it work

Docker uses volumes that are mapped to project directory of host system.
It allows to reload files immediately into tomcat that is inside docker container. Static resources do not require project rebuilding at all. Webscripts and java classes require project rebuild (Ctrl + F9 in Idea). So you no need to deploy code manually to docker containers.

If you have any questions, some potential project, the idea of a startup or you just need some consultations, then don't hesitate to contact us. We would be happy to help.