Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump eslint from 3.19.0 to 4.18.2 in /aragwas_ui #138

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
10 changes: 10 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
aragwas_ui/node_modules
.git
aragwas_server/static/*
aragwas_server/GENOTYPE_DATA
*.egg-info
*.egg/
*.pyc
*.swp

.tox
.coverage
html/*
__pycache__
44 changes: 44 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
FROM python:3 as django
RUN useradd --uid=10372 -ms /bin/bash aragwas && mkdir -p /srv/web && mkdir -p /srv/static && chown aragwas:aragwas /srv/static && chown aragwas:aragwas /srv/web
COPY aragwas_server/requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt && pip install gunicorn
# copy webservice code
COPY --chown=aragwas:aragwas aragwas_server /srv/web
WORKDIR /srv/web
COPY --chown=aragwas:aragwas entrypoint.sh write_version.sh wait-for-it.sh ./

RUN chmod 755 entrypoint.sh wait-for-it.sh write_version.sh

ARG GIT_BRANCH
ENV GIT_BRANCH $GIT_BRANCH

ARG GIT_COMMIT
ENV GIT_COMMIT $GIT_COMMIT

ARG BUILD_NUMBER
ENV BUILD_NUMBER $BUILD_NUMBER

ARG BUILD_URL
ENV BUILD_URL $BUILD_URL

RUN /srv/web/write_version.sh /srv/web/gwasdb/__init__.py

USER aragwas


FROM django as aragwas-worker
ENTRYPOINT ["/srv/web/entrypoint.sh", "aragwas-worker"]

FROM node:11-alpine AS builder
WORKDIR /app
COPY aragwas_ui/package.json aragwas_ui/package-lock.json /app/
RUN npm install
COPY aragwas_ui /app
RUN npm run build


FROM django as aragwas-backend
COPY --chown=aragwas:aragwas --from=builder /app/dist/static /srv/web/gwasdb/static
COPY --chown=aragwas:aragwas --from=builder /app/dist/index.html /srv/web/gwasdb/templates/index.html
ENTRYPOINT ["/srv/web/entrypoint.sh", "aragwas-backend"]

160 changes: 19 additions & 141 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,141 +1,19 @@
#!/usr/bin/env groovy


/**
* build / test pipeline for AraGWAS
*/

pipeline {

agent any
stages {

// global checkout needed for Docker setup
stage('checkout') {
steps {
checkout scm
}
}

// prepare the dockers: testing env
stage('test') {
steps {
script {

// build ui docker image to compile javascript
def ui_img = docker.build("aragwas_ui","aragwas_ui")
ui_img.inside('-u root') {
sh """
cd aragwas_ui
ln -s /srv/aragwas_ui/node_modules/ || true
npm run build
rm node_modules
"""
}
//ui_img.run('-a -v $WORKSPACE/dist:/srv/aragwas_server/gwasdb')
//sh 'cp -r dist/* $WORKSPACE/aragwas_server/gwasdb/'
//FIXME this in try-catch and clean shutdown of db_cont
def app_img = docker.build("aragwas","aragwas_server")

// link app container to db container, expose platinum test config path
app_img.inside() {
// run the behave tests
echo "running tests"
sh returnStatus: true, script: "cd /srv/web/ && py.test -ra -p no:cacheprovider --junitxml ${env.WORKSPACE}/TESTS-aragwas.xml"
}
// collect unit test results
junit "TESTS-aragwas.xml"
}
}
}

// not _really_ deploy, but push to local registry
stage('deploy') {
when{
branch 'master'
}
steps {
script {
sh 'sh write_version.sh'
//FIXME leaking local infra details
docker.withRegistry('https://docker.artifactory.imp.ac.at', 'jenkins_artifactory_creds') {

// push DB docker img to registry
def server_img = docker.build("docker.artifactory.imp.ac.at/the1001genomes/aragwas", "aragwas_server")

server_img.push('latest')
sshagent(['1001genome_deploy_ssh_key']) {
env.DEPLOY_HOST = 'aragwas.sci.gmi.oeaw.ac.at'
sh '''
scp -o StrictHostKeyChecking=no aragwas_server/docker-compose.yml root@$DEPLOY_HOST:/root/
ssh -o StrictHostKeyChecking=no root@$DEPLOY_HOST "cd /root && docker-compose pull && docker-compose up -d"
'''
}
}
}
}
}
// in the future: conditional deploy?
} //stages

// post block is executed after all the stages/steps in the pipeline
post {
// always {
// // notify build results, see https://jenkins.io/blog/2016/07/18/pipline-notifications/
// // notifyBuild(currentBuild.result)

// }
changed {
echo "build changed"
}
aborted {
echo "build aborted"
}
failure {
echo "build failed"
}
success {
echo "build is success"
}
unstable {
echo "build is unstable"
}
}
}

// send global slack notification, but fail silently if this is not possible, i.e. slack integration is not installed
def notifyBuild(String buildStatus) {
// build status of null means successful
buildStatus = buildStatus ?: 'SUCCESS'

if (buildStatus == 'STARTED' || buildStatus == 'CHANGED' || buildStatus == 'UNSTABLE') {
color = 'YELLOW'
colorCode = '#DDDD00'
}
else if (buildStatus == 'SUCCESS') {
color = 'GREEN'
colorCode = '#00DD00'
}
else {
// FAILURE or UNSTABLE
color = 'RED'
colorCode = '#DD0000'
}

def message = "${buildStatus}: Job <${env.BUILD_URL}|${env.JOB_NAME} #${env.BUILD_NUMBER}>"

/* we could add blame to the slack message ;) but it's visible on the build details anyway
if (buildStatus == 'FAILURE') {
def changes_by = sh 'git --no-pager log -1 --format=%an'
message = "${buildStatus}: Job <${env.BUILD_URL}|${env.JOB_NAME} #${env.BUILD_NUMBER}> caused by ${changes_by}"
}
*/

// send gracefully
try {
slackSend (color: colorCode, message: "${message}")
}
catch (e) {
echo "failed to send notification: ${e}"
}
}
def jobsMapping = [
tags: [jobName:"App AraGWAS", jobTags: "reload", extraVars: "app_generic_image_tag: latest"],
master: [jobName:"App AraGWAS", jobTags: "reload", extraVars: "app_generic_image_tag: master"]
]

