Mar 8, 2018 3:32:27 PM seb leridon avatar   1195

Deployment on CloudBees


CloudBees Logo

Deploy two LUTECE environments step by step on the CloudBees platform: one for the development version of the site, the other for the production version.

Then manage the automated deployment based on component updates.

Here are the different steps of this tutorial:

Interest of CloudBees


The interests of this platform are:

  • This is a Platform as a Service (PaaS) that provides all the runtime elements for Java Webapps: JEE server: Tomcat, JBoss, ... Database: MySQL, ...
    • So there is no technical base to install, just provide a Webapp
  • The CloudBees platform integrates a continuous integration environment based on: version control repositories GIT or SVN Jenkins integration driver
    • Lutece build and build mechanisms can be used directly in CloudBees

Prerequisites


Creating the Cloudbees account


Registration is free and does not require the registration of a bank card.

Create your account at the following address: https://www.cloudbees.com/signup

Note: The selected Domain / Account name will appear in the application access URL. https://app_name.account_name.cloudbees.net

Creating code repository based on a GIT repository


This repository will contain:

  • the pom.xml file allowing the construction of the site,
  • the files which will overload at the time of the assembly the files of the construction by default (ex: graphic load, files of configuration, ...)

Creating the GIT repository

Click on the " Repositories " menu in the main menu (banner).

In the Code Repositories section, click the " Create new code repository " button.

Connecting to the GIT repository

To connect, it is necessary to have a pair of keys (public / private) SSH as indicated in the prerequisites above. Indeed, the access to the repository GIT created supposes that you have registered your public key at the level of the plate CloudBees.

To do this, click on "Account" (in the banner on the right of your login), then on "Security Keys". You are then asked to enter your SSH public key.

Then test the connection to GIT with the following command:

$ ssh git@git.cloudbees.com echo

Creation of the local project under GIT

Go to the tree of your local file system where you want to create the root directory of your GIT-versioned project (mysite directory for our example) and launch the command to clone the repository locally: git clone ssh: git@git.cloudbees.com/lutece/mysite.git

Then test by making a first commit and push to the server.

cd mysite
echo 'Repository mysite'> README
git add README
git commit -m 'Initial checkin'
git push origin master

Creation of the database


Click on the " DBs " menu of the main menu (banner).

In the Database section on the left, click on the "Add new database" button.

Then enter the information about the development database to get started.

Once the database has been created, you will obtain information allowing you to configure its access (server, port, ...).

Repeat this operation to create the production database.

Creation of project files


Your project should contain at least the following files:

  • The pom.xml file used by Maven to build the site
  • db.properties files corresponding to our two DEV and PROD databases

The root directory of the project must contain two subdirectories: src and webapp

You can add other files in the webapp directory that will override or supplement those that will be assembled during the build.

Classically overloaded files usually concern the graphic charter (eg: footer.html, page_frameset.html, icon.png, ...)

The pom.xml file

This file has the following characteristics:

  • it must derive from the project file for Lutece sites: lutece-site-pom
  • it must contain the addresses of the repositories maven of Lutece: stable versions and / or snapshots according to the wish.
  • he must declare in the dependencies all the plugins and modules to be included in the site.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/maven-v4_0_0.xsd">

    <modelVersion>4.0.0</modelVersion>
    <groupId>fr.paris.lutece</groupId>
    <artifactId>mysite</artifactId>
    <packaging>lutece-site</packaging>
    <name>My Site</name>
    <version>1.0.0-SNAPSHOT</version>


    <!-- This project should inherit from lutece-site-pom -->
    <parent>
        <artifactId>lutece-site-pom</artifactId>
        <groupId>fr.paris.lutece.tools</groupId>
        <version>2.0.2</version>
    </parent>


    <!-- Repositories -->
    <repositories>
        <repository>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
            <id>luteceSnapshot</id>
            <name>luteceSnapshot</name>
            <url>http://dev.lutece.paris.fr/snapshot_repository</url>
        </repository>
        <repository>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
            <id>lutece</id>
            <name>luteceRepository</name>
            <url>http://dev.lutece.paris.fr/maven_repository</url>
        </repository>
    </repositories>
    <dependencies>


        <!-- Lutece core -->
        <dependency>
            <groupId>fr.paris.lutece</groupId>
            <artifactId>lutece-core</artifactId>
            <version>[4.1.0-SNAPSHOT,5.0.0-SNAPSHOT)</version>
            <type>lutece-core</type>
        </dependency>


        <!-- Plugins of my site -->

        <!-- Contact -->
        <dependency>
            <groupId>fr.paris.lutece.plugins</groupId>
            <artifactId>plugin-contact</artifactId>
            <version>[2.1.2,6.0.0-SNAPSHOT)</version>
            <type>lutece-plugin</type>
        </dependency>

        ...


        <!-- Wiki -->
        <dependency>
            <groupId>fr.paris.lutece.plugins</groupId>
            <artifactId>plugin-wiki</artifactId>
            <version>[0.9.0,4.0.0-SNAPSHOT)</version>
            <type>lutece-plugin</type>
        </dependency>
        <dependency>
            <groupId>fr.paris.lutece.plugins</groupId>
            <artifactId>module-seo-wiki</artifactId>
            <version>[0.9.0,4.0.0-SNAPSHOT)</version>
            <type>lutece-plugin</type>
        </dependency>


    </dependencies>
