Commit d8bfc694 authored by jnaud's avatar jnaud
Browse files

Add cicd with 3.4.1

parent 75039ecb
/target
/source
\ No newline at end of file
/source
/.metadata
/.settings
/.classpath
/.project
/jenkins_release
\ No newline at end of file
# Geosource
## Download dependency
```bash
mkdir source
cd source
wget -O geonetwork-3.8.3-0.war https://sourceforge.net/projects/geonetwork/files/GeoNetwork_opensource/v3.8.3/geonetwork.war/download
wget -O geonetwork-3.4.1-0.war https://sourceforge.net/projects/geonetwork/files/GeoNetwork_opensource/v3.4.1/geonetwork.war/download
cd ..
```
## Build geosource war in local maven repository
# install geosource war in local maven repository
#./mvnw install:install-file -DgroupId=org.geonetwork-opensource -DartifactId=geosource -Dversion=3.0.1-0 -Dpackaging=war -Dfile=./source/geosource-3.0.1-0.war
./mvnw install:install-file -DgroupId=org.geonetwork-opensource -DartifactId=geonetwork -Dversion=3.8.3-0 -Dpackaging=war -Dfile=./source/geonetwork-3.8.3-0.war && ./mvnw clean package
# build war overlay
./mvnw clean package
\ No newline at end of file
```bash
./mvnw install:install-file -DgroupId=org.geonetwork-opensource -DartifactId=geonetwork -Dversion=3.4.1-0 -Dpackaging=war -Dfile=./source/geonetwork-3.4.1-0.war && ./mvnw clean package
```
\ No newline at end of file
pipeline {
agent any
options { disableConcurrentBuilds() }
stages {
stage('Fetch dependencies') {
agent any
steps {
sh 'cicd/build/0_fetch-dependencies.sh'
stash includes: 'node_modules/', name: 'node_modules'
}
}
stage('Build war') {
agent any
steps {
sh 'cicd/build/1_build_war.sh'
stash includes: 'target/', name: 'target'
}
}
stage('Make docker') {
agent any
steps {
unstash 'jenkins_release'
sh 'cicd/build/6_make_docker.sh'
stash includes: 'jenkins_release/', name: 'jenkins_release'
}
}
}
post {
success {
unstash 'jenkins_release'
archiveArtifacts artifacts: 'jenkins_release/*.tar.gz', onlyIfSuccessful: true
archiveArtifacts artifacts: 'jenkins_release/*.docker', onlyIfSuccessful: true
}
always {
sh 'cicd/build/99_clean.sh'
}
}
}
#!/bin/sh
set -e
# Source env file
SCRIPT=`readlink -f $0`
SCRIPTDIR=`dirname $SCRIPT`
SCRIPTNAME=`basename $SCRIPT`
ROOTDIR="$SCRIPTDIR/../.."
. $SCRIPTDIR/env.sh
mkdir -p $ROOTDIR/source
if [ ! -f $ROOTDIR/source/geonetwork-3.4.1-0.war ]; then
cd $ROOTDIR/source
wget -O geonetwork-3.4.1-0.war https://sourceforge.net/projects/geonetwork/files/GeoNetwork_opensource/v3.4.1/geonetwork.war/download
fi;
\ No newline at end of file
#!/bin/sh
set -e
# Source env file
SCRIPT=`readlink -f $0`
SCRIPTDIR=`dirname $SCRIPT`
SCRIPTNAME=`basename $SCRIPT`
ROOTDIR="$SCRIPTDIR/../.."
. $SCRIPTDIR/env.sh
cd $ROOTDIR
# Build war
docker run -u root -w "/usr/local/tomcat/build" --volume "$ROOTDIR:/usr/local/tomcat/build" tomcat:8-jdk8 ./mvnw install:install-file -DgroupId=org.geonetwork-opensource -DartifactId=geonetwork -Dversion=3.4.1-0 -Dpackaging=war -Dfile=./source/geonetwork-3.4.1-0.war && ./mvnw clean package
#!/bin/sh
set -e
# Source env file
SCRIPT=`readlink -f $0`
SCRIPTDIR=`dirname $SCRIPT`
SCRIPTNAME=`basename $SCRIPT`
ROOTDIR="$SCRIPTDIR/../.."
COMMIT=`git rev-parse --short=8 HEAD`
DATE="`date '+%Y%m%dT%H%M'`"
. $SCRIPTDIR/env.sh
# Build docker
cd $ROOTDIR
docker build -t ${PROJECT_NAME}_web:${COMMIT} -f $ROOTDIR/cicd/build/docker-prod/web/Dockerfile .
# Tag to latest
docker tag ${PROJECT_NAME}_web:${COMMIT} ${PROJECT_NAME}_web
# Remove previous docker if exist
mkdir -p $ROOTDIR/jenkins_release
files=`find $ROOTDIR/jenkins_release -type f -name "*.docker" -print`
if [ "${files}" ]; then
rm $ROOTDIR/jenkins_release/*.docker
fi
# Save image
docker save ${PROJECT_NAME}_web:${COMMIT} | gzip > $ROOTDIR/jenkins_release/${PROJECT_NAME}_web_${COMMIT}_${DATE}.docker
#!/bin/sh
set -e
# Source env file
SCRIPT=`readlink -f $0`
SCRIPTDIR=`dirname $SCRIPT`
SCRIPTNAME=`basename $SCRIPT`
. $SCRIPTDIR/env.sh
echo " Start 99_clean.sh"
if [ "$(docker ps -aq -f name=${DOCKER_NAME}_web)" ]; then
echo " Clean container docker prod"
docker rm -f ${DOCKER_NAME}_web
fi
if [ "$(docker images -q -f reference=${DOCKER_NAME}_web)" ]; then
echo " Clean images docker build"
docker rmi -f $(docker images -q -f reference=${DOCKER_NAME}_web | tail -n 1)
fi
if [ "$(docker images -q -f reference=${DOCKER_NAME}_dev_web)" ]; then
echo " Clean images docker prod"
docker rmi -f $(docker images -q -f reference=${DOCKER_NAME}_dev_web | tail -n 1)
fi
echo " End 99_clean.sh"
FROM tomcat:8-jdk8
## Not delpoy the geosource-overlay-3.4.1-0.war but the unziped one in docker
COPY --chown=root:root ./target/geosource-overlay-3.4.1-0 /usr/local/tomcat/webapps/geonetwork
#COPY --chown=root:root ./etc/geosource-overlay-3.4.1-0 /etc/geosource-overlay-3.4.1-0
\ No newline at end of file
#!/bin/bash
PROJECT_NAME="jpr_prodige_geonetwork"
DOCKER_NAME="${PROJECT_NAME}_build"
# README
<!-- TOC -->
- [README](#readme)
- [Overview](#overview)
- [Start developpement](#start-developpement)
- [Download dependency](#download-dependency)
- [Compile the war file](#compile-the-war-file)
- [Deploy war](#deploy-war)
- [Stop developpement](#stop-developpement)
- [General Docker commands](#general-docker-commands)
- [Advanced Docker commands](#advanced-docker-commands)
- [Clean commands](#clean-commands)
- [Monitoring commands](#monitoring-commands)
<!-- /TOC -->
## Overview
This file give commands to start development with docker.
Require:
- Docker installed.
- Docker well configured, cf. **/etc/docker/deamon.json**
- User in docker group to avoid sudo/su right
## Start developpement
### Download dependency
Go to the root of this project and download geonetwork.war
```bash
mkdir -p source
cd source
wget -O geonetwork-3.4.1-0.war https://sourceforge.net/projects/geonetwork/files/GeoNetwork_opensource/v3.4.1/geonetwork.war/download
cd ..
```
### Compile the war file
Make these commands in the root directory of this project:
```bash
docker run -u root -w "/usr/local/tomcat/build" --volume "${PWD}:/usr/local/tomcat/build" tomcat:8-jdk8 ./mvnw install:install-file -DgroupId=org.geonetwork-opensource -DartifactId=geonetwork -Dversion=3.4.1-0 -Dpackaging=war -Dfile=./source/geonetwork-3.4.1-0.war && ./mvnw clean package
```
### Deploy war
Make these commands in this directory the ```cd ./cicd/dev```
Run container
```bash
# Build dev image
docker-compose build
# Run containers
docker-compose up
```
The url web are: http://localhost:8080/geonetwork
## Stop developpement
Make these commands in this directory ```cd ./cicd/dev```.
```bash
# Shutdown containers
docker-compose down
# Remove dev image
docker rmi jpr_prodige_geonetwork_dev_web
```
## General Docker commands
| Description | Commandes |
|- |- |
| Display images | ```docker images``` |
| Remove image | ```docker rmi myimages``` |
|- |- |
| Display all running containers | ```docker ps``` |
| Display all containers | ```docker ps -a``` |
| Remove container | ```docker rm mycontainer``` |
| Display info container | ```docker inpect mycontainer``` |
| Display container ouput | ```docker logs mycontainer``` |
| Stop container | ```docker stop mycontainer``` |
| Kill container | ```docker kill mycontainer``` |
|- |- |
| Connection as root | ```docker exec --user 0 -w / -it jpr_prodige_geonetwork_dev_web bash``` |
| Connection as www-data | ```docker exec --user www-data -w /var/www/html -it jpr_prodige_geonetwork_dev_web bash``` |
| Connection as postgres | ```docker exec --user postgres -it tpl_alkante_symfony_3_dev_db bash``` |
| Run composer install | ```docker exec --user www-data -w /var/www/html -it jpr_prodige_geonetwork_dev_web composer install ``` |
## Advanced Docker commands
### Clean commands
```bash
# Stop all container
docker stop $(docker ps -a -q)
# Remove all container
docker rm $(docker ps -a -q)
# Delete all image with name or tag aas "<none>"
docker rmi `docker images| egrep "<none>" |awk '{print $3}'`
```
### Monitoring commands
```bash
# Watch all container
watch -n 1 "docker ps -a"
# Watch all images
watch -n 1 "docker images"
# Watch all resources container
docker stats
```
version: '3.5'
services:
jpr_prodige_geonetwork_dev_web:
image: jpr_prodige_geonetwork_dev_web
build: ./web
container_name: jpr_prodige_geonetwork_dev_web
volumes:
- ../../target/geosource-overlay-3.4.1-0.war:/usr/local/tomcat/webapps/geonetwork.war
# - ../../etc/cas:/etc/cas
ports:
- "8080:8080"
networks:
default:
aliases:
- jpr_prodige_geonetwork_web
#networks:
# default:
# name: jpr_prodige_geonetwork_network
networks:
default:
name: prodige
external: true
\ No newline at end of file
FROM tomcat:8-jdk8
# WEB-INF/config-overrides.properties
#ENV LDAP_CREDENTIAL ldappassword
#ENV CAS_BASEURL https://cas.prodige.internal
#ENV GEONETWORK_BASEURL https://catalogue.prodige.internal/geonetwork
#ENV DB_NAME catalogue
#ENV USER_NAME user_prodige
#ENV USER_PASSWORD databasepassword
#ENV DB_HOST ppr_prodige_catalogue_db
#ENV DB_PORT 5432
# WEB-INF/config-overrides-prod.xml
#ENV URL_CATALOGUE https://catalogue.prodige.internal
#ENV URL_CARTO https://carto.prodige.internal
#ENV URL_TELECARTO https://telecarto.prodige.internal
#CATALINA_OPTS=-D$(URL_CATALOGUE)
CMD ["catalina.sh", "run"]
\ No newline at end of file
## Run
Run with
```bash
docker-compose up
```
url : http://localhost:8080/geonetwork
Stop with
```bash
docker-compose down
```
\ No newline at end of file
version: '3.5'
services:
jpr_prodige_geonetwork_web:
image: jpr_prodige_geonetwork_web:latest
container_name: jpr_prodige_geonetwork_web
ports:
- "8080:8080"
networks:
default:
name: jpr_prodige_geonetwork_network
\ No newline at end of file
......@@ -6,13 +6,13 @@
<groupId>prodige41.alkante.al</groupId>
<artifactId>geosource-overlay</artifactId>
<packaging>war</packaging>
<version>3.8.3-0</version>
<version>3.4.1-0</version>
<dependencies>
<dependency>
<groupId>org.geonetwork-opensource</groupId>
<artifactId>geonetwork</artifactId>
<version>3.8.3-0</version>
<version>3.4.1-0</version>
<type>war</type>
<scope>runtime</scope>
</dependency>
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration debug="false">
<!-- Appender Configurations -->
<appender name="consoleAppender" class="org.apache.log4j.ConsoleAppender">
<param name="Threshold" value="ALL"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{ISO8601} %-5p [%c] - %m%n"/>
</layout>
</appender>
<appender name="allConsoleAppender" class="org.apache.log4j.ConsoleAppender">
<param name="Threshold" value="ALL"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{ISO8601} %-5p [%c] - %m%n"/>
</layout>
</appender>
<appender name="fileAppender" class="org.apache.log4j.RollingFileAppender">
<param name="Threshold" value="ALL"/>
<param name="File" value="logs/geonetwork.log"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{ISO8601} %-5p [%c] - %m%n"/>
</layout>
</appender>
<!-- Geonetwork module (and submodule) logging -->
<logger name="geonetwork" additivity="false">
<level value="WARN"/>
<appender-ref ref="consoleAppender"/>
<appender-ref ref="fileAppender"/>
</logger>
<logger name="geonetwork.search">
<level value="WARN"/>
</logger>
<logger name="geonetwork.databasemigration">
<level value="WARN"/>
</logger>
<logger name="geonetwork.database">
<level value="WARN"/>
</logger>
<logger name="geonetwork.cors">
<level value="WARN"/>
</logger>
<logger name="geonetwork.editor">
<level value="WARN"/>
</logger>
<logger name="geonetwork.schemamanager">
<level value="WARN"/>
</logger>
<logger name="geonetwork.thesaurus-man">
<level value="WARN"/>
</logger>
<logger name="geonetwork.accessmanager">
<level value="WARN"/>
</logger>
<logger name="geonetwork.thesaurus">
<level value="WARN"/>
</logger>
<logger name="geonetwork.editorexpandelement">
<level value="WARN"/>
</logger>
<logger name="geonetwork.editorfillelement">
<level value="WARN"/>
</logger>
<logger name="geonetwork.LanguageDetector">
<level value="WARN"/>
</logger>
<logger name="geonetwork.index">
<level value="WARN"/>
</logger>
<logger name="geonetwork.csw">
<level value="WARN"/>
</logger>
<logger name="geonetwork.csw.search">
<level value="WARN"/>
</logger>
<logger name="geonetwork.formatter">
<level value="WARN"/>
</logger>
<logger name="geonetwork.harvester">
<level value="WARN"/>
</logger>
<logger name="geonetwork.lucene">
<level value="WARN"/>
</logger>
<logger name="geonetwork.ldap">
<level value="WARN"/>
</logger>
<logger name="geonetwork.lucene.tracking">
<level value="WARN"/>
</logger>
<logger name="geonetwork.mef">
<level value="WARN"/>
</logger>
<logger name="geonetwork.sru">
<level value="WARN"/>
</logger>
<logger name="geonetwork.sru.search">
<level value="WARN"/>
</logger>
<logger name="geonetwork.GeoServerPublisher">
<level value="WARN"/>
</logger>
<logger name="geonetwork.GeoServerRest">
<level value="WARN"/>
</logger>
<logger name="geonetwork.data.directory">
<level value="WARN"/>
</logger>
<logger name="geonetwork.wro4j">
<level value="WARN"/>
</logger>
<logger name="geonetwork.camel-harvester">
<level value="WARN"/>
</logger>
<logger name="geonetwork.harvest.wfs.features">
<level value="WARN"/>
</logger>
<!-- Jeeves module and submodule logger configuration -->
<logger name="jeeves" additivity="false">
<level value="WARN"/>
<appender-ref ref="consoleAppender"/>
<appender-ref ref="fileAppender"/>
</logger>
<logger name="jeeves.dbms">
<level value="WARN"/>
</logger>
<logger name="jeeves.dbms.resourcetracking">
<level value="WARN"/>
</logger>
<logger name="jeeves.monitor">
<level value="WARN"/>
</logger>
<logger name="jeeves.engine">
<level value="WARN"/>
</logger>
<logger name="jeeves.dbmspool">
<level value="WARN"/>
</logger>
<logger name="jeeves.resources">
<level value="WARN"/>
</logger>
<logger name="jeeves.xlinkprocessor">
<level value="WARN"/>
</logger>
<logger name="jeeves.transformerFactory">
<level value="WARN"/>
</logger>
<logger name="jeeves.xmlresolver">
<level value="WARN"/>
</logger>
<!-- Spring logging configuration -->
<logger name="org.springframework" additivity="false">
<level value="WARN"/>
<appender-ref ref="consoleAppender"/>
<appender-ref ref="fileAppender"/>
</logger>
<logger name="org.springframework.beans" additivity="false">
<level value="WARN"/>
<appender-ref ref="fileAppender"/>
</logger>
<logger name="org.springframework.security">
<level value="WARN"/>
</logger>
<logger name="org.springframework.security.ldap">
<level value="WARN"/>
</logger>
<logger name="org.springframework.aop.framework.CglibAopProxy">
<level value="ERROR"/>
</logger>
<!-- JZKIT logging configuration -->
<logger name="com.k_int" additivity="false">
<level value="WARN"/>
<appender-ref ref="consoleAppender"/>
<appender-ref ref="fileAppender"/>
</logger>
<logger name="org.jzkit">
<level value="WARN"/>
</logger>
<logger name="org.jzkit.a2j">
<level value="WARN"/>
</logger>
<logger name="org.jzkit.search.impl.LRUCache">
<level value="WARN"/>
</logger>
<logger name="ro.isdc.wro.http" additivity="false">
<level value="WARN"/>
<appender-ref ref="allConsoleAppender"/>
<appender-ref ref="fileAppender"/>
</logger>
<logger name="org.hibernate.SQL" additivity="false">
<level value="WARN"/>
<appender-ref ref="consoleAppender"/>
<appender-ref ref="fileAppender"/>
</logger>
<logger name="org.hibernate.type" additivity="false">
<level value="WARN"/>
<appender-ref ref="consoleAppender"/>
<appender-ref ref="fileAppender"/>
</logger>
<logger name="org.hibernate.tool.hbm2ddl" additivity="false">
<level value="WARN"/>
<appender-ref ref="consoleAppender"/>
<appender-ref ref="fileAppender"/>
</logger>
<logger name="org.xhtmlrenderer" additivity="false">
<level value="TRACE"/>
<appender-ref ref="consoleAppender"/>
<appender-ref ref="fileAppender"/>
</logger>
<logger name="org.apache.camel" additivity="true">
<level value="WARN"/>
<appender-ref ref="consoleAppender"/>
<appender-ref ref="fileAppender"/>
</logger>
<!-- Turn off logging except when explicitly declared below -->