def extraImages =
[
[imageName: "aragwas-backend", dockerFile: "Dockerfile", dockerContext: ".", extraBuildArgs: '--target aragwas-backend'],
[imageName: "aragwas-worker", dockerFile: "Dockerfile", dockerContext: ".", extraBuildArgs: '--target aragwas-worker']
]

buildDockerImage([
imageName: "aragwas-backend",
pushRegistryNamespace: "the1001genomes",
pushBranches: ['develop', 'master'],
test: testScript('py.test -ra -p no:cacheprovider /srv/web --junitxml junit.xml', '**/junit.xml'),
containerImages: extraImages
//tower: jobsMapping
])
26 changes: 0 additions & 26 deletions aragwas_server/Dockerfile

This file was deleted.

16 changes: 11 additions & 5 deletions aragwas_server/aragwas/settings/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
# See https://docs.djangoproject.com/en/dev/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '!x&y+0o%^+*hc5phfjh2jm+vprr=6z00*f^z03k5%e0xqrgiz0'
SECRET_KEY = os.environ.get('SECRET_KEY','REPLACE_WITH_PROD_KEY')

ALLOWED_HOSTS = os.environ.get('ALLOWED_HOSTS','127.0.0.1').split()

Expand Down Expand Up @@ -131,11 +131,14 @@
# https://docs.djangoproject.com/en/dev/howto/static-files/

STATIC_URL = '/static/'
STATIC_ROOT = '/usr/share/nginx/html/static'
STATIC_ROOT = '/srv/static'


# Celery
BROKER_HOST = os.environ.get('AMQP_HOST', 'amqp1')
CELERY_BROKER_URL = 'amqp://%s' % (BROKER_HOST)
BROKER_HOST = os.environ.get('RABBITMQ_HOSTNAME', 'amqp1')
BROKER_USERNAME = os.environ.get('RABBITMQ_DEFAULT_USER', 'guest')
BROKER_PASSWORD = os.environ.get('RABBITMQ_DEFAULT_PASS', 'guest')
CELERY_BROKER_URL = 'amqp://%s:%s@%s' % (BROKER_USERNAME, BROKER_PASSWORD, BROKER_HOST)
CELERY_ACCEPT_CONTENT = ['json']
CELERY_TASK_SERIALIZER = 'json'
CELERY_RESULT_SERIALIZER = 'json'
Expand All @@ -156,7 +159,10 @@
}


ES_HOST = os.environ.get('ES_HOST', 'http://elastic:changeme@localhost:9200')
ES_HOSTNAME = os.environ.get('ELASTICSEARCH_HOSTNAME', 'http://elastic:changeme@localhost:9200')
ES_USERNAME = os.environ.get('ELASTICSEARCH_USER', 'elastic')
ES_PASSWORD = os.environ.get('ELASTICSEARCH_PASS', 'changeme')
ES_HOST = 'http://%s:%s@%s' % (ES_USERNAME, ES_PASSWORD, ES_HOSTNAME)
GITHUB_URL='https://github.com/1001genomes/aragwas/commit'
HDF5_FILE_PATH = os.environ.get('ARAGWAS_HDF5_FILE_PATH','aragwas_data')

Expand Down
11 changes: 0 additions & 11 deletions aragwas_server/web-entrypoint.sh

This file was deleted.

2 changes: 0 additions & 2 deletions aragwas_server/worker-entrypoint.sh

This file was deleted.

2 changes: 0 additions & 2 deletions aragwas_ui/.dockerignore

This file was deleted.

13 changes: 0 additions & 13 deletions aragwas_ui/Dockerfile

This file was deleted.

8 changes: 2 additions & 6 deletions aragwas_ui/build/webpack.prod.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ var CopyWebpackPlugin = require('copy-webpack-plugin')
var HtmlWebpackPlugin = require('html-webpack-plugin')
var ExtractTextPlugin = require('extract-text-webpack-plugin')
var OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin')
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')

var env = process.env.NODE_ENV === 'testing'
? require('../config/test.env')
Expand All @@ -31,12 +32,7 @@ var webpackConfig = merge(baseWebpackConfig, {
new webpack.DefinePlugin({
'process.env': env
}),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
},
sourceMap: true
}),
new UglifyJsPlugin(),
// extract css into its own file
new ExtractTextPlugin({
filename: utils.assetsPath('css/[name].[contenthash].css')
Expand Down
4 changes: 2 additions & 2 deletions aragwas_ui/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ var path = require('path')
module.exports = {
build: {
env: require('./prod.env'),
index: path.resolve(__dirname, '../../aragwas_server/gwasdb/templates/index.html'),
assetsRoot: path.resolve(__dirname, '../../aragwas_server/gwasdb/static'),
index: path.resolve(__dirname, '../dist/index.html'),
assetsRoot: path.resolve(__dirname, '../dist/static/'),
assetsSubDirectory: '',
assetsPublicPath: '/static',
productionSourceMap: true,
Expand Down
Loading