This commit is contained in:
apapachristou 2020-09-24 20:28:08 +03:00
commit 794ef0142a
7 changed files with 158 additions and 5 deletions

66
Jenkinsfile vendored Normal file
View File

@ -0,0 +1,66 @@
def pipelineContext = [:]
pipeline {
agent any
options {
skipDefaultCheckout(true)
}
stages {
stage('Checkout') {
steps {
checkout scm
}
}
stage('Build API') {
steps {
script {
pipelineContext.apiImage = docker.build("open-dmp-api:${env.BUILD_ID}", "-f dmp-backend/Dockerfile.CI dmp-backend/")
}
}
}
stage('Build WebApp') {
steps {
script {
pipelineContext.webappImage = docker.build("open-dmp-webapp:${env.BUILD_ID}", "-f dmp-frontend/Dockerfile.CI dmp-frontend/")
}
}
}
//stage('SonarQube analysis') {
// steps {
// script {
// def scannerHome = tool 'SonarQube Scanner 4.3';
// withSonarQubeEnv('SonarQube') { // If you have configured more than one global server connection, you can specify its name
// sh "${scannerHome}/bin/sonar-scanner"
// }
// }
// }
//}
//// waiting for sonar results based into the configured web hook in Sonar server which push the status back to jenkins
//stage('SonarQube scan result check') {
// steps {
// timeout(time: 2, unit: 'MINUTES') {
// retry(3) {
// script {
// def qg = waitForQualityGate()
// if (qg.status != 'OK') {
// error "Pipeline aborted due to quality gate failure: ${qg.status}"
// }
// }
// }
// }
// }
//}
stage('Pushing to Docker Registry') {
steps {
script {
docker.withRegistry('http://drepo.local.cite.gr', 'b2c651c1-9a3b-4a98-a6da-e1dd7a20f512') {
pipelineContext.apiImage.push()
pipelineContext.webappImage.push()
}
}
}
}
}
}

15
dmp-backend/Dockerfile.CI Normal file
View File

@ -0,0 +1,15 @@
FROM maven:3-jdk-8-alpine AS MAVEN_BUILD
COPY pom.xml /build/
COPY data /build/data/
COPY elastic /build/elastic/
COPY queryable /build/queryable/
COPY web /build/web/
WORKDIR /build/
RUN mvn package
FROM openjdk:8-jre-alpine
WORKDIR /app
COPY --from=MAVEN_BUILD /build/web/target/web-1.0-SNAPSHOT.jar /app/app.jar
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom" ,"-Dspring.profiles.active=${PROF}","-jar","/app.jar"]

View File

@ -173,8 +173,12 @@ public class DMPs extends BaseController {
@RequestMapping(method = RequestMethod.GET, value = {"rda/{id}"})
public @ResponseBody
ResponseEntity getRDAJsonDocument(@PathVariable String id, @ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal) throws IOException {
ResponseEntity getRDAJsonDocument(@PathVariable String id, @ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal) {
try {
return this.dataManagementPlanManager.getRDAJsonDocument(id, datasetManager, principal);
} catch (Exception e) {
return ResponseEntity.status(HttpStatus.EXPECTATION_FAILED).body(new ResponseItem<>().message(e.getMessage()).status(ApiMessageCode.ERROR_MESSAGE));
}
}
@RequestMapping(method = RequestMethod.GET, value = {"/getPDF/{id}"})

View File

@ -0,0 +1,31 @@
# stage1 as builder
FROM node:12-alpine as builder
# copy the package.json to install dependencies
COPY package.json ./
# Install the dependencies and make the folder
RUN npm install && mkdir /src && mv ./node_modules ./src
WORKDIR /src
COPY . .
# Build the project and copy the files
RUN npm run ng build -- --deploy-url=/ --prod
FROM nginx:alpine
#!/bin/sh
COPY nginx.conf.CI /etc/nginx/nginx.conf
## Remove default nginx index page
RUN rm -rf /usr/share/nginx/html/*
# Copy from the stahg 1
COPY --from=builder /src/dist /usr/share/nginx/html
EXPOSE 8080
ENTRYPOINT ["nginx", "-g", "daemon off;"]

View File

@ -0,0 +1,28 @@
server {
listen 8080;
sendfile on;
default_type application/octet-stream;
gzip on;
gzip_http_version 1.1;
gzip_disable "MSIE [1-6]\.";
gzip_min_length 1100;
gzip_vary on;
gzip_proxied expired no-cache no-store private auth;
gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript;
gzip_comp_level 9;
root /usr/share/nginx/html;
location / {
try_files $uri $uri/ /index.html =404;
add_header Cache-Control "no-store, no-cache, must-revalidate";
}
}

View File

@ -353,11 +353,19 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
downloadJson(id: string) {
this.dmpService.downloadJson(id)
.pipe(takeUntil(this._destroyed))
.subscribe(response => {
const blob = new Blob([response.body], { type: 'application/json' });
const filename = this.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition'));
.subscribe(complete => {
const blob = new Blob([complete.body], { type: 'application/json' });
const filename = this.getFilenameFromContentDispositionHeader(complete.headers.get('Content-Disposition'));
FileSaver.saveAs(blob, filename);
})
}, async error => {
this.onExportCallbackError(error);
});
}
async onExportCallbackError(error: any) {
const errorJsonText = await error.error.text();
const errorObj = JSON.parse(errorJsonText);
this.uiNotificationService.snackBarNotification(errorObj.message, SnackBarNotificationLevel.Error);
}
getFilenameFromContentDispositionHeader(header: string): string {

View File

@ -10,6 +10,7 @@
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"importHelpers": true,
"skipLibCheck": true,
"target": "es2015",
"typeRoots": [
"node_modules/@types"