Skip to content

Commit

Permalink
Merge pull request #37 from ncats/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
jorgeso authored Jun 21, 2021
2 parents 33c91e5 + ea1e4aa commit 07d9161
Show file tree
Hide file tree
Showing 136 changed files with 612 additions and 13,310 deletions.
Binary file removed .DS_Store
Binary file not shown.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
.history/*

.DS_Store
.profraw
notebooks
notebooks/
env
Expand Down
30 changes: 30 additions & 0 deletions Dockerfile-ncats
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
FROM node:12 AS build

WORKDIR /opt/adme

COPY client ./

RUN npm install && npm install -g @angular/cli

# parameter for adme.ncats subdomain
RUN ng build --configuration production --deploy-url=/models/client/ --base-href=/models

FROM continuumio/miniconda:4.7.12

WORKDIR /opt/adme

COPY server ./

RUN conda env create -f environment.yml

ENV PATH /opt/conda/envs/ncats-adme/bin:$PATH

RUN chmod +x startup.sh

# clean existing client folder
RUN rm -rf client
COPY --from=build /opt/adme/dist/client client

CMD /bin/bash startup.sh

EXPOSE 5000
30 changes: 30 additions & 0 deletions Dockerfile-opendata
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
FROM node:12 AS build

WORKDIR /opt/adme

COPY client ./

RUN npm install && npm install -g @angular/cli

# build parameter for opendata subdomain
RUN ng build --configuration production --deploy-url=/adme/client/ --base-href=/adme

FROM continuumio/miniconda:4.7.12

WORKDIR /opt/adme

COPY server ./

RUN conda env create -f environment.yml

ENV PATH /opt/conda/envs/ncats-adme/bin:$PATH

RUN chmod +x startup.sh

# clean existing client folder
RUN rm -rf client
COPY --from=build /opt/adme/dist/client client

CMD /bin/bash startup.sh

EXPOSE 5000
63 changes: 63 additions & 0 deletions Jenkinsfile-ncats
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
pipeline {
options {
timestamps()
disableConcurrentBuilds()
}
parameters {
string(name: 'BUILD_VERSION', defaultValue: '', description: 'The build version to deploy (optional)')
}
agent {
label 'ncatsldvifx01'
}
triggers {
pollSCM('H/5 * * * *')
}
stages {
stage('Build Version') {
when {
expression {
return !params.BUILD_VERSION
}
}
steps{
script {
BUILD_VERSION_GENERATED = VersionNumber(
versionNumberString: 'v${BUILD_YEAR, XX}.${BUILD_MONTH, XX}${BUILD_DAY, XX}.${BUILDS_TODAY}',
projectStartDate: '1970-01-01',
skipFailedBuilds: true)
currentBuild.displayName = BUILD_VERSION_GENERATED
env.BUILD_VERSION = BUILD_VERSION_GENERATED
env.BUILD = 'true'
}
}
}
stage('Build') {
when {
expression {
// Skip build when a specific version is provided
return !params.BUILD_VERSION
}
}
steps {
sshagent (credentials: ['871f96b5-9d34-449d-b6c3-3a04bbd4c0e4']) {
sh 'git submodule update --init --recursive'
withEnv([
"BUILD_VERSION=" + (params.BUILD_VERSION ?: env.BUILD_VERSION)
]) {
script {
// build and push for ncats adme image
docker.withRegistry("https://registry.ncats.nih.gov:5000", "564b9230-c7e3-482d-b004-8e79e5e9720a") {
def image = docker.build(
"ncats-adme:${env.BUILD_VERSION}",
"-f Dockerfile-ncats --no-cache ."
)
// Push the image to the registry
image.push("${env.BUILD_VERSION}")
}
}
}
}
}
}
}
}
37 changes: 6 additions & 31 deletions server/Jenkinsfile → Jenkinsfile-opendata
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
pipeline {
options {
timestamps()
skipDefaultCheckout true
disableConcurrentBuilds()
}
parameters {
Expand Down Expand Up @@ -36,28 +35,7 @@ pipeline {
}
}
}
stage('Prepare') {
when {
expression {
// Skip build when a specific version is provided
return !params.BUILD_VERSION
}
}
steps {
sshagent (credentials: ['871f96b5-9d34-449d-b6c3-3a04bbd4c0e4']) {
checkout scm
sh 'git submodule update --init --recursive'
// milestone(1)
}
}
}
stage('Build') {
agent {
node {
label 'ncatsldvifx01'
customWorkspace "${env.WORKSPACE}/server"
}
}
when {
expression {
// Skip build when a specific version is provided
Expand All @@ -66,16 +44,16 @@ pipeline {
}
steps {
sshagent (credentials: ['871f96b5-9d34-449d-b6c3-3a04bbd4c0e4']) {
sh 'git submodule update --init --recursive'
withEnv([
"IMAGE_NAME=adme",
"BUILD_VERSION=" + (params.BUILD_VERSION ?: env.BUILD_VERSION)
]) {
script {
// See: https://jenkins.io/doc/book/pipeline/docker/#building-containers
// build and push for opendata adme image
docker.withRegistry("https://registry.ncats.nih.gov:5000", "564b9230-c7e3-482d-b004-8e79e5e9720a") {
def image = docker.build(
"${env.IMAGE_NAME}:${env.BUILD_VERSION}",
"--no-cache ."
"${env.IMAGE_NAME}:${env.BUILD_VERSION}", "-f Dockerfile-opendata --no-cache ."
)
// Push the image to the registry
image.push("${env.BUILD_VERSION}")
Expand All @@ -87,19 +65,16 @@ pipeline {
}
stage('deploy docker') {
agent {
node { label 'ncatsldvifx01'}
node { label 'ncatsldvifx01'}
}
steps {
configFileProvider([
configFile(fileId: 'adme-dev-compose', targetLocation: 'docker-compose.yml'),
configFile(fileId: 'config.json', targetLocation: 'config.json')
]) {
sh """
chmod 755 config.json
"""
script {
script {
def docker = new org.labshare.Docker()
docker.deployDockerUI()
docker.deployDockerAPI()
}
}
}
Expand Down
27 changes: 0 additions & 27 deletions client/angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,33 +61,6 @@
}
]
},
"adme": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.adme.prod.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"namedChunks": false,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "6kb",
"maximumError": "10kb"
}
]
},
"dev": {
"fileReplacements": [
{
Expand Down
4 changes: 2 additions & 2 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"ng": "ng",
"start:dev": "ng serve --configuration=dev",
"build": "ng build",
"build:embedded:adme": "ng build --configuration=adme --deploy-url=/adme/client/ --base-href=/adme/ && rimraf ../server/client && cpx \"dist/client/**/*\" ../server/client -u",
"build:embedded": "ng build --prod --deploy-url=/client/ && rimraf ../server/client && cpx \"dist/client/**/*\" ../server/client -u",
"build:embedded:adme": "ng build --deploy-url=/adme/client/ --base-href=/adme/ && rimraf ../server/client && cpx \"dist/client/**/*\" ../server/client -u",
"build:embedded": "ng build --prod --deploy-url=/client/ --base-href=/ && rimraf ../server/client && cpx \"dist/client/**/*\" ../server/client -u",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
Expand Down
3 changes: 2 additions & 1 deletion client/src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
<a class="nav-item" [matMenuTriggerFor]="navMenu" >Models</a>
<mat-menu #navMenu="matMenu">
<button mat-menu-item routerLink="/models/rlm">RLM</button>
<button mat-menu-item routerLink="/models/pampa">PAMPA</button>
<button mat-menu-item routerLink="/models/pampa_ph74">PAMPA pH 7.4</button>
<button mat-menu-item routerLink="/models/pampa_ph5">PAMPA pH 5.0</button>
<button mat-menu-item routerLink="/models/solubility">Solubility</button>
<button mat-menu-item routerLink="/models/cyp450">CYP450</button>
</mat-menu>
Expand Down
10 changes: 6 additions & 4 deletions client/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ import { MatIconRegistry } from '@angular/material/icon';
import { DomSanitizer } from '@angular/platform-browser';
import { ResolveEnd, Router, RouterEvent } from '@angular/router';
import { Subscription } from 'rxjs';
import { environment } from 'src/environments/environment';
import { GoogleAnalyticsService } from './google-analytics/google-analytics.service';
import { DOCUMENT } from '@angular/common';
import { APP_BASE_HREF } from '@angular/common';
import { DEPLOY_URL } from './utilities/deploy-url';

