Commit d7537cfa authored by rajkumar's avatar rajkumar
Browse files

Merge master branch and remotes/origin/ENA-3858-merge-k8-change-3 into K8-master

# Conflicts:
#	build.gradle
#	frontend/package-lock.json
#	src/app/submission-result-dialog/submission-result-dialog.component.spec.ts
#	src/main/resources/static/index.html
parents bdc097d0 606887e7
node_modules
dist
.git
.gitignore
# Created by .ignore support plugin (hsz.mobi)
### JetBrains template
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
.gradle
# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf
# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml
# compiled output
/dist
/dist-server
/tmp
/out-tsc
# Gradle
.idea/**/gradle.xml
.idea/**/libraries
# dependencies
/node_modules
# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/modules.xml
#.idea/*.iml
.idea/modules
# CMake
cmake-build-*/
# Mongo Explorer plugin
.idea/**/mongoSettings.xml
# File-based project format
# IDEs and editors
/.idea
.project
.classpath
.settings
*.iws
*.iml
*.ipr
# misc
/.sass-cache
/connect.lock
/coverage
/libpeerconnection.log
npm-debug.log
testem.log
/typings
# e2e
/e2e/*.js
/e2e/*.map
# System Files
.DS_Store
Thumbs.db
# IntelliJ
out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Cursive Clojure plugin
.idea/replstate.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
# Editor-based Rest Client
.idea/httpRequests
/.idea/modules/
.gradle/
.idea/modules.xml
.idea/vcs.xml
.idea/misc.xml
.idea/google-java-format.xml
.idea/encodings.xml
frontend/.vscode/settings.json
image: docker:latest
services:
- docker:dind
before_script:
- export KUBECONFIG=./Kubernetes-cluster.yaml
variables:
DOCKER_DRIVER: overlay
DOCKER_TLS_CERTDIR: ""
stages:
- package
- deploy
docker-build-dev:
stage: package
only:
- /^dev-.*$/
except:
- branches
- triggers
script:
- docker login $CI_REGISTRY -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD
- docker build -t $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG --build-arg configuration=dev .
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG
docker-build-test:
stage: package
only:
- /^test-.*$/
except:
- branches
- triggers
script:
- docker login $CI_REGISTRY -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD
- docker build -t $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG --build-arg configuration=test .
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG
docker-build-prod:
stage: package
only:
refs:
- master
- tags
variables:
- $CI_COMMIT_BRANCH == "master"
script:
- docker login $CI_REGISTRY -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD
- docker build -t $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG --build-arg configuration=production .
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG
k8s-deploy-dev:
image: dtzar/helm-kubectl
stage: deploy
only:
- /^dev-.*$/
except:
- branches
- triggers
script:
- sed -i s#%DOCKER_IMAGE%#$CI_REGISTRY_IMAGE\:$CI_COMMIT_TAG#g Kubernetes-dev-deploy.yaml
- kubectl delete secret gitlab --namespace=ena-dev
- kubectl create secret docker-registry gitlab --docker-server=$CI_REGISTRY --docker-username=$DOCKER_USER --docker-password=$DOCKER_PASSWORD --docker-email=$DOCKER_EMAIL --namespace=ena-dev
- kubectl apply -f Kubernetes-dev-deploy.yaml --namespace=ena-dev
k8s-deploy-test:
image: dtzar/helm-kubectl
stage: deploy
only:
- /^test-.*$/
except:
- branches
- triggers
script:
- sed -i s#%DOCKER_IMAGE%#$CI_REGISTRY_IMAGE\:$CI_COMMIT_TAG#g Kubernetes-test-deploy.yaml
- kubectl delete secret gitlab --namespace=ena-test
- kubectl create secret docker-registry gitlab --docker-server=$CI_REGISTRY --docker-username=$DOCKER_USER --docker-password=$DOCKER_PASSWORD --docker-email=$DOCKER_EMAIL --namespace=ena-test
- kubectl apply -f Kubernetes-test-deploy.yaml --namespace=ena-test
k8s-deploy-prod:
image: dtzar/helm-kubectl
stage: deploy
only:
refs:
- master
- tags
variables:
- $CI_COMMIT_BRANCH == "master"
script:
- sed -i s#%DOCKER_IMAGE%#$CI_REGISTRY_IMAGE\:$CI_COMMIT_TAG#g Kubernetes-prod-deploy.yaml
- kubectl delete secret gitlab --namespace=ena-prod
- kubectl create secret docker-registry gitlab --docker-server=$CI_REGISTRY --docker-username=$DOCKER_USER --docker-password=$DOCKER_PASSWORD --docker-email=$DOCKER_EMAIL --namespace=ena-prod
- kubectl apply -f Kubernetes-prod-deploy.yaml --namespace=ena-prod
......@@ -4,6 +4,8 @@
<bytecodeTargetLevel>
<module name="uk.ac.ebi.ena.webin-portal.webin-portal.main" target="1.8" />
<module name="uk.ac.ebi.ena.webin-portal.webin-portal.test" target="1.8" />
<module name="webin-portal.main" target="1.8" />
<module name="webin-portal.test" target="1.8" />
<module name="webin-portal_main" target="1.8" />
<module name="webin-portal_test" target="1.8" />
</bytecodeTargetLevel>
......
### STAGE 1: Build ###
FROM node:12.7-alpine AS build
WORKDIR /usr/src/app
COPY package.json package-lock.json ./
RUN npm install
COPY . .
ARG configuration
RUN npm run build -- --configuration $configuration
### STAGE 2: Run ###
FROM nginx:1.17.1-alpine
COPY nginx.conf /etc/nginx/nginx.conf
COPY --from=build /usr/src/app/dist/webin-portal /usr/share/nginx/html
COPY --from=build /usr/src/app/dist/webin-portal /usr/share/nginx/html/ena/submit/webin
apiV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NCV25rdnBBcDdWQmxUdUI0UHp0RVYzSzdLUXp4QU5aCkk3aXI2K2FHeHN1U0FBVkxvTmJmSlo1ZHRZT1J0UWxNMEU4MUhvZk1XT0xKeGZjUjVGdGVHbnVmdCtwV1dubU0KQjhBYlpMYUhxYURndkpkTlFqaFArVjhJUmpkWVBPRGE1SDdLbWFSQ0lvbVVaOHMwVXhiakovTFJiUmVOb3E1bwo2S0k3VWwraDk0VlFIRlpjR2xFSXBRU0NQTW14eHdZRDh2VXlERlg1cWpMOC9Ta3ZDaDQ9Ci0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K
server: https://hx-wp-webadmin-17.wp-k8s.ebi.ac.uk:30030
name: hx-wp-webadmin-17
contexts:
- context:
cluster: hx-wp-webadmin-17
user: team-admin-hx-wp-webadmin-17
name: team-admin-hx-wp-webadmin-17
current-context: team-admin-hx-wp-webadmin-17
kind: Config
preferences: {}
users:
- name: team-admin-hx-wp-webadmin-17
user:
token: eyJhbGciOiJSUzI1NiIsImtpZCI6IiJ9.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJkZWZhdWx0Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZWNyZXQubmFtZSI6InRlYW0tYWRtaW4tdG9rZW4tbW52azgiLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC5uYW1lIjoidGVhbS1hZG1pbiIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VydmljZS1hY2NvdW50LnVpZCI6Ijc1ZDI2OTE5LTVjMDItNDFhNC1iNDliLWUzNmVlYjdkODMyOSIsInN1YiI6InN5c3RlbTpzZXJ2aWNlYWNjb3VudDpkZWZhdWx0OnRlYW0tYWRtaW4ifQ.XffZYtJjxdWBJEiV-gse8Wkjvfc__h5pNBEbqzmQFkN8iDY-cIryBkLZ_hs_G4mzXrzQrmZf8AxQc9MAfrTuEtWGJKvXYA1YIEkkcrGwrpItAjLIiuCcAtbmJWGixUVWsMBnyuMpqGYloO1WYFOQDHaypU_rMV_tslav4YiOWEicU3lRC2jaOO6-a-fKPpTrYMT1lDVqwQmUeDbidpN_cjwijDTNwG2TSP91V8fwzJ56mBPJQgbNufEHFASoVo9lP30ipQjzusSwO5sEPbliCBL2Ms-9pfTQVtfQFYChDJLjfhoV2g8brK0rJBLlRD5ir0f9KIcY1kXuv8k4Fd-2UA
apiVersion: apps/v1
kind: Deployment
metadata:
name: webin-portal
spec:
replicas: 1
selector:
matchLabels:
run: webin-portal
template:
metadata:
labels:
run: webin-portal
spec:
containers:
- name: webin-portal
image: %DOCKER_IMAGE%
ports:
- containerPort: 80
- containerPort: 443
imagePullSecrets:
- name: gitlab
---
apiVersion: v1
kind: Service
metadata:
name: webin-portal
labels:
run: webin-portal
spec:
type: NodePort
ports:
- port: 80
targetPort: 80
protocol: TCP
name: http
- port: 443
protocol: TCP
name: https
selector:
run: webin-portal
apiVersion: apps/v1
kind: Deployment
metadata:
name: webin-portal
spec:
replicas: 1
selector:
matchLabels:
run: webin-portal
template:
metadata:
labels:
run: webin-portal
spec:
containers:
- name: webin-portal
image: %DOCKER_IMAGE%
ports:
- containerPort: 80
- containerPort: 443
imagePullSecrets:
- name: gitlab
---
apiVersion: v1
kind: Service
metadata:
name: webin-portal
labels:
run: webin-portal
spec:
type: NodePort
ports:
- port: 80
targetPort: 80
protocol: TCP
name: http
- port: 443
protocol: TCP
name: https
selector:
run: webin-portal
apiVersion: apps/v1
kind: Deployment
metadata:
name: webin-portal
spec:
replicas: 1
selector:
matchLabels:
run: webin-portal
template:
metadata:
labels:
run: webin-portal
spec:
containers:
- name: webin-portal
image: %DOCKER_IMAGE%
ports:
- containerPort: 80
- containerPort: 443
imagePullSecrets:
- name: gitlab
---
apiVersion: v1
kind: Service
metadata:
name: webin-portal
labels:
run: webin-portal
spec:
type: NodePort
ports:
- port: 80
targetPort: 80
protocol: TCP
name: http
- port: 443
protocol: TCP
name: https
selector:
run: webin-portal
......@@ -10,6 +10,62 @@ version 7.3.8
Run `ng serve` for a dev server. Navigate to `http://localhost:4200/ena/submit/webin`. The app will automatically reload if you change any of the source files.
## Production server
Run `ng build --prod` and then `ng serve --prod` for a production server. Navigate to `http://localhost:4200/ena/submit/webin`.
## Docker image build (for local run/ test only)
Run `docker build -t dockerhub.ebi.ac.uk/enasequence/webin-portal . `
## Docker image push (for local run/ test only)
Run `docker push dockerhub.ebi.ac.uk/enasequence/webin-portal`
## Kubernetes deployment
For kubernetes deployment we need a unique project version number because the version is used to create unique docker images. For keeping the version number unique we use the corresponding git tag of the release. The version related steps involved in releasing the project are listed below.
1. Check the latest version number in GitHub or GitLab or using the git tag command:
```
git tag
```
The tag should be a semantic version number.
When deploying in production:
```
A.B.C (e.g. 1.0.0)
```
When deploying in test:
```
test-A.B.C (e.g. dev-1.0.0)
```
When deploying in development:
```
dev-A.B.C (e.g. dev-1.0.0)
```
2. Commit and push all the changes that need to be released.
3. Create and push the git tag with value "new version number".
```
git tag [dev-]A.B.C
git push origin [dev-]A.B.C
```
Please note:
- The package and deploy GitLab CI/CD stages will only run for git tags. The git tag will be used as the docker image tag.
- The production deploy GitLab CI/CD stage will only run from master branch.
- Please refer to the .gitlab-ci.yml file for more details
## Running unit tests
Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).
......
......@@ -13,7 +13,7 @@
"options": {
"baseHref" : "/ena/submit/webin/",
"deployUrl": "/ena/submit/webin/",
"outputPath": "../src/main/resources/static",
"outputPath": "dist/webin-portal",
"index": "src/index.html",
"main": "src/main.ts",
"tsConfig": "src/tsconfig.app.json",
......
# This file is used by the build system to adjust CSS and JS output to support the specified browsers below.
# For additional information regarding the format and rule options, please see:
# https://github.com/browserslist/browserslist#queries
# You can see what browsers were selected by your queries by running:
# npx browserslist
> 0.5%
last 2 versions
Firefox ESR
not dead
not IE 9-11 # For IE 9-11 support, remove 'not'.
buildscript {
ext {
springBootVersion = '1.5.9.RELEASE'
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
classpath "com.moowork.gradle:gradle-node-plugin:1.2.0"
classpath 'org.hidetake:gradle-ssh-plugin:2.9.0'
}
repositories {
mavenLocal()
maven { url "https://plugins.gradle.org/m2/" }
}
}
enum Environment{
localdev, localtest, dev , test , prod
}
ext.version_base = '1.0.5'
ext.environment = project.hasProperty('env') ? env : Environment.dev.toString()
version = version_base + "-$ext.environment"
group = 'uk.ac.ebi.ena.webin-portal'
ext.sshKeyFile = file(hasProperty('sshKeyFile') ? sshKeyFile : "${System.properties['user.home']}/.ssh/id_rsa.ppk")
ext.gitlab_project_id ='977'
ext.envAngularBuildScriptMap = [
'test' : 'buildTest',
'dev' : 'buildDev',
'prod' : 'buildProd',
'default': 'build'
]
printSetup()
def props = new Properties()
file('src/main/resources/application.properties').withInputStream {
props.load(it)
}
ext.serverContextPath = removeLeadingSlash(props['server.contextPath'])
ext.serverPort = props['server.port']
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'com.moowork.node'
apply plugin: 'org.hidetake.ssh'
apply plugin: 'maven-publish'
sourceCompatibility = 1.8
sourceSets.main.resources.includes = [ "**/*.*" ]
repositories {
mavenLocal()
maven { url "https://gitlab.ebi.ac.uk/api/v4/groups/enasequence/-/packages/maven" }
mavenCentral()
}
dependencies {
compile('org.springframework.boot:spring-boot-starter-web')
compile 'org.springframework.boot:spring-boot-starter-actuator'
testCompile('org.springframework.boot:spring-boot-starter-test')
}
node {
version = "10.9.0"
download = true
nodeModulesDir = file("frontend")
}
processResources {
filesMatching('application*.properties') {
expand(project.properties)
}
}
jar {
manifest {
attributes(
'Implementation-Title': project.name,
'Implementation-Version': project.version,
'Built-By': System.getProperty('user.name'),
'Built-Date': new Date(),
'Source-Compatibility': project.sourceCompatibility)
}
}
task sourceJar(type: Jar) {
classifier = 'sources'
from sourceSets.main.allSource
}
remotes {
dev {
host = 'ves-ebi-5b.ebi.ac.uk'
user = 'ena_adm'
identity = sshKeyFile
knownHosts = allowAnyHosts
}
test {
host = 'ves-ebi-5a'
user = 'ena_adm'
identity = sshKeyFile
knownHosts = allowAnyHosts
}
prodA {
host = 'ves-hx-5a'
user = 'ena_adm'
identity = sshKeyFile
knownHosts = allowAnyHosts
}
prodB {
host = 'ves-hx-5b'
user = 'ena_adm'
identity = sshKeyFile
knownHosts = allowAnyHosts
}
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
artifact sourceJar
}
}
repositories {
maven {
// Project specific maven repository in Gitlab.
url "https://gitlab.ebi.ac.uk/api/v4/projects/${gitlab_project_id}/packages/maven"
// Developer token in Gitlab.
credentials(HttpHeaderCredentials) {
name = "Private-Token"
value = project.ext.properties.gitlab_private_token
}
authentication {
header( HttpHeaderAuthentication )
}
}
}
}
wrapper{
gradleVersion = '5.2.1'
}
task buildClientWatch(type: NpmTask, dependsOn: 'npmInstall'){
group = 'application'
description = "Build and watches the client side assets for rebuilding"
args = ['run','buildWatch']
}
task buildClient(type:NpmTask, dependsOn:'npmInstall'){
println 'buildClient script:' + getAngularBuildScript()
group = 'build'
description = "Compile client side folder for production"
args = ['run', getAngularBuildScript()]
}