Skip to content

Commit da11650

Browse files
author
jaserud
committed
- port to es7
- remove circle CI - added jenkins pipeline - updated dockerfile
1 parent 73addba commit da11650

File tree

10 files changed

+193
-165
lines changed

10 files changed

+193
-165
lines changed

.circleci/config.yml

-56
This file was deleted.

.mvn/wrapper/maven-wrapper.properties

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#
2-
# Copyright (c) 2018. The Ontario Institute for Cancer Research. All rights reserved.
3-
#
2+
# Copyright (c) 2020. The Ontario Institute for Cancer Research. All rights reserved.
3+
#
44
# This program is free software: you can redistribute it and/or modify
55
# it under the terms of the GNU Affero General Public License as published by
66
# the Free Software Foundation, either version 3 of the License, or
@@ -13,7 +13,7 @@
1313
#
1414
# You should have received a copy of the GNU Affero General Public License
1515
# along with this program. If not, see <http://www.gnu.org/licenses/>.
16-
#
16+
#
1717
#
1818

19-
distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.3/apache-maven-3.5.3-bin.zip
19+
distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip

Dockerfile

+23-27
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,32 @@
1-
FROM openjdk:8u121-jdk-alpine
1+
FROM openjdk:11-jdk as builder
22

3-
ARG MAVEN_VERSION=3.5.4
4-
ARG SHA=ce50b1c91364cb77efe3776f756a6d92b76d9038b0a0782f7d53acf1e997a14d
5-
ARG BASE_URL=https://apache.osuosl.org/maven/maven-3/${MAVEN_VERSION}/binaries
3+
# Build song-server jar
4+
COPY . /srv
5+
WORKDIR /srv
6+
RUN ./mvnw clean package -DskipTests
67

7-
RUN apk add --no-cache curl tar bash \
8-
&& mkdir -p /usr/share/maven /usr/share/maven/ref \
9-
&& curl -fsSL -o /tmp/apache-maven.tar.gz ${BASE_URL}/apache-maven-${MAVEN_VERSION}-bin.tar.gz \
10-
&& echo "${SHA} /tmp/apache-maven.tar.gz" | sha256sum -c - \
11-
&& tar -xzf /tmp/apache-maven.tar.gz -C /usr/share/maven --strip-components=1 \
12-
&& rm -f /tmp/apache-maven.tar.gz \
13-
&& ln -s /usr/share/maven/bin/mvn /usr/bin/mvn
148

15-
WORKDIR /usr/src/app
9+
FROM openjdk:11-jre as server
10+
# Paths
11+
ENV APP_HOME /srv/rollcall
12+
ENV APP_LOGS $APP_HOME/logs
13+
ENV JAR_FILE /srv/rollcall/rollcall.jar
1614

17-
# copy just the pom.xml and install dependencies for caching
18-
COPY pom.xml .
19-
RUN mvn verify clean --fail-never
15+
COPY --from=builder /srv/target/rollcall-*.jar $JAR_FILE
2016

17+
ENV APP_USER rollcall
18+
ENV APP_UID 9999
19+
ENV APP_GID 9999
2120

22-
COPY . .
21+
RUN useradd -r -u $APP_UID $APP_USER \
22+
&& mkdir -p $APP_HOME $APP_LOGS \
23+
&& chown -R $APP_UID:$APP_GID $APP_HOME \
24+
&& chown -R $APP_UID:$APP_GID $APP_LOGS
2325

24-
RUN mkdir -p /srv/rollcall/install \
25-
&& mkdir -p /srv/rollcall/exec \
26-
&& mvn package -Dmaven.test.skip=true \
27-
&& mv /usr/src/app/target/rollcall-*-SNAPSHOT.jar /srv/rollcall/install/ROLLCALL.jar \
28-
&& mv /usr/src/app/src/main/resources/scripts/run.sh /srv/rollcall/exec/run.sh
26+
USER $APP_USER
2927

30-
# setup required environment variables
31-
ENV ROLLCALL_INSTALL_PATH /srv/rollcall
32-
33-
# start ego server
34-
WORKDIR $ROLLCALL_INSTALL_PATH
35-
CMD $ROLLCALL_INSTALL_PATH/exec/run.sh
28+
WORKDIR $APP_HOME
3629

30+
CMD java -Dlog.path=$APP_LOGS \
31+
-jar $JAR_FILE \
32+
--spring.config.location=classpath:/application.yml

Jenkinsfile

