Skip to content

Commit

Permalink
Merge pull request #41 from KillrVideo/ci_pipeline
Browse files Browse the repository at this point in the history
CI Pipeline
  • Loading branch information
HadesArchitect authored Jan 15, 2020
2 parents b2ef090 + 1154e36 commit 98a32fd
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 38 deletions.
28 changes: 21 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
language: java
jdk:
- openjdk11
language: generic

# Sudo required for doing docker build
sudo: required
Expand All @@ -9,15 +7,32 @@ services:

# Build the app and a docker image
script:
- mvn clean install
- docker build -t ${TRAVIS_COMMIT} --build-arg JAR_FILE=target/killrvideo-services-3.0.0.jar ./killrvideo-services
- travis_fold start docker_build
- docker run -v ${PWD}:/opt/killrvideo-java -w /opt/killrvideo-java maven mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B
- docker build -t ${TRAVIS_COMMIT} -t killrvideo-java-local .
- travis_fold end docker_build
- travis_fold start docker_dependencies_up
- docker-compose -f docker-compose.ci.yml up -d dse dse-config
- sleep 180
- docker-compose -f docker-compose.ci.yml up -d backend
- sleep 180
- docker-compose -f docker-compose.ci.yml exec backend echo 'Still alive!' || { echo "Backend is down"; docker-compose -f docker-compose.ci.yml logs dse-config backend; exit 1; }
- travis_fold end docker_dependencies_up
- docker run --network killrvideo-java_default killrvideo/killrvideo-integration-tests

# If successful, see if we need to publish also
after_success:
- test -z $TRAVIS_TAG && travis_terminate 0
- "[ \"$TRAVIS_EVENT_TYPE\" = \"cron\" ] && { echo \"Ignore nightly builds\"; travis_terminate 0; }"
- test -z $TRAVIS_TAG && { echo "Ignore non-tagged builds"; travis_terminate 0; }
- docker tag ${TRAVIS_COMMIT} killrvideo/killrvideo-java:${TRAVIS_TAG}
- echo "$DOCKER_PASS" | docker login -u "$DOCKER_USER" --password-stdin
- docker push killrvideo/killrvideo-java:${TRAVIS_TAG}
- "[ \"$(git tag --sort=-v:refname | grep -P \"^\\d+.\\d+.\\d+$\" | head -n1)\" == \"$TRAVIS_TAG\" ] && { docker tag ${TRAVIS_COMMIT} killrvideo/killrvideo-java:latest; docker push killrvideo/killrvideo-java:latest; }"

after_failure:
- travis_fold start docker_logs
- docker-compose -f docker-compose.ci.yml logs dse-config backend
- travis_fold end docker_logs

env:
global:
Expand All @@ -29,4 +44,3 @@ notifications:
slack:
rooms:
secure: N6FrJ0l0gw2t1wnty/xPDKvLBZlzOAmkIbHjd4ZrtaC4vLU8iZP+YCRvQd7Vwzc97yDhHIZ41eGtjHjBIIeMX/3rfuS+6GA4VJgyNFGsP0f81YYHxiMOEUlVa2O6LBwbF3LokaFi3l7Iau1c5Op9c3LinhTdE0W6KG+2gxEqSKJkBcVJfK9SZGXg3+6qlq065BWx7xWlzoWgMFyipJJLW1BAqEzP5cc6hHozJ5H/8ucMaJbWQF+nOaIYUJdaop4ChSpe6EFyg0XNp+mIjJ2BxZ6hfYrAs69vwBapBepe4zEoR5xdN1dGUAIDqNY9rr4Npp8InFmBmnlL1xG6FeG73C2qfSr3Y2WziOtwececzmuQWI2Do9ioB5k0KtC4UAV42tpADUODrrwxE8S32tqgr0Pojg8FvgsM6O3twvF1UH3LLEyW7zDzuDpYdtvIROWZGerxyWqQIFI7MzragyL+ZiKKUOG1uKsA8DoeECcMHuUsDEsR/mHalmQGGl2ZNGpphAHg/1HtjB32VDCIuZpFHsqFG7BfMY2dg8Mm+ea4j9imOxM+2TFxbPhoIjIJq1o+/YvolrYviWgmQOpeFw0c1xXWSL5aXmBv2nUnlBaXxfzC9FTl0xmovJmKeYhqJ81TMa33gimsMeccZIDmzcMDsW82idsvtHeNDSX1wil5DXA=

