adds devops components

parent 49cf48e0
node_modules/
node/
bower_components/
\ No newline at end of file
/sources
\ No newline at end of file
FROM maven:3.5.4 as builder
ARG GIT_CREDENTIALS
ARG ARTIFACTORY_USE
ARG ARTIFACTORY_USER
ARG ARTIFACTORY_PASSWORD
ARG ARTIFACTORY_MAVEN_REPO
ARG IA_CLIENT_GIT_REF
ARG BACKEND_GIT_REF
ARG VERSION
COPY . /
RUN \
chmod 750 /*.sh && \
. /configartifactorymaven.sh && \
python /processSourcesJson.py && \
rm -rf /sources
FROM jetty:9.3.24-alpine
ENV USER_GIT=user
ENV TOKEN_GIT=password
COPY --from=builder /app.war /var/lib/jetty/webapps/ROOT.war
USER root
RUN chown jetty:jetty /var/lib/jetty/webapps/ROOT.war
USER jetty
COPY /etc/dockertraining /etc/dockertraining
#!/bin/bash
sourcespath=$1
project=$2
echo "sourcespath $sourcespath"
echo "project $project"
#no config needed
#rm -rf ${xpref}
\ No newline at end of file
#!/bin/bash
if [ "$ARTIFACTORY_USE" != "Y" ]
then
echo "Without Artifactory"
else
echo "With Artifactory"
cp /settings.xml /usr/share/maven/conf/.
mkdir /root/.m2
cp /settings-security.xml /root/.m2/.
export MAVEN_USER="$ARTIFACTORY_USER"
export MASTER_PASSWORD="$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)"
export MAVEN_MASTER_PASSWORD="$(mvn --encrypt-master-password $MASTER_PASSWORD)"
sed -i "s@\${.*}@$MAVEN_MASTER_PASSWORD@g" /root/.m2/settings-security.xml
export MAVEN_PASSWORD="$(mvn --encrypt-password $ARTIFACTORY_PASSWORD)"
fi
#rm -rf /root/.m2/repository/ #to test that it works
javax.persistence.jdbc.driver=com.mysql.cj.jdbc.Driver
javax.persistence.jdbc.url=jdbc:mysql://mysql:3306/backend
javax.persistence.jdbc.user=root
javax.persistence.jdbc.password=
ia.mathsapi.basepath=http://ia:8080/v1
\ No newline at end of file
#!/bin/bash
sourcespath=$1
project=$2
echo "sourcespath $sourcespath"
echo "project $project"
cp $sourcespath/$project/target/*.war /app.war || true
#!/bin/bash -e
if [ $# -lt 5 ]; then
echo "Arguments required: dockerRepoUrl projectPath gitRef mavenParams"
fi
dockerRepoUrl=$1
projectPath=$2
gitRef=$3
gitCredentials=$4
mavenParams=$5
repofix=$dockerRepoUrl
[ -d /sources ] || mkdir -p /sources
#phase 1 clone repo if necesary
repo_dir=`echo $dockerRepoUrl | sed 's%^.*/\([^/]*\)\.git$%\1%g'`
echo "Git repository: $dockerRepoUrl"
echo "repository dir: $repo_dir"
if [ "$VERSION" != "local" ] && [ ! -d /sources/$repo_dir/.git ]; then
echo "Enter to clone repo..."
rm -rf /sources/$repo_dir/* > /dev/null 2>&1 || true
if [[ ! -z "$gitCredentials" ]]; then
repofix=${repofix/https:\/\//https:\/\/$gitCredentials@}
fi
git clone "$repofix" /sources/$repo_dir
echo "repository cloned"
else
echo "repository found in local folder: $repo_dir"
fi
#phase 2 checkout right version
if [ "$VERSION" != "local" ] && [ ! -z "$gitRef" ]; then
echo "checking out: $gitRef"
git -C /sources/$repo_dir checkout $gitRef --force
fi
#phase 3 config
/config.sh /sources/$repo_dir $projectPath
#phase 4 mvn
#NOTE jhipster bower instalation requires a file /root/.bowerrc to be run as root
if [[ ! -z "$mavenParams" ]]; then
echo "maven execution: -f sources/$repo_dir/$projectPath/pom.xml $mavenParams"
mvn -f /sources/$repo_dir/$projectPath/pom.xml $mavenParams || true
#because jhister
fi
#phase 5 move app war
/moveappwar.sh /sources/$repo_dir $projectPath
import json
import subprocess
import os
with open('/sources.json', 'r') as handle:
parsed = json.load(handle)
for source in parsed['sources']:
subprocess.check_call(['/processSource.sh',source['source']['repo'],source['source']['path'],os.getenv(source['source']['git_ref'],''),os.getenv(source['source']['git_credentials'],''),source['source']['maven']])
<settingsSecurity>
<master>${env.MAVEN_MASTER_PASSWORD}</master>
</settingsSecurity>
\ No newline at end of file
This diff is collapsed.
{
"sources": [
{
"source": {
"repo": "https://git.code.tecnalia.com/public_dockerkubernetes/p04_1.git",
"path": "devops/ia.client",
"git_ref": "IA_CLIENT_GIT_REF",
"git_credentials": "GIT_CREDENTIALS",
"maven": "install -Dmaven.test.skip=true -DskipTests"
}
},
{
"source": {
"repo": "https://git.code.tecnalia.com/public_dockerkubernetes/p04_1.git",
"path": "devops/backend",
"git_ref": "BACKEND_GIT_REF",
"git_credentials": "GIT_CREDENTIALS",
"maven": "package war:war -Dmaven.test.skip=true -DskipTests"
}
}
]
}
\ No newline at end of file
FROM alpine:3.9
RUN apk add --no-cache mysql-client curl
ENV MYSQL_DB_USER root
ENV MYSQL_DB_NAME backend
ENV MYSQL_DB_HOST mysql
ADD resources resources
ADD run.sh .
RUN chmod 750 run.sh
ENV PATH /:$PATH
CMD ["run.sh"]
\ No newline at end of file
-- MySQL dump 10.16 Distrib 10.1.30-MariaDB, for CYGWIN (x86_64)
--
-- Host: 127.0.0.1 Database: backend
-- ------------------------------------------------------
-- Server version 5.7.25
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Dumping data for table `Harvest`
--
LOCK TABLES `Harvest` WRITE;
/*!40000 ALTER TABLE `Harvest` DISABLE KEYS */;
INSERT INTO `Harvest` VALUES (1,100,'2019-04-12 12:29:35.833000','string'),(2,100,'2019-04-13 12:29:35.833000','string'),(3,100,'2019-04-14 12:29:35.833000','string'),(4,100,'2019-04-15 12:29:35.833000','string'),(5,100,'2019-04-16 12:29:35.833000','string'),(6,100,'2019-04-17 12:29:35.833000','string'),(7,100,'2019-04-18 12:29:35.833000','string'),(8,100,'2019-04-19 12:29:35.833000','string'),(9,100,'2019-04-20 12:29:35.833000','string'),(10,100,'2019-04-21 12:29:35.833000','string'),(11,100,'2019-04-22 12:29:35.833000','string');
/*!40000 ALTER TABLE `Harvest` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2019-04-22 23:01:38
#!/bin/sh
while ! mysqladmin ping -h $MYSQL_DB_HOST --silent; do
sleep 1
done
#wait for the frontend to be on
URL="http://backend:8080/v1/harvests"
echo "URL=$URL"
#$(curl --output /dev/null --silent --head --fail $URL) it does not work it returns 500
until $(curl --output /dev/null --silent --head --fail $URL); do
printf 'waiting for backend'
echo ''
sleep 5
done
mysql -u $MYSQL_DB_USER -f -h $MYSQL_DB_HOST -D $MYSQL_DB_NAME -P 3306 < /resources/sql/test-data.sql
# mysql -u $MYSQL_DB_USER -h $MYSQL_DB_HOST -D $MYSQL_DB_NAME < resources/sql/test-data.sql
if [ $? -eq 0 ]
then
echo "ALL SUCCESSFUL"
else
echo "ERROR"
fi
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/classes" path="src/gen/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>eu.afarcloud.dockertraining.backend.server</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>
eclipse.preferences.version=1
encoding//src/gen/java=UTF-8
encoding//src/main/java=UTF-8
encoding/<project>=UTF-8
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.7
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1
# Swagger Codegen Ignore
# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen
# Use this file to prevent files from being overwritten by the generator.
# The patterns follow closely to .gitignore or .dockerignore.
# As an example, the C# client generator defines ApiClient.cs.
# You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line:
#ApiClient.cs
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
#foo/*/qux
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
#foo/**/qux
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
# You can also negate patterns with an exclamation (!).
# For example, you can ignore all files in a docs folder with the file extension .md:
#docs/*.md
# Then explicitly reverse the ignore rule for a single file:
#!docs/README.md
2.4.4
\ No newline at end of file
# Swagger Jersey generated server
## Overview
This server was generated by the [swagger-codegen](https://github.com/swagger-api/swagger-codegen) project. By using the
[OpenAPI-Spec](https://github.com/swagger-api/swagger-core/wiki) from a remote server, you can easily generate a server stub. This
is an example of building a swagger-enabled JAX-RS server.
This example uses the [JAX-RS](https://jax-rs-spec.java.net/) framework.
To run the server, please execute the following:
```
mvn clean package jetty:run
```
You can then view the swagger listing here:
```
http://localhost:8080/v1/swagger.json
```
Note that if you have configured the `host` to be something other than localhost, the calls through
swagger-ui will be directed to that host and not localhost!
\ No newline at end of file
{
"apiPackage": "eu.afarcloud.dockertraining.backend.server.api",
"modelPackage": "eu.afarcloud.dockertraining.backend.server.model",
"groupId": " eu.afarcloud",
"artifactId": "eu.afarcloud.dockertraining.backend.server "
}
<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/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId> eu.afarcloud</groupId>
<artifactId>eu.afarcloud.dockertraining.backend.server </artifactId>
<packaging>jar</packaging>
<name>eu.afarcloud.dockertraining.backend.server </name>
<version>1.0.0</version>
<licenses>
<license>
<name>Unlicense</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.html</url>
<distribution>repo</distribution>
</license>
</licenses>
<build>
<sourceDirectory>src/main/java</sourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>${jetty-version}</version>
<configuration>
<webApp>
<contextPath>/</contextPath>
</webApp>
<webAppSourceDirectory>target/${project.artifactId}-${project.version}</webAppSourceDirectory>
<stopPort>8079</stopPort>
<stopKey>stopit</stopKey>
<stopWait>10</stopWait>
<httpConnector>
<port>8080</port>
<idleTimeout>60000</idleTimeout>
</httpConnector>
</configuration>
<executions>
<execution>
<id>start-jetty</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start</goal>
</goals>
<configuration>
<scanIntervalSeconds>0</scanIntervalSeconds>
<daemon>true</daemon>
</configuration>
</execution>
<execution>
<id>stop-jetty</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.9.1</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>src/gen/java</source>
</sources>
</configuration>
</execution>
<!--
<execution>
<id>add-resource</id>
<phase>generate-resources</phase>
<goals>
<goal>add-resource</goal>
</goals>
<configuration>
<resources>
<resource>
<directory>src/resources</directory>
<targetPath>resources</targetPath>
<excludes>
<exclude>**/junk/**</exclude>
</excludes>
</resource>
</resources>
</configuration>
</execution>
-->
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-jersey2-jaxrs</artifactId>
<scope>compile</scope>
<version>${swagger-core-version}</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback-version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>${logback-version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit-version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>${servlet-api-version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet-core</artifactId>
<version>${jersey2-version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-multipart</artifactId>
<version>${jersey2-version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-joda</artifactId>
<version>${jackson-version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-json-provider</artifactId>
<version>${jackson-version}</version>
</dependency>
<!-- Base64 encoding that works in both JVM and Android -->
<dependency>
<groupId>com.brsanthu</groupId>
<artifactId>migbase64</artifactId>
<version>2.2</version>
</dependency>
<!-- Bean Validation API support -->
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.1.0.Final</version>
</dependency>
<!-- JPA support -->
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>javax.persistence</artifactId>
<version>2.2.0</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.2.18.Final</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.15</version>
</dependency>
<!-- IA CLient -->
<dependency>
<groupId> eu.afarcloud</groupId>
<artifactId>eu.afarcloud.dockertraining.ia.client</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-rs-client</artifactId>
<version>3.2.8</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>sonatype-snapshots</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<properties>
<java.version>1.7</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<swagger-core-version>1.5.18</swagger-core-version>
<jetty-version>9.2.9.v20150224</jetty-version>
<jersey2-version>2.22.2</jersey2-version>
<jackson-version>2.8.9</jackson-version>
<junit-version>4.12</junit-version>
<logback-version>1.1.7</logback-version>
<servlet-api-version>2.5</servlet-api-version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>
package eu.afarcloud.dockertraining.backend.server.api;
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2019-04-19T01:00:19.867+02:00")
public class ApiException extends Exception{
private int code;
public ApiException (int code, String msg) {
super(msg);
this.code = code;
}
}
package eu.afarcloud.dockertraining.backend.server.api;
import java.io.IOException;
import javax.servlet.*;
import javax.servlet.http.HttpServletResponse;
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2019-04-19T01:00:19.867+02:00")
public class ApiOriginFilter implements javax.servlet.Filter {
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
HttpServletResponse res = (HttpServletResponse) response;
res.addHeader("Access-Control-Allow-Origin", "*");
res.addHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT");
res.addHeader("Access-Control-Allow-Headers", "Content-Type");
chain.doFilter(request, response);
}
public void destroy() {}
public void init(FilterConfig filterConfig) throws ServletException {}
}
\ No newline at end of file
package eu.afarcloud.dockertraining.backend.server.api;
import javax.xml.bind.annotation.XmlTransient;
@javax.xml.bind.annotation.XmlRootElement
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2019-04-19T01:00:19.867+02:00")