Skip to content
Closed
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
8 changes: 4 additions & 4 deletions .github/workflows/ebrains.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Mirror to Ebrains

on:
push:
branches: [ master ]
branches: [master]
tags:
- '*'
- "*"

jobs:
to_ebrains:
Expand All @@ -13,14 +13,14 @@ jobs:
- name: syncmaster
uses: wei/git-sync@v3
with:
source_repo: "HBPMedical/portal-backend"
source_repo: "HBPMedical/platform-backend"
source_branch: "master"
destination_repo: "https://ghpusher:${{ secrets.EBRAINS_GITLAB_ACCESS_TOKEN }}@gitlab.ebrains.eu/hbp-mip/portal-backend.git"
destination_branch: "master"
- name: synctags
uses: wei/git-sync@v3
with:
source_repo: "HBPMedical/portal-backend"
source_repo: "HBPMedical/platform-backend"
source_branch: "refs/tags/*"
destination_repo: "https://ghpusher:${{ secrets.EBRAINS_GITLAB_ACCESS_TOKEN }}@gitlab.ebrains.eu/hbp-mip/portal-backend.git"
destination_branch: "refs/tags/*"
11 changes: 5 additions & 6 deletions .github/workflows/publish_images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ jobs:
uses: docker/metadata-action@v4
with:
images: |
hbpmip/portal-backend
docker-registry.ebrains.eu/medical-informatics-platform/portal-backend
hbpmip/platform-backend
docker-registry.ebrains.eu/medical-informatics-platform/platform-backend

- name: Load cached image
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache/portal-backend
path: /tmp/.buildx-cache/platform-backend
key: buildx-backend
restore-keys: buildx-backend

Expand All @@ -50,8 +50,8 @@ jobs:
file: ./Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=local,src=/tmp/.buildx-cache/portal-backend
cache-to: type=local,dest=/tmp/.buildx-cache-new/portal-backend
cache-from: type=local,src=/tmp/.buildx-cache/platform-backend
cache-to: type=local,dest=/tmp/.buildx-cache-new/platform-backend

# Temp fix
# https://github.com/docker/build-push-action/issues/252
Expand All @@ -60,4 +60,3 @@ jobs:
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache

48 changes: 0 additions & 48 deletions .github/workflows/publish_testing_images.yml

This file was deleted.

25 changes: 13 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@
# Build the spring boot maven project
#######################################################
FROM maven:3.9.3-amazoncorretto-17 AS mvn-build-env
MAINTAINER Thanasis Karampatsis <[email protected]>
LABEL maintainer="Thanasis Karampatsis <[email protected]>"

ENV CODE_PATH="/opt/code"
WORKDIR $CODE_PATH

COPY pom.xml $CODE_PATH
COPY pom.xml $CODE_PATH/

RUN mvn clean compile test
# Pre-fetch dependencies first to improve build cache efficiency.
RUN mvn -B -ntp dependency:go-offline

COPY src/ $CODE_PATH/src

RUN mvn clean package
RUN mvn -B -ntp clean package

#######################################################
# Setup the running container
Expand All @@ -33,7 +34,7 @@ ENV APP_CONFIG_TEMPLATE="/opt/config/application.tmpl"
ENV APP_CONFIG_LOCATION="/opt/config/application.yml"
ENV SPRING_CONFIG_LOCATION="file:/opt/config/application.yml"

ENV SERVICE="portal-backend"
ENV SERVICE="platform-backend"
ENV FEDERATION="default"
ENV LOG_LEVEL="INFO"
ENV FRAMEWORK_LOG_LEVEL="INFO"
Expand All @@ -54,18 +55,18 @@ RUN wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSI
#######################################################
# Prepare the spring boot application files
#######################################################
COPY /config/application.tmpl $APP_CONFIG_TEMPLATE
COPY --from=mvn-build-env /opt/code/target/portal-backend.jar /usr/share/jars/
COPY config/application.tmpl $APP_CONFIG_TEMPLATE
COPY --from=mvn-build-env /opt/code/target/platform-backend.jar /usr/share/jars/


#######################################################
# Configuration for the backend config files
#######################################################
ENV DISABLED_ALGORITHMS_CONFIG_PATH="/opt/portal/algorithms/disabledAlgorithms.json"
COPY /config/disabledAlgorithms.json $DISABLED_ALGORITHMS_CONFIG_PATH
VOLUME /opt/portal/api
ENV DISABLED_ALGORITHMS_CONFIG_PATH="/opt/platform/algorithms/disabledAlgorithms.json"
COPY config/disabledAlgorithms.json $DISABLED_ALGORITHMS_CONFIG_PATH
VOLUME /opt/platform/api