10 changes: 10 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM openjdk:11

MAINTAINER Cedrick Lunven <[email protected]>
MAINTAINER Davig Gilardi <[email protected]>

ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/killrvideo-java.jar"]
EXPOSE 50101

# To create jar file, run `docker run -v ${PWD}:/opt/killrvideo-java -w /opt/killrvideo-java maven mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B`
COPY ./killrvideo-services/target/killrvideo-java.jar /killrvideo-java.jar
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@ A reference application for Java developers looking to learn more about using [A

## The latest stable build of KillrVideo Java is [v2.1.0][v2.1.0]. Master is experimental. Please use v2.1.0 if you attempting to follow the instructions in the links below.

## Building Locally

**Docker Way**

`docker run -v ${PWD}:/opt/killrvideo-java -w /opt/killrvideo-java maven mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B`

**Maven Way**

`mvn install`

## Running Locally

Use these guides to get started running KillrVideo locally on your development machine:
Expand Down
24 changes: 24 additions & 0 deletions docker-compose.ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
version: '3'
services:
backend:
image: killrvideo-java-local
depends_on:
- dse
environment:
KILLRVIDEO_LOGGING_LEVEL: debug
KILLRVIDEO_DSE_CONTACT_POINTS: dse

dse:
image: datastax/dse-server:6.7.4
command: [ -s -g ]
environment:
DS_LICENSE: accept
cap_add:
- IPC_LOCK
ulimits:
memlock: -1

dse-config:
image: killrvideo/killrvideo-dse-config:3.0.0
depends_on:
- dse
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,17 @@ public class DseConfiguration {
@Value("#{environment.KILLRVIDEO_DSE_PASSWORD}")
public Optional < String > dsePassword;

@Value("${killrvideo.cassandra.maxNumberOfTries: 10}")
private int maxNumberOfTries = 10;

@Value("${killrvideo.cassandra.delayBetweenTries: 2}")
private int delayBetweenTries = 2;
@Value("${killrvideo.cassandra.maxNumberOfTries: 50}")
private Integer maxNumberOfTries;

@Value("#{environment.KILLRVIDEO_MAX_NUMBER_RETRY}")
private Optional < Integer > maxNumberOfTriesFromEnvVar;

@Value("${killrvideo.cassandra.delayBetweenTries: 3}")
private Integer delayBetweenTries;

@Value("#{environment.KILLRVIDEO_DELAY_BETWEEN_RETRY}")
private Optional < Integer > delayBetweenTriesFromEnvVar;

@Value("${killrvideo.ssl.CACertFileLocation: cassandra.cert}")
private String sslCACertFileLocation;
Expand Down Expand Up @@ -133,6 +139,14 @@ public DseSession initializeDSE() {
return clusterConfig.build().connect(CommonConstants.KILLRVIDEO_KEYSPACE);
};

if (!maxNumberOfTriesFromEnvVar.isEmpty()) {
maxNumberOfTries = maxNumberOfTriesFromEnvVar.get();
}

if (!delayBetweenTriesFromEnvVar.isEmpty()) {
delayBetweenTries = delayBetweenTriesFromEnvVar.get();
}

// Connecting to DSE with a retry mechanism :
/* In docker deployments we may have to wait until all components are up and running. */
RetryConfig config = new RetryConfigBuilder()
Expand All @@ -144,7 +158,7 @@ public DseSession initializeDSE() {

return new CallExecutor<DseSession>(config)
.afterFailedTry(s -> {
LOGGER.info("Attempt #{}/{} failed.. trying in {} seconds, waiting Dse to Start", atomicCount.getAndIncrement(),
LOGGER.info("Attempt #{}/{} failed.. trying in {} seconds, waiting for DSE to start...", atomicCount.getAndIncrement(),
maxNumberOfTries, delayBetweenTries); })
.onFailure(s -> {
LOGGER.error("Cannot connection to DSE after {} attempts, exiting", maxNumberOfTries);
Expand Down
25 changes: 0 additions & 25 deletions killrvideo-services/Dockerfile

This file was deleted.

2 changes: 2 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,8 @@
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<build>

<finalName>killrvideo-java</finalName>

<extensions>
<extension>
<groupId>kr.motd.maven</groupId>
Expand Down

0 comments on commit 98a32fd

Please sign in to comment.