</project>

The configuration files of the database

These files must be in the following directories:

  • /webapp/src/conf/dev/WEB-INF/conf/db.properties
  • /webapp/src/conf/prod/WEB-INF/conf/db.properties

Here is the content for example of the file that will allow access to the development database:

################################################################################
# Configuration file for Lutece to parameterize connections pools to databases
################################################################################

portal.poolservice=fr.paris.lutece.util.pool.service.LuteceConnectionService
portal.driver=org.gjt.mm.mysql.Driver
portal.url=jdbc:mysql://ec2-50-19-213-178.compute-1.amazonaws.com/mydatabase-dev?autoReconnect=true&useUnicode=yes&characterEncoding=utf8
portal.user=myuser-dev
portal.password=<my password>
portal.initconns=2
portal.maxconns=50
portal.logintimeout=2
portal.checkvalidconnectionsql=SELECT 1

Initialization of databases


The easiest way to initialize the databases is to build the two webapps locally and play the creation scripts.

The db.properties files must be correctly configured beforehand to access the remote databases (hosted at Amazon at the time of writing the tutorial)

Remote database access can be a problem if you are behind a proxy that does not allow you to use port 3306.

To build the dev webapp locally and start the initialization of its remote database, here are the commands

mvn clean lutece:site-assembly -P dev
cd target / mysite-1.0.0-SNAPSHOT / WEB-INF / sql
ant

For the production base, replace dev by prod in the first command.

Update project files on GIT


Once all the project files are ready, you have to push them into the GIT repository branch.

For that, the three commands to execute:

git add <files>
git commit -m "Project files added"
git push origin master

Creating instances of applications


Click on the "Apps" menu of the main menu (banner).

In the Database section on the left, click on the "Add new application" button.

Then enter the name of the application (mysite-dev and mysite for the example) in the form below:

Creating Continuous Integration Jobs


Click on the " Builds " menu of the main menu (banner).

Enable the provision of a Jenkins Continuous Integration Platform.

Once the platform is available, click on " Create Job "

You must then give a name: " Deploy DEV ", select the type of Job: " Free-Style project " and validate.

Warning ! Do not choose " Build Maven 2/3 project " which now requires to create an artifact to deploy the war in RUN @ Cloud

You will then have to enter the detailed configuration of the Job.

The only information to enter is:

  • The repository type: GIT and the URL of this one: ssh: git@git.cloudbees.com/lutece/mysite.git
  • In the Build section, Run a shell script - command: mvn clean lutece:site-assembly -Pdev -DfinalName = mysite-dev
  • The actions following the build for which we will choose Deploy Host service CloudBees RUN @ cloud service mysite-dev

The second job to be defined for production, " Deploy PROD ", can be created by cloning the previous one.

The only differences are:

  • The goals and options in the Build section: clean lutece:site-assembly -Pprod -DfinalName = mysite-prod
  • The actions following the build for which we will choose Deploy Host service CloudBees RUN @ cloud service mysite

In addition, you must uncheck the automatic launch option of the Job whenever you make a change in the GIT repository. This Job is to be launched manually when the changes have been validated on the development platform.

Here is the view of the Jenkins dashboard, after creating and launching jobs:

Jenkins jobs

Deployment of instances


In the proposed configuration, any changes to GIT will automatically launch a full build of the webapp and its deployment on the development instance at the URL http://mysite-dev.myaccount.cloudbees.net

If the tests are satisfactory, the launch of the Job "Deploy PROD" can be done manually from the dashboard of Jenkins.

If all goes well you should get your Lutece instance at the URL http://mysite.myaccount.cloudbees.net.

Setting up the mail service


Enable the "SendGrid Mail Server" service for your account from the Apps interface.

Click Alert Settings (http://sendgrid.com/alerts) to set the notification email address of the service.

Initialize your password: https://sendgrid.com/user/forgotPassword

Click Developer (http://sendgrid.com/developer) to view the configuration settings.

Add, in the WEB-INF / conf / override / directory of your deployment profile on CloudBees or in your webapp, a config.properties file with the following elements configured:

config.properties
################################################## ##############################
# Mail sending parameters (ip address of the mail server)
# username and password if authentication needed - empty otherwise
mail.server = smtp.sendgrid.net
mail.username = [Your SendGrid account]
mail.password = [Your SendGrid password]
mail.list.separator =;
mail.type.plain = text / plain; charset =
mail.type.html = text / html; charset =
mail.noreply.email = [your reply email]

Release note The authentication mode requested by SendGrid is supported only as of version 4.1.0 of Lutece.