Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
136 changes: 136 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
image: docker:latest
services:
- docker:stable-dind
variables:
DOCKER_TLS_CERTDIR: ""
stages:
- tests
- build-jar
- build-docker-image
- kubernetes-deploy

unit-tests:
image: maven:3.6-jdk-11
stage: tests
script:
- mvn test -B -s settings.xml -P complex-ws,unit-tests
when: manual

.maven-build:
needs: [ unit-tests ]
image: maven:3.6-jdk-11
stage: build-jar
script:
- mvn clean package -B -s settings.xml -P $MAVEN_PROFILES -Dmaven.test.skip=true
- POM_VERSION=$(mvn -Dexec.executable='echo' -Dexec.args='${project.version}' --non-recursive exec:exec -q)
- echo "IMAGE_TAG=$POM_VERSION-$PROFILE_SUFFIX-$CI_COMMIT_SHORT_SHA" > build.env
artifacts:
paths:
- target/*.war
reports:
dotenv: build.env
when: manual

maven-build-test:
extends: .maven-build
variables:
MAVEN_PROFILES: "complex-ws,k8s-solr,test"
PROFILE_SUFFIX: "test"

maven-build-prod-hx:
extends: .maven-build
variables:
MAVEN_PROFILES: "complex-ws,k8s-solr,pub-fallback"
PROFILE_SUFFIX: "hx"

maven-build-prod-hh:
extends: .maven-build
variables:
MAVEN_PROFILES: "complex-ws,k8s-solr,pub"
PROFILE_SUFFIX: "hh"

.docker-build:
stage: build-docker-image
before_script:
- unset DOCKER_HOST
- unset DOCKER_AUTH_CONFIG
- docker system prune -af
script:
- echo "$CI_DOCKER_HUB_PASSWORD" | docker login -u $CI_DOCKER_HUB_USER --password-stdin
- echo "$CI_REGISTRY_IMAGE:$IMAGE_TAG"
- docker build -t "$CI_REGISTRY_IMAGE:$IMAGE_TAG" --no-cache .
- docker image ls
- docker logout
- echo "$CI_REGISTRY_PASSWORD" | docker login -u $CI_REGISTRY_USER $CI_REGISTRY --password-stdin
- docker push "$CI_REGISTRY_IMAGE:$IMAGE_TAG"
- docker rmi "$CI_REGISTRY_IMAGE:$IMAGE_TAG"
- docker logout $CI_REGISTRY

docker-build-test:
extends: .docker-build
needs: [ maven-build-test ]

docker-build-prod-hx:
extends: .docker-build
needs: [ maven-build-prod-hx ]

docker-build-prod-hh:
extends: .docker-build
needs: [ maven-build-prod-hh ]

.kubernetes-deploy:
stage: kubernetes-deploy
image: alpine
before_script:
- apk add --no-cache curl git
- curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl
- chmod +x ./kubectl
- mv ./kubectl /usr/local/bin/kubectl
- git clone https://k8s-config-token:$K8S_CONFIG_TOKEN@gitlab.ebi.ac.uk/intact-ci/k8s-config
- mkdir ~/.kube
- cp k8s-config/config ~/.kube/
script:
- kubectl config get-contexts
- kubectl config use-context $KUBE_CONTEXT
- kubectl create secret docker-registry gitlab-registry --docker-server=$CI_REGISTRY --docker-username=$CI_REGISTRY_USER --docker-password=$CI_JOB_TOKEN --docker-email=$GITLAB_USER_EMAIL --dry-run=client -o yaml | kubectl apply -f -
- kubectl get secrets gitlab-registry -o yaml
- echo "$CI_REGISTRY_IMAGE:$IMAGE_TAG"
- sed -i -e "s|<IMAGE_TAG>|$CI_REGISTRY_IMAGE:$IMAGE_TAG|g" k8s-deploy-config/k8s_deploy.yml
- sed -i -e "s|<PROXY_HOST>|$PROXY_HOST|g" k8s-deploy-config/k8s_deploy.yml
- kubectl apply -f k8s-deploy-config/k8s_deploy.yml
- kubectl rollout restart deployment/complex-ws-deployment
- kubectl get nodes
when: manual

hh-test-deploy:
extends: .kubernetes-deploy
needs: [ maven-build-test, docker-build-test ]
variables:
PROXY_HOST: hh-wwwcache.ebi.ac.uk
KUBE_CONTEXT: hh-intact-test
environment:
name: hh/test
deployment_tier: testing
url: http://hh-rke-wp-webadmin-99-worker-1.caas.ebi.ac.uk:31231/intact/complex-ws

hx-prod-deploy:
extends: .kubernetes-deploy
needs: [ maven-build-prod-hx, docker-build-prod-hx ]
variables:
PROXY_HOST: hx-wwwcache.ebi.ac.uk
KUBE_CONTEXT: hx-intact-prod
environment:
name: hx/prod
deployment_tier: production
url: http://hx-rke-wp-webadmin-78-worker-1.caas.ebi.ac.uk:31231/intact/complex-ws

hh-prod-deploy:
extends: .kubernetes-deploy
needs: [ maven-build-prod-hh, docker-build-prod-hh ]
variables:
PROXY_HOST: hh-wwwcache.ebi.ac.uk
KUBE_CONTEXT: hh-intact-prod
environment:
name: hh/prod
deployment_tier: production
url: http://hh-rke-wp-webadmin-102-worker-1.caas.ebi.ac.uk:31231/intact/complex-ws
7 changes: 7 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM tomcat:9-jdk11

ADD /target/complex-ws.war "/usr/local/tomcat/webapps/intact#complex-ws.war"
RUN cp -r webapps.dist/ROOT webapps/
RUN cp -r webapps.dist/manager webapps/

CMD ["catalina.sh", "run"]
68 changes: 68 additions & 0 deletions k8s-deploy-config/k8s_deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Specifies what version of K8s you want to use
apiVersion: v1
# A service is used to expose your Deployment to the external access
kind: Service
metadata:
name: complex-ws-service
spec:
ports:
- port: 31231
protocol: TCP
# The port which will be externally exposed. Must be in the range [30000, 32767].
nodePort: 31231
# The port on your Deployment which it will expose
targetPort: 8080
selector:
# Selects the disease-portal-client Deployment to attach the Service to
app: complex-ws
# Tell K8s this wants to expose an external port
type: NodePort
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: complex-ws-deployment
spec:
selector:
matchLabels:
app: complex-ws
replicas: 1
strategy:
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
type: RollingUpdate
template:
metadata:
labels:
app: complex-ws
spec:
terminationGracePeriodSeconds: 10
restartPolicy: Always
containers:
- name: complex-ws
# Pull the image which contains complex-ws webservice and the built assets from EBI's dockerhub
image: <IMAGE_TAG>
ports:
# We are using complex-ws webservice config which serves on port 8080
- containerPort: 8080
readinessProbe:
tcpSocket:
port: 8080
initialDelaySeconds: 5
periodSeconds: 10
livenessProbe:
tcpSocket:
port: 8080
initialDelaySeconds: 15
periodSeconds: 20
env:
- name: http_proxy
value: "http://<PROXY_HOST>:3128"
- name: https_proxy
value: "http://<PROXY_HOST>:3128"
- name: JAVA_OPTS
value: "-Dhttp.proxyHost=<PROXY_HOST> -Dhttp.proxyPort=3128 -Dhttps.proxyHost=<PROXY_HOST> -Dhttps.proxyPort=3128"
imagePullSecrets:
# Provided by GitLab, this allows K8s to connect to dockerhub.ebi.ac.uk
- name: gitlab-registry
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@
</dependencies>

<build>
<finalName>${project.artifactId}-${project.version}</finalName>
<finalName>${project.artifactId}</finalName>

<plugins>
<plugin>
Expand Down
56 changes: 56 additions & 0 deletions settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">

<profiles>
<profile>
<id>complex-ws</id>
<properties>
<mvn.db.user>${env.CI_POSTGRES_RO_USER}</mvn.db.user>
<mvn.db.password>${env.CI_POSTGRES_RO_PASS}</mvn.db.password>
<mvn.db.hbm2ddl>none</mvn.db.hbm2ddl>
<mvn.db.dialect>org.hibernate.dialect.PostgreSQL82Dialect</mvn.db.dialect>
<mvn.db.driver>org.postgresql.Driver</mvn.db.driver>
<mvn.solr.maxConnHost>32</mvn.solr.maxConnHost>
<mvn.solr.maxConnTotal>128</mvn.solr.maxConnTotal>
<mvn.solr.socketTimeOut>20000</mvn.solr.socketTimeOut>
<mvn.solr.connectionTimeOut>20000</mvn.solr.connectionTimeOut>
</properties>
</profile>
<profile>
<id>k8s-solr</id>
<properties>
<mvn.solr.url>http://tomcat-solr-service:8080/solr/core_complex_pub/</mvn.solr.url>
</properties>
</profile>
<profile>
<id>test</id>
<properties>
<mvn.db.url>jdbc:postgresql://pgsql-dlvm-085.ebi.ac.uk:5432/intacttst</mvn.db.url>
<mvn.intact.graph.ws.url>https://wwwdev.ebi.ac.uk/intact/ws/graph/</mvn.intact.graph.ws.url>
</properties>
</profile>
<profile>
<id>pub</id>
<properties>
<mvn.db.url>jdbc:postgresql://pgsql-dlvmpub2-014.ebi.ac.uk:5432/intactpub</mvn.db.url>
<mvn.intact.graph.ws.url>https://www.ebi.ac.uk/intact/ws/graph/</mvn.intact.graph.ws.url>
</properties>
</profile>
<profile>
<id>pub-fallback</id>
<properties>
<mvn.db.url>jdbc:postgresql://pgsql-dlvmpubfall2-011.ebi.ac.uk:5432/intactpub</mvn.db.url>
<mvn.intact.graph.ws.url>https://www.ebi.ac.uk/intact/ws/graph/</mvn.intact.graph.ws.url>
</properties>
</profile>
<profile>
<id>unit-tests</id>
<properties>
<mvn.solr.url>http://hh-rke-wp-webadmin-99-worker-1.caas.ebi.ac.uk:31236/solr//core_complex_pub/</mvn.solr.url>
<mvn.db.url>jdbc:postgresql://pgsql-dlvm-084.ebi.ac.uk:5432/intactdev</mvn.db.url>
</properties>
</profile>
</profiles>
</settings>
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
import uk.ac.ebi.intact.service.complex.ws.model.IntactProteinPairScoreDistribution;
import uk.ac.ebi.intact.service.complex.ws.utils.IntactComplexUtils;

import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.persistence.Query;
import java.io.IOException;
import java.net.URI;
Expand Down Expand Up @@ -57,9 +55,7 @@ public class ComplexCovariationManager {
private final String intactProteinScoresEndpointUrl;
private final String intactProteinScoreDistributionEndpointUrl;

public ComplexCovariationManager(IntactDao intactDao, @Value("${intact.graph.ws.url}") String intactGraphWsUrlProperty) {
String intactGraphWebServiceUrl = getIntactGraphWsUrl(intactGraphWsUrlProperty);

public ComplexCovariationManager(IntactDao intactDao, @Value("${intact.graph.ws.url}") String intactGraphWebServiceUrl) {
this.intactDao = intactDao;
this.client = HttpClient.newBuilder().version(HttpClient.Version.HTTP_1_1).build();
this.mapper = new ObjectMapper();
Expand Down Expand Up @@ -352,12 +348,4 @@ private static String encodeParams(Map<String, String> data) {
}
return "?" + sj;
}

private static String getIntactGraphWsUrl(String urlFromProperties) {
try {
return InitialContext.doLookup("java:comp/env/intact.graph.ws.url");
} catch (NamingException e) {
return urlFromProperties;
}
}
}
12 changes: 0 additions & 12 deletions src/main/resources/complex.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,6 @@ db.driver=${mvn.db.driver}
db.url=${mvn.db.url}
db.user=${mvn.db.user}
db.password=${mvn.db.password}
db.jndi=${mvn.db.intact.jndi}

# solr properties
solr.complex.url=${mvn.solr.complex.url}
solr.ontology.url=${mvn.solr.ontology.url}

# intact beans properties
intact.init.autoPersist=${mvn.intact.init.autoPersist}
intact.acprefix=${mvn.intact.acprefix}
intact.db.hbm2ddl=${mvn.intact.db.hbm2ddl}
intact.db.dialect=${mvn.intact.db.dialect}
ac.prefix=${mvn.intact.acprefix}

# web services
intact.graph.ws.url=${mvn.intact.graph.ws.url}
13 changes: 5 additions & 8 deletions src/main/webapp/WEB-INF/complex-ws-servlet.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,12 @@
</bean>

<!-- Intact core basic datasource -->
<bean id="jamiCoreDataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="java:comp/env/${db.jndi}"/>
<bean id="jamiCoreDataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="${db.driver}"/>
<property name="url" value="${db.url}"/>
<property name="username" value="${db.user}"/>
<property name="password" value="${db.password}"/>
</bean>
<!-- <bean id="jamiCoreDataSource" class="org.apache.commons.dbcp.BasicDataSource">-->
<!-- <property name="driverClassName" value="${db.driver}"/>-->
<!-- <property name="url" value="${db.url}"/>-->
<!-- <property name="username" value="${db.user}"/>-->
<!-- <property name="password" value="${db.password}"/>-->
<!-- </bean>-->

<!-- INTACT more specific beans -->
<bean id="jamiUserContext" class="uk.ac.ebi.intact.jami.context.UserContext" scope="prototype">
Expand Down
5 changes: 0 additions & 5 deletions src/main/webapp/WEB-INF/web.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,4 @@
<url-pattern>/</url-pattern>
</servlet-mapping>

<resource-env-ref>
<resource-env-ref-name>jdbc/IntactDS</resource-env-ref-name>
<resource-env-ref-type>javax.sql.DataSource</resource-env-ref-type>
</resource-env-ref>

</web-app>
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,8 @@ private ComplexDetails.ComplexDetailsBuilder expectedComplexDetailsBuilder(
.diseases(List.of())
.agonists(List.of())
.antagonists(List.of())
.comments(List.of());
.comments(List.of())
.releaseDates(List.of());
}

private IntactComplex buildComplex(
Expand Down