+102-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,102 @@
1-
@Library(value="oicr", changelog=false) _
2-
rollcall{}
1+
import groovy.json.JsonOutput
2+
3+
def version = "UNKNOWN"
4+
def commit = "UNKNOWN"
5+
6+
pipeline {
7+
agent {
8+
kubernetes {
9+
label 'rollcall-executor'
10+
yaml """
11+
apiVersion: v1
12+
kind: Pod
13+
spec:
14+
containers:
15+
- name: jdk
16+
tty: true
17+
image: openjdk:11
18+
env:
19+
- name: DOCKER_HOST
20+
value: tcp://localhost:2375
21+
- name: helm
22+
image: alpine/helm:2.12.3
23+
command:
24+
- cat
25+
tty: true
26+
- name: docker
27+
image: docker:18-git
28+
tty: true
29+
volumeMounts:
30+
- mountPath: /var/run/docker.sock
31+
name: docker-sock
32+
- name: dind-daemon
33+
image: docker:18.06-dind
34+
securityContext:
35+
privileged: true
36+
volumeMounts:
37+
- name: docker-graph-storage
38+
mountPath: /var/lib/docker
39+
volumes:
40+
- name: docker-sock
41+
hostPath:
42+
path: /var/run/docker.sock
43+
type: File
44+
- name: docker-graph-storage
45+
emptyDir: {}
46+
"""
47+
}
48+
}
49+
stages {
50+
stage('Prepare') {
51+
steps {
52+
script {
53+
commit = sh(returnStdout: true, script: 'git describe --always').trim()
54+
}
55+
script {
56+
version = readMavenPom().getVersion()
57+
}
58+
}
59+
}
60+
stage('Test') {
61+
steps {
62+
container('jdk') {
63+
sh "./mvnw test package"
64+
}
65+
}
66+
}
67+
stage('Build & Publish Develop') {
68+
when {
69+
branch "develop"
70+
}
71+
steps {
72+
container('docker') {
73+
withCredentials([usernamePassword(credentialsId:'OvertureDockerHub', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) {
74+
sh 'docker login -u $USERNAME -p $PASSWORD'
75+
}
76+
sh "docker build --network=host -f Dockerfile . -t overture/rollcall:edge -t overture/rollcall:${commit}"
77+
sh "docker push overture/rollcall:edge"
78+
sh "docker push overture/rollcall:${commit}"
79+
}
80+
}
81+
}
82+
stage('Release & tag') {
83+
when {
84+
branch "master"
85+
}
86+
steps {
87+
container('docker') {
88+
withCredentials([usernamePassword(credentialsId: 'OvertureBioGithub', passwordVariable: 'GIT_PASSWORD', usernameVariable: 'GIT_USERNAME')]) {
89+
sh "git tag ${version}"
90+
sh "git push https://${GIT_USERNAME}:${GIT_PASSWORD}@github.com/overture-stack/rollcall --tags"
91+
}
92+
withCredentials([usernamePassword(credentialsId:'OvertureDockerHub', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) {
93+
sh 'docker login -u $USERNAME -p $PASSWORD'
94+
}
95+
sh "docker build --network=host -f Dockerfile . -t overture/rollcall:latest -t overture/rollcall:${version}"
96+
sh "docker push overture/rollcall:${version}"
97+
sh "docker push overture/rollcall:latest"
98+
}
99+
}
100+
}
101+
}
102+
}

pom.xml

+11-10
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
<groupId>bio.overture</groupId>
2525
<artifactId>rollcall</artifactId>
26-
<version>1.0.0-SNAPSHOT</version>
26+
<version>2.0.0-SNAPSHOT</version>
2727
<packaging>jar</packaging>
2828

2929
<name>rollcall</name>
@@ -101,22 +101,17 @@
101101
<dependency>
102102
<groupId>org.elasticsearch</groupId>
103103
<artifactId>elasticsearch</artifactId>
104-
<version>6.3.1</version>
104+
<version>7.5.2</version>
105105
</dependency>
106106
<dependency>
107107
<groupId>org.elasticsearch.client</groupId>
108108
<artifactId>elasticsearch-rest-high-level-client</artifactId>
109-
<version>6.3.1</version>
109+
<version>7.5.2</version>
110110
</dependency>
111111
<dependency>
112112
<groupId>org.elasticsearch.client</groupId>
113-
<artifactId>transport</artifactId>
114-
<version>6.3.1</version>
115-
</dependency>
116-
<dependency>
117-
<groupId>org.elasticsearch.plugin</groupId>
118-
<artifactId>transport-netty4-client</artifactId>
119-
<version>6.3.1</version>
113+
<artifactId>elasticsearch-rest-client</artifactId>
114+
<version>7.5.2</version>
120115
</dependency>
121116

122117
<!-- Swagger -->
@@ -145,6 +140,12 @@
145140
<scope>test</scope>
146141
</dependency>
147142

143+
<!-- JAXB -->
144+
<dependency>
145+
<groupId>org.glassfish.jaxb</groupId>
146+
<artifactId>jaxb-runtime</artifactId>
147+
<version>2.4.0-b180830.0438</version>
148+
</dependency>
148149
</dependencies>
149150

150151
<build>

src/main/java/bio/overture/rollcall/config/ElasticsearchConfig.java

-18
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@
2222
import org.apache.http.HttpHost;
2323
import org.elasticsearch.client.RestClient;
2424
import org.elasticsearch.client.RestHighLevelClient;
25-
import org.elasticsearch.client.transport.TransportClient;
26-
import org.elasticsearch.common.settings.Settings;
27-
import org.elasticsearch.common.transport.TransportAddress;
28-
import org.elasticsearch.transport.client.PreBuiltTransportClient;
2925
import org.springframework.beans.factory.annotation.Value;
3026
import org.springframework.context.annotation.Bean;
3127
import org.springframework.context.annotation.Configuration;
@@ -35,16 +31,12 @@
3531
@Configuration
3632
public class ElasticsearchConfig {
3733

38-
private static final String CLUSTER_NAME = "cluster.name";
39-
4034
@Value("${elasticsearch.host}")
4135
private String host;
4236

4337
@Value("${elasticsearch.port}")
4438
private int port;
4539

46-
@Value("${elasticsearch.cluster-name}")
47-
private String clusterName;
4840

4941
@Bean
5042
@SneakyThrows
@@ -55,14 +47,4 @@ public RestHighLevelClient restClient() {
5547
)
5648
);
5749
}
58-
59-
@Bean
60-
@SneakyThrows
61-
public TransportClient transportClient() {
62-
return new PreBuiltTransportClient(Settings.builder()
63-
.put(CLUSTER_NAME, clusterName)
64-
.build())
65-
.addTransportAddress(new TransportAddress(InetAddress.getByName(host), port));
66-
}
67-
6850
}

0 commit comments

Comments
 (0)