@Component({
selector: 'adme-root',
Expand All @@ -20,14 +21,15 @@ export class AppComponent implements OnInit, OnDestroy {
private router: Router,
private gaService: GoogleAnalyticsService,
// tslint:disable-next-line:variable-name
@Inject(DOCUMENT) private _document: HTMLDocument
@Inject(DOCUMENT) private _document: HTMLDocument,
@Inject(DEPLOY_URL) private deployUrl: string
) {
iconRegistry.addSvgIcon(
'cancel',
sanitizer.bypassSecurityTrustResourceUrl(`${environment.baseHref}assets/icons/cancel-24px.svg`));
sanitizer.bypassSecurityTrustResourceUrl(`${deployUrl}assets/icons/cancel-24px.svg`));
}
ngOnInit() {
this._document.getElementById('appFavicon').setAttribute('href', `${environment.baseHref}assets/icons/favicon.ico`);
this._document.getElementById('appFavicon').setAttribute('href', `${this.deployUrl}assets/icons/favicon.ico`);
this.routerSubscription = this.router.events.subscribe((event: RouterEvent) => {
if (event instanceof ResolveEnd) {
this.gaService.sendPageView(event.state.root.firstChild.data.pageTitle, event.state.url);
Expand Down
6 changes: 6 additions & 0 deletions client/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import { ConfigService } from './config/config.service';
import { configServiceFactory } from './config/config.factory';
import { TrackLinkEventDirective } from './google-analytics/track-link-event/track-link-event.directive';
import { MatMenuModule } from '@angular/material/menu';
import { APP_BASE_HREF, PlatformLocation } from '@angular/common';

@NgModule({
declarations: [
Expand Down Expand Up @@ -88,6 +89,11 @@ import { MatMenuModule } from '@angular/material/menu';
useFactory: configServiceFactory,
deps: [ConfigService],
multi: true
},
{
provide: APP_BASE_HREF,
useFactory: (s: PlatformLocation) => s.getBaseHrefFromDOM(),
deps: [PlatformLocation]
}
],
bootstrap: [AppComponent]
Expand Down
13 changes: 9 additions & 4 deletions client/src/app/config/config.service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { Injectable } from '@angular/core';
import { Injectable, Inject } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Config } from './config.model';
import { environment } from 'src/environments/environment';
import { APP_BASE_HREF } from '@angular/common';
import { DEPLOY_URL } from '../utilities/deploy-url';

@Injectable({
providedIn: 'root'
Expand All @@ -10,15 +12,18 @@ export class ConfigService {
// tslint:disable-next-line:variable-name
private _configData: Config;

constructor(private http: HttpClient) { }
constructor(
private http: HttpClient,
@Inject(APP_BASE_HREF) public baseHref: string,
@Inject(DEPLOY_URL) private deployUrl: string
) { }

// This is the method you want to call at bootstrap
// Important: It should return a Promise
load(): Promise<any> {
this._configData = null;

const configFilePath = environment.configFileLocation ?
environment.configFileLocation : `${environment.baseHref || '/'}assets/data/config.json`;
environment.configFileLocation : `${this.deployUrl || '/'}assets/data/config.json`;

return this.http
.get(configFilePath)
Expand Down
29 changes: 15 additions & 14 deletions client/src/app/contact/contact.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component, OnInit } from '@angular/core';
import { Component, OnInit, Inject } from '@angular/core';
import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser';
import { environment } from 'src/environments/environment';
import { DEPLOY_URL } from '../utilities/deploy-url';

@Component({
selector: 'adme-contact',
Expand All @@ -21,20 +21,21 @@ export class ContactComponent implements OnInit {
epamImgSrc: SafeResourceUrl;

constructor(
private domSanatizer: DomSanitizer
private domSanatizer: DomSanitizer,
@Inject(DEPLOY_URL) public deployUrl: string
) {
this.vishalImgSrc = domSanatizer.bypassSecurityTrustResourceUrl(`${environment.baseHref}assets/profile_images/siramshettyv2.jpg`);
this.pranavImgSrc = domSanatizer.bypassSecurityTrustResourceUrl(`${environment.baseHref}assets/profile_images/shahpa2.png`);
this.jorgeImgSrc = domSanatizer.bypassSecurityTrustResourceUrl(`${environment.baseHref}assets/profile_images/neyraj2.jpg`);
this.jordanImgSrc = domSanatizer.bypassSecurityTrustResourceUrl(`${environment.baseHref}assets/profile_images/williamsjos.jpg`);
this.noelImgSrc = domSanatizer.bypassSecurityTrustResourceUrl(`${environment.baseHref}assets/profile_images/southalln.jpg`);
this.trungImgSrc = domSanatizer.bypassSecurityTrustResourceUrl(`${environment.baseHref}assets/profile_images/nguyenda.png`);
this.xinImgSrc = domSanatizer.bypassSecurityTrustResourceUrl(`${environment.baseHref}assets/profile_images/xux7.jpg`);
this.vishalImgSrc = domSanatizer.bypassSecurityTrustResourceUrl(`${this.deployUrl}assets/profile_images/siramshettyv2.jpg`);
this.pranavImgSrc = domSanatizer.bypassSecurityTrustResourceUrl(`${this.deployUrl}assets/profile_images/shahpa2.png`);
this.jorgeImgSrc = domSanatizer.bypassSecurityTrustResourceUrl(`${this.deployUrl}assets/profile_images/neyraj2.jpg`);
this.jordanImgSrc = domSanatizer.bypassSecurityTrustResourceUrl(`${this.deployUrl}assets/profile_images/williamsjos.jpg`);
this.noelImgSrc = domSanatizer.bypassSecurityTrustResourceUrl(`${this.deployUrl}assets/profile_images/southalln.jpg`);
this.trungImgSrc = domSanatizer.bypassSecurityTrustResourceUrl(`${this.deployUrl}assets/profile_images/nguyenda.png`);
this.xinImgSrc = domSanatizer.bypassSecurityTrustResourceUrl(`${this.deployUrl}assets/profile_images/xux7.jpg`);

this.rdkitImgSrc = domSanatizer.bypassSecurityTrustResourceUrl(`${environment.baseHref}assets/images/rdkit.png`);
this.pythonImgSrc = domSanatizer.bypassSecurityTrustResourceUrl(`${environment.baseHref}assets/images/python.png`);
this.angularImgSrc = domSanatizer.bypassSecurityTrustResourceUrl(`${environment.baseHref}assets/images/angular.png`);
this.epamImgSrc = domSanatizer.bypassSecurityTrustResourceUrl(`${environment.baseHref}assets/images/epam_ketcher.png`);
this.rdkitImgSrc = domSanatizer.bypassSecurityTrustResourceUrl(`${this.deployUrl}assets/images/rdkit.png`);
this.pythonImgSrc = domSanatizer.bypassSecurityTrustResourceUrl(`${this.deployUrl}assets/images/python.png`);
this.angularImgSrc = domSanatizer.bypassSecurityTrustResourceUrl(`${this.deployUrl}assets/images/angular.png`);
this.epamImgSrc = domSanatizer.bypassSecurityTrustResourceUrl(`${this.deployUrl}assets/images/epam_ketcher.png`);
}

ngOnInit(): void {
Expand Down
Loading

0 comments on commit 07d9161

Please sign in to comment.