ENTRYPOINT ["sh", "-c", "dockerize -template $APP_CONFIG_TEMPLATE:$APP_CONFIG_LOCATION java -Daeron.term.buffer.length -jar /usr/share/jars/portal-backend.jar"]
ENTRYPOINT ["sh", "-ec", "exec dockerize -template ${APP_CONFIG_TEMPLATE}:${APP_CONFIG_LOCATION} java -Daeron.term.buffer.length -jar /usr/share/jars/platform-backend.jar"]
EXPOSE 8080
HEALTHCHECK --start-period=60s CMD curl -v --silent http://localhost:8080/services/actuator/health 2>&1 | grep UP
HEALTHCHECK --start-period=60s CMD curl --fail --silent --show-error http://localhost:8080/services/actuator/health | grep -q '"status":"UP"'
17 changes: 8 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[![CHUV](https://img.shields.io/badge/CHUV-LREN-AF4C64.svg)](https://www.unil.ch/lren/en/home.html) [![License](https://img.shields.io/badge/license-AGPL--3.0-blue.svg)](https://www.gnu.org/licenses/agpl-3.0.html)
[![DockerHub](https://img.shields.io/badge/docker-hbpmip%2Fportal--backend-008bb8.svg)](https://hub.docker.com/r/hbpmip/portal-backend/)
[![DockerHub](https://img.shields.io/badge/docker-hbpmip%2Fplatform--backend-008bb8.svg)](https://hub.docker.com/r/hbpmip/platform-backend/)

# Backend for the MIP portal
# Backend for the MIP platform

## DEV Deployment
To run the backend using an IDE for development, such as IntelliJ, you need a running instance of PostgreSQL.

## Deployment (using a Docker image)
Build the image: `docker build -t hbpmip/portal-backend:testing .`
Build the image: `docker build -t hbpmip/platform-backend:testing .`

To use this image, you need a running instance of PostgreSQL and to configure the software using the following environment variables.

Expand All @@ -19,14 +19,13 @@ To use this image, you need a running instance of PostgreSQL and to configure th
* AUTHENTICATION: true for production, false for development.

#### DATABASE CONFIGURATION ###
* PORTAL_DB_URL: JDBC URL to connect to the portal database, default value is "jdbc:postgresql://127.0.0.1:5432/portal".
* PORTAL_DB_SCHEMA: Database schema, default value is "public".
* PORTAL_DB_USER: User to use when connecting to the portal database, default value is "postgres".
* PORTAL_DB_PASSWORD: Password to use when connecting to the portal database.
* PLATFORM_DB_URL: JDBC URL to connect to the platform database, default value is "jdbc:postgresql://127.0.0.1:5432/platform".
* PLATFORM_DB_SCHEMA: Database schema, default value is "public".
* PLATFORM_DB_USER: User to use when connecting to the platform database, default value is "postgres".
* PLATFORM_DB_PASSWORD: Password to use when connecting to the platform database.

#### EXTERNAL SERVICES ###
* EXAREME_URL: URL to Exareme server. Default is "http://localhost:9090" .
* EXAREME2_URL: URL to Exareme2 server. Default is "http://localhost:5000" .
* EXAFLOW_URL: URL to Exaflow server. Default is "http://localhost:5000" .

#### KEYCLOAK ###
* KEYCLOAK_AUTH_URL: Keycloak authentication URL.
Expand Down
27 changes: 17 additions & 10 deletions config/application.tmpl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Configuration template for the portal running inside a Docker container
# Configuration template for the platform running inside a Docker container


### EMBEDDED SERVER CONFIGURATION ###
Expand All @@ -12,9 +12,9 @@ server:
### DATABASE CONFIGURATION ###
spring:
datasource:
url: {{ default .Env.PORTAL_DB_URL "jdbc:postgresql://172.17.0.1:5433/portal" }}
username: {{ default .Env.PORTAL_DB_USER "portal" }}
password: {{ default .Env.PORTAL_DB_PASSWORD "portalpwd" }}
url: {{ default .Env.PLATFORM_DB_URL "jdbc:postgresql://172.17.0.1:5433/portal" }}
username: {{ default .Env.PLATFORM_DB_USER "portal" }}
password: {{ default .Env.PLATFORM_DB_PASSWORD "portalpwd" }}
driver-class-name: org.postgresql.Driver
data:
jpa:
Expand Down Expand Up @@ -42,6 +42,10 @@ spring:
keycloak:
issuer-uri: {{ .Env.KEYCLOAK_AUTH_URL }}realms/{{ .Env.KEYCLOAK_REALM }}
user-name-attribute: preferred_username
# Allow API clients (e.g. notebooks) to authenticate with Bearer JWTs.
resourceserver:
jwt:
issuer-uri: {{ .Env.KEYCLOAK_AUTH_URL }}realms/{{ .Env.KEYCLOAK_REALM }}


### AUTHENTICATION ###
Expand All @@ -55,15 +59,18 @@ authentication:
### EXTERNAL SERVICES ###
services:
algorithmsUpdateInterval: {{ .Env.ALGORITHM_UPDATE_INTERVAL}}
exareme2:
algorithmsUrl: {{ .Env.EXAREME2_URL}}/algorithms
attributesUrl: {{ .Env.EXAREME2_URL}}/data_models_attributes
cdesMetadataUrl: {{ .Env.EXAREME2_URL}}/cdes_metadata
datasets_variables: {{ .Env.EXAREME2_URL}}/datasets_variables
exaflow:
algorithmsUrl: {{ .Env.EXAFLOW_URL}}/algorithms
attributesUrl: {{ .Env.EXAFLOW_URL}}/data_models_attributes
cdesMetadataUrl: {{ .Env.EXAFLOW_URL}}/cdes_metadata
datasets_variables: {{ .Env.EXAFLOW_URL}}/datasets_variables


### EXTERNAL FILES ###
# Files are imported when building the docker image
files:
pathologies_json: "file:/opt/portal/api/pathologies.json"
disabledAlgorithms_json: "file:{{ .Env.DISABLED_ALGORITHMS_CONFIG_PATH}}"


frontend:
base-url: {{ .Env.FRONTEND_BASE_URL }}
17 changes: 9 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<name>portal-backend</name>
<description>Medical Informatics Platform - portal-backend</description>
<name>platform-backend</name>
<description>Medical Informatics Platform - platform-backend</description>
<groupId>hbp.mip</groupId>
<artifactId>portal-backend</artifactId>
<artifactId>platform-backend</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>

Expand All @@ -19,27 +19,24 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>17</java.version>
<spring-context.version>6.1.20</spring-context.version>
<postgresql.version>42.6.1</postgresql.version>
<jakarta.version>3.1.0</jakarta.version>
<hibernate.version>6.2.7.Final</hibernate.version>
<flyway-core.version>4.2.0</flyway-core.version>
<gson.version>2.10.1</gson.version>
<commons-dbcp.version>2.9.0</commons-dbcp.version>
<springdoc-openapi-starter-webmvc-ui.version>2.1.0</springdoc-openapi-starter-webmvc-ui.version>
<lombok.version>1.18.28</lombok.version>
<lombok.version>1.18.34</lombok.version>
</properties>

<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>${spring-context.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring-context.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
Expand Down Expand Up @@ -71,6 +68,10 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-oauth2-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-oauth2-resource-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-commons</artifactId>
Expand Down Expand Up @@ -122,7 +123,7 @@
</dependencies>

<build>
<finalName>portal-backend</finalName>
<finalName>platform-backend</finalName>
<resources>
<resource>
<directory>src/main/resources</directory>
Expand Down
31 changes: 31 additions & 0 deletions src/main/java/hbp/mip/algorithm/AlgorithmRequestDTO.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package hbp.mip.algorithm;

import hbp.mip.experiment.ExperimentExecutionDTO;
import lombok.extern.slf4j.Slf4j;

import java.util.*;

@Slf4j
public record AlgorithmRequestDTO(
String request_id,
InputDataRequestDTO inputdata,
Map<String, Object> parameters,
Map<String, Object> preprocessing
) {

public static AlgorithmRequestDTO create(UUID experimentUUID,ExperimentExecutionDTO.AlgorithmExecutionDTO algorithmExecutionDTO){
return new AlgorithmRequestDTO(
experimentUUID.toString(),
algorithmExecutionDTO.inputdata(),
algorithmExecutionDTO.parameters(),
algorithmExecutionDTO.preprocessing()
);
}

public record InputDataRequestDTO(String data_model, List<String> datasets, List<String> x, List<String> y,
FilterRequestDTO filters) {
}

public record FilterRequestDTO(String condition, List<Object> rules) {
}
}
Loading
Loading