Commit 9aa02ab2 authored by David Mendez's avatar David Mendez
Browse files

Merge branch 'staging' into 'master'

Start to add CI script for deployment

See merge request !1
parents 7f18d1a1 f5a836a0
variables: variables:
DOCKER_TLS_CERTDIR: "" DOCKER_TLS_CERTDIR: ""
GIT_STRATEGY: clone GIT_STRATEGY: clone
REGISTRY_USER: chembl/unichem REGISTRY_USER: chembl/research
APPLICATION: malaria-frontend APPLICATION: lina-web
SERVER_IMAGE_TAG: ${CI_REGISTRY}/${REGISTRY_USER}/${APPLICATION}:${CI_COMMIT_SHORT_SHA}
RELEASE_IMAGE: $CI_REGISTRY/$REGISTRY_USER/$APPLICATION:$CI_BUILD_REF_NAME RELEASE_IMAGE: $CI_REGISTRY/$REGISTRY_USER/$APPLICATION:$CI_BUILD_REF_NAME
DOCKER_IMAGE: $CI_REGISTRY/$REGISTRY_USER/$APPLICATION DOCKER_IMAGE: $CI_REGISTRY/$REGISTRY_USER/$APPLICATION
DOCKER_DRIVER: overlay DOCKER_DRIVER: overlay
CONFIGS_FOLDER: run_config
image: docker:latest # Config staging
ENV_STAGING_FILE_PATH: ${CONFIGS_FOLDER}/staging/.env
services: INGRESS_STAGING_FILE_PATH: ${CONFIGS_FOLDER}/staging/ingress.yml
- docker:dind # Config prod hx
ENV_PROD_HX_FILE_PATH: ${CONFIGS_FOLDER}/prod_hx/.env
INGRESS_PROD_HX_FILE_PATH: ${CONFIGS_FOLDER}/prod_hx/ingress.yml
# Config prod hh
ENV_PROD_HH_FILE_PATH: ${CONFIGS_FOLDER}/prod_hh/.env
INGRESS_PROD_HH_FILE_PATH: ${CONFIGS_FOLDER}/prod_hh/ingress.yml
stages: stages:
- build - build
# - test - test
# - deploy - prepare_config
- deploy
build-dev: build:
image:
name: docker/compose:1.25.5
entrypoint: ["/bin/sh", "-c"]
stage: build
only:
- staging
services:
- docker:dind
tags:
- dind
variables:
DOCKER_HOST: tcp://docker:2375
script: script:
- echo 'hello!' - echo $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER --password-stdin $CI_REGISTRY
# build-dev: - echo Building ${SERVER_IMAGE_TAG}
# image: - echo building ${SERVER_IMAGE_TAG}
# name: docker/compose:1.25.5 - docker build --tag ${SERVER_IMAGE_TAG} .
# entrypoint: ["/bin/sh", "-c"] - docker push ${SERVER_IMAGE_TAG}
# stage: build
# only:
# - dev
# # - master
# variables:
# DOCKER_HOST: tcp://docker:2375
# script:
# - echo $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER --password-stdin $CI_REGISTRY
# - echo Building ${DOCKER_IMAGE}:${CI_COMMIT_SHORT_SHA}
# - docker-compose build development
# - echo Deploying ${DOCKER_IMAGE}:${CI_COMMIT_SHORT_SHA}
# - docker push ${DOCKER_IMAGE}:${CI_COMMIT_SHORT_SHA}
# build-prod: # build-prod:
# image: # image:
...@@ -54,75 +61,117 @@ build-dev: ...@@ -54,75 +61,117 @@ build-dev:
# - echo Deploying ${DOCKER_IMAGE}:${CI_COMMIT_SHORT_SHA} # - echo Deploying ${DOCKER_IMAGE}:${CI_COMMIT_SHORT_SHA}
# - docker push ${DOCKER_IMAGE}:${CI_COMMIT_SHORT_SHA} # - docker push ${DOCKER_IMAGE}:${CI_COMMIT_SHORT_SHA}
# unit-tests: unit-tests:
# stage: test stage: test
# when: manual script:
# script: - echo "ToDo UNIT TESTS"
# - echo "ToDo UNIT TESTS"
# only:
# - master
# - dev
# deploy-dev-hx: prepare_config_staging:
# image: stage: prepare_config
# name: lachlanevenson/k8s-kubectl:latest image:
# entrypoint: ["/bin/sh", "-c"] name: alpine/git
# stage: deploy entrypoint: ["/bin/sh", "-c"]
# script: only:
# - echo $KUBE_URL_HX - staging
# - echo "$KUBE_CA_PEM_HX" > "$(pwd)/kube.ca.pem" script:
# - kubectl config set-cluster ${KUBE_CLUS_NAME_HX} --server="${KUBE_URL_HX}" --certificate-authority="$(pwd)/kube.ca.pem" - set -x
# - kubectl config set-credentials ${KUBE_USER_HX} --token="${KUBE_TOKEN_HX}" - rm -rf ${CONFIGS_FOLDER} || true
# - kubectl config set-context ${KUBE_NAMESPACE_DEV} --cluster=${KUBE_CLUS_NAME_HX} --user=${KUBE_USER_HX} - mkdir -p ${CONFIGS_FOLDER}
# - kubectl config use-context ${KUBE_NAMESPACE_DEV} - git clone https://${CONFIG_DEPLOY_GITLAB_USERNAME}:${CONFIG_DEPLOY_GITLAB_TOKEN}@${CONFIGURATIONS_REPO} ${CONFIGS_FOLDER}
# - echo ${KUBE_NAMESPACE_DEV} ${KUBE_URL_HH} ${KUBE_CLUS_NAME_HX} ${KUBE_USER_HX} tags:
# - kubectl get pods -n ${KUBE_NAMESPACE_DEV} - docker
# - sed -i "s~<VERSION>~${CI_COMMIT_SHORT_SHA}~" k8s-deployment.yml artifacts:
# - sed -i "s~<DOCKER_IMAGE>~${DOCKER_IMAGE}~" k8s-deployment.yml
# - kubectl apply -n ${KUBE_NAMESPACE_DEV} -f k8s-deployment.yml
# only:
# - dev
# deploy-dev-hh: paths:
# image: - ${ENV_STAGING_FILE_PATH}
# name: lachlanevenson/k8s-kubectl:latest - ${INGRESS_STAGING_FILE_PATH}
# entrypoint: ["/bin/sh", "-c"]
# stage: deploy
# script:
# - echo $KUBE_URL_HH
# - echo "$KUBE_CA_PEM_HH" > "$(pwd)/kube.ca.pem"
# - kubectl config set-cluster ${KUBE_CLUS_NAME_HH} --server="${KUBE_URL_HH}" --certificate-authority="$(pwd)/kube.ca.pem"
# - kubectl config set-credentials ${KUBE_USER_HH} --token="${KUBE_TOKEN_HH}"
# - kubectl config set-context ${KUBE_NAMESPACE_DEV} --cluster=${KUBE_CLUS_NAME_HH} --user=${KUBE_USER_HH}
# - kubectl config use-context ${KUBE_NAMESPACE_DEV}
# - echo ${KUBE_NAMESPACE_DEV} ${KUBE_URL_HH} ${KUBE_CLUS_NAME_HH} ${KUBE_USER_HH}
# - kubectl get pods -n ${KUBE_NAMESPACE_DEV}
# - sed -i "s~<VERSION>~${CI_COMMIT_SHORT_SHA}~" k8s-deployment.yml
# - sed -i "s~<DOCKER_IMAGE>~${DOCKER_IMAGE}~" k8s-deployment.yml
# - kubectl apply -n ${KUBE_NAMESPACE_DEV} -f k8s-deployment.yml
# only:
# - dev
# deploy-prod-hx: deploy-staging:
# image: image:
# name: lachlanevenson/k8s-kubectl:latest name: lachlanevenson/k8s-kubectl:latest
# entrypoint: ["/bin/sh", "-c"] entrypoint: ["/bin/sh", "-c"]
# stage: deploy only:
# script: - staging
# - echo $KUBE_URL_HX stage: deploy
# - echo "$KUBE_CA_PEM_HX" > "$(pwd)/kube.ca.pem" script:
# - kubectl config set-cluster ${KUBE_CLUS_NAME_HX} --server="${KUBE_URL_HX}" --certificate-authority="$(pwd)/kube.ca.pem" - set -x
# - kubectl config set-credentials ${KUBE_USER_HX} --token="${KUBE_TOKEN_HX}" - echo "$KUBE_CA_PEM_HX" > "$(pwd)/kube.ca.pem"
# - kubectl config set-context ${KUBE_NAMESPACE_PROD} --cluster=${KUBE_CLUS_NAME_HX} --user=${KUBE_USER_HX} - kubectl config set-cluster ${KUBE_CLUS_NAME_HX} --server="${KUBE_URL_HX}" --certificate-authority="$(pwd)/kube.ca.pem"
# - kubectl config use-context ${KUBE_NAMESPACE_PROD} - kubectl config set-credentials ${KUBE_USER_HX} --token="${KUBE_TOKEN_HX}"
# - echo ${KUBE_NAMESPACE_DEV} ${KUBE_URL_HX} ${KUBE_CLUS_NAME_HX} ${KUBE_USER_HX} - kubectl config set-context ${CHEMBL_NS_STAGING} --cluster=${KUBE_CLUS_NAME_HX} --user=${KUBE_USER_HX}
# - kubectl get pods -n ${KUBE_NAMESPACE_PROD} - kubectl config use-context ${CHEMBL_NS_STAGING}
# - sed -i "s~<VERSION>~${CI_COMMIT_SHORT_SHA}~" k8s-deployment.yml - echo ${CHEMBL_NS_STAGING} ${KUBE_URL_HX} ${KUBE_CLUS_NAME_HX} ${KUBE_USER_HX}
# - sed -i "s~<DOCKER_IMAGE>~${DOCKER_IMAGE}~" k8s-deployment.yml - kubectl get pods -n ${CHEMBL_NS_STAGING}
# - kubectl apply -n ${KUBE_NAMESPACE_PROD} -f k8s-deployment.yml - kubectl create secret generic ${RUN_CONFIG_SECRET_NAME_STAGING} --from-file=.env=${ENV_STAGING_FILE_PATH} -o yaml -n ${CHEMBL_NS_STAGING} --dry-run=client | kubectl replace -f -
# when: manual - cat ${ENV_STAGING_FILE_PATH}
# only: - echo ${CHEMBL_NS_STAGING} ${KUBE_URL_HX} ${KUBE_CLUS_NAME_HX} ${KUBE_USER_HX}
# - master - kubectl get pods -n ${CHEMBL_NS_STAGING}
- sed -i "s~<SERVER_IMAGE_TAG>~${SERVER_IMAGE_TAG}~" k8s-deployment.yml
- sed -i "s~<HTTP_PROXY>~${HTTP_PROXY_HX}~g" k8s-deployment.yml
- sed -i "s~<HTTPS_PROXY>~${HTTPS_PROXY_HX}~g" k8s-deployment.yml
- sed -i "s~<NO_PROXY>~${NO_PROXY_HX_DEFAULT}~g" k8s-deployment.yml
- sed -i "s~<ENV_SECRET_NAME>~${RUN_CONFIG_SECRET_NAME_STAGING}~g" k8s-deployment.yml
- cat k8s-deployment.yml
- kubectl apply -n ${CHEMBL_NS_STAGING} -f k8s-deployment.yml
- cat ${INGRESS_STAGING_FILE_PATH}
- kubectl apply -n ${CHEMBL_NS_STAGING} -f ${INGRESS_STAGING_FILE_PATH}
prepare_config_prod:
stage: prepare_config
image:
name: alpine/git
entrypoint: ["/bin/sh", "-c"]
only:
- master
script:
- set -x
- rm -rf ${CONFIGS_FOLDER} || true
- mkdir -p ${CONFIGS_FOLDER}
- git clone https://${CONFIG_DEPLOY_GITLAB_USERNAME}:${CONFIG_DEPLOY_GITLAB_TOKEN}@${CONFIGURATIONS_REPO} ${CONFIGS_FOLDER}
tags:
- docker
artifacts:
paths:
- ${ENV_PROD_HX_FILE_PATH}
- ${INGRESS_PROD_HX_FILE_PATH}
- ${ENV_PROD_HH_FILE_PATH}
- ${INGRESS_PROD_HH_FILE_PATH}
deploy-prod-hx:
image:
name: lachlanevenson/k8s-kubectl:latest
entrypoint: ["/bin/sh", "-c"]
stage: deploy
only:
- master
script:
- set -x
- echo "$KUBE_CA_PEM_HX" > "$(pwd)/kube.ca.pem"
- kubectl config set-cluster ${KUBE_CLUS_NAME_HX} --server="${KUBE_URL_HX}" --certificate-authority="$(pwd)/kube.ca.pem"
- kubectl config set-credentials ${KUBE_USER_HX} --token="${KUBE_TOKEN_HX}"
- kubectl config set-context ${CHEMBL_NS_PROD} --cluster=${KUBE_CLUS_NAME_HX} --user=${KUBE_USER_HX}
- kubectl config use-context ${CHEMBL_NS_PROD}
- echo ${CHEMBL_NS_PROD} ${KUBE_URL_HX} ${KUBE_CLUS_NAME_HX} ${KUBE_USER_HX}
- kubectl get pods -n ${CHEMBL_NS_PROD}
- kubectl create secret generic ${RUN_CONFIG_SECRET_NAME_PROD_HX} --from-file=.env=${ENV_PROD_HX_FILE_PATH} -o yaml -n ${CHEMBL_NS_PROD} --dry-run=client | kubectl apply -f -
- cat ${ENV_PROD_HX_FILE_PATH}
- echo ${CHEMBL_NS_PROD} ${KUBE_URL_HX} ${KUBE_CLUS_NAME_HX} ${KUBE_USER_HX}
- kubectl get pods -n ${CHEMBL_NS_PROD}
- sed -i "s~<SERVER_IMAGE_TAG>~${SERVER_IMAGE_TAG}~" k8s-deployment.yml
- sed -i "s~<HTTP_PROXY>~${HTTP_PROXY_HX}~g" k8s-deployment.yml
- sed -i "s~<HTTPS_PROXY>~${HTTPS_PROXY_HX}~g" k8s-deployment.yml
- sed -i "s~<NO_PROXY>~${NO_PROXY_HX_DEFAULT}~g" k8s-deployment.yml
- sed -i "s~<ENV_SECRET_NAME>~${RUN_CONFIG_SECRET_NAME_PROD_HX}~g" k8s-deployment.yml
- cat k8s-deployment.yml
- kubectl apply -n ${CHEMBL_NS_PROD} -f k8s-deployment.yml
- cat ${INGRESS_PROD_HX_FILE_PATH}
- kubectl apply -n ${CHEMBL_NS_PROD} -f ${INGRESS_PROD_HX_FILE_PATH}
# deploy-prod-hh: # deploy-prod-hh:
# image: # image:
......
FROM node:lts FROM node:lts
ENV ENV_FILE_PATH=${ENV_FILE_PATH:-'/etc/run_config/.env'}
LABEL maintainer="heinzke@ebi.ac.uk" LABEL maintainer="heinzke@ebi.ac.uk"
...@@ -16,10 +17,10 @@ COPY . $APP_SOURCE ...@@ -16,10 +17,10 @@ COPY . $APP_SOURCE
ARG DELAYED_JOBS_API ARG DELAYED_JOBS_API
ENV DELAYED_JOBS_API $DELAYED_JOBS_API ENV DELAYED_JOBS_API $DELAYED_JOBS_API
RUN npm install && npm run build RUN npm install
ENV HOST 0.0.0.0 ENV HOST 0.0.0.0
EXPOSE 3000 EXPOSE 3000
ENTRYPOINT [ "npm", "start" ] ENTRYPOINT ENV_FILE_PATH=${ENV_FILE_PATH} npm run build && npm start
apiVersion: apps/v1 apiVersion: apps/v1
kind: Deployment kind: Deployment
metadata: metadata:
name: malaria-front name: lina-web
labels: labels:
app: malaria-front app: lina-web
spec: spec:
selector: selector:
matchLabels: matchLabels:
app: malaria-front app: lina-web
role: master role: master
tier: frontend tier: frontend
replicas: 2 replicas: 2
template: template:
metadata: metadata:
labels: labels:
app: malaria-front app: lina-web
role: master role: master
tier: frontend tier: frontend
spec: spec:
containers: containers:
- name: malaria-front - name: lina-web
image: <DOCKER_IMAGE>:<VERSION> image: <SERVER_IMAGE_TAG>
imagePullPolicy: Always imagePullPolicy: Always
ports: ports:
- containerPort: 3000 - containerPort: 3000
imagePullSecrets: volumeMounts:
- name: malaria-frontend-registry - name: run-config
mountPath: '/etc/run_config/'
readOnly: true
env:
- name: HTTP_PROXY
value: "<HTTP_PROXY>"
- name: http_proxy
value: "<HTTP_PROXY>"
- name: HTTPS_PROXY
value: "<HTTPS_PROXY>"
- name: https_proxy
value: "<HTTPS_PROXY>"
- name: NO_PROXY
value: "<NO_PROXY>"
- name: no_proxy
value: "<NO_PROXY>"
volumes:
- name: run-config
secret:
secretName: <ENV_SECRET_NAME>
--- ---
apiVersion: v1 apiVersion: v1
kind: Service kind: Service
metadata: metadata:
name: malaria-front name: lina-web
spec: spec:
selector: selector:
app: malaria-front app: lina-web
ports: ports:
- protocol: TCP - protocol: TCP
port: 3000 port: 3000
......
require('dotenv').config({ path: process.env.ENV_FILE_PATH })
export default { export default {
mode: 'universal', mode: 'universal',
router: { router: {
base: '/chembl/lina-web' base: '/chembl/lina_web'
}, },
env: { env: {
baseUrl: process.env.BASE_URL || 'http://localhost:3000', baseUrl: process.env.BASE_URL || 'http://localhost:3000',
......
This diff is collapsed.
...@@ -15,11 +15,12 @@ ...@@ -15,11 +15,12 @@
}, },
"dependencies": { "dependencies": {
"@chembl/ebi-basic-components": "0.2.5", "@chembl/ebi-basic-components": "0.2.5",
"@nuxtjs/axios": "^5.12.0", "@nuxtjs/axios": "^5.13.1",
"@nuxtjs/google-analytics": "^2.4.0", "@nuxtjs/google-analytics": "^2.4.0",
"apexcharts": "^3.19.3", "apexcharts": "^3.25.0",
"nuxt": "^2.13.3", "dotenv": "^8.2.0",
"papaparse": "^5.2.0", "nuxt": "^2.15.0",
"papaparse": "^5.3.0",
"vue-apexcharts": "^1.6.0", "vue-apexcharts": "^1.6.0",
"vuex-persistedstate": "^2.7.1" "vuex-persistedstate": "^2.7.1"
}, },
...@@ -27,21 +28,21 @@ ...@@ -27,21 +28,21 @@
"@nuxtjs/eslint-config": "^2.0.2", "@nuxtjs/eslint-config": "^2.0.2",
"@nuxtjs/eslint-module": "^1.2.0", "@nuxtjs/eslint-module": "^1.2.0",
"@nuxtjs/style-resources": "^1.0.0", "@nuxtjs/style-resources": "^1.0.0",
"@nuxtjs/vuetify": "^1.11.2", "@nuxtjs/vuetify": "^1.11.3",
"@vue/test-utils": "^1.0.3", "@vue/test-utils": "^1.1.3",
"babel-eslint": "^10.1.0", "babel-eslint": "^10.1.0",
"babel-jest": "^26.1.0", "babel-jest": "^26.6.3",
"eslint": "^6.8.0", "eslint": "^6.8.0",
"eslint-config-prettier": "^6.11.0", "eslint-config-prettier": "^6.15.0",
"eslint-loader": "^3.0.2", "eslint-loader": "^3.0.2",
"eslint-plugin-nuxt": "^0.5.2", "eslint-plugin-nuxt": "^0.5.2",
"eslint-plugin-prettier": "^3.1.4", "eslint-plugin-prettier": "^3.3.1",
"eslint-plugin-vue": "^6.2.2", "eslint-plugin-vue": "^6.2.2",
"jest": "^26.1.0", "jest": "^26.6.3",
"node-sass": "^4.14.1", "node-sass": "^4.14.1",
"prettier": "^1.19.1", "prettier": "^1.19.1",
"sass-loader": "^8.0.2", "sass-loader": "^8.0.2",
"vue-jest": "^4.0.0-beta.4", "vue-jest": "^4.0.0-rc.1",
"vuetify": "^2.3.4" "vuetify": "^2.4.4"
} }
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment