Skip to content

Commit

Permalink
Updated python docker images to gracefuly stop since they now start i…
Browse files Browse the repository at this point in the history
…n the primary process in a container, through taking over execution of the entrypoint script via a command; Increased python-multipart pacakge version to avoid vulnerability; increased eslint's version to remove dependency which has vulnerability; this required upgrading the eslint configuration within rosalution to use the new flat file configuration. It is temporarily tuned to be close to the existing code base linting however, the team will review and revise linting guidelines when we gather soon.
  • Loading branch information
SeriousHorncat committed Dec 16, 2024
1 parent ca8a2a0 commit e988603
Show file tree
Hide file tree
Showing 20 changed files with 867 additions and 499 deletions.
4 changes: 2 additions & 2 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ WORKDIR /app
COPY requirements.txt /app/requirements.txt
RUN pip install --no-cache-dir --upgrade -r /app/requirements.txt
COPY ./src /app/src
ENTRYPOINT ["/bin/sh", "-c", "uvicorn src.main:app --host 0.0.0.0 --port 8000 --log-level info --reload"]
CMD ["uvicorn", "src.main:app", "--host", "0.0.0.0", "--port", "8000", "--log-level", "info", "--reload"]

# Production Build Stage
FROM python:3.11-slim-bookworm AS production-stage
Expand All @@ -15,4 +15,4 @@ RUN pip install --no-cache-dir -r /app/requirements.txt
COPY ./src /app/src
COPY etc/entrypoint-init.sh /app/entrypoint-init.sh
RUN rm /app/src/routers/dev_router.py
ENTRYPOINT ["/bin/sh", "-c", "uvicorn src.main:app --host 0.0.0.0 --port 8000 --log-level info"]
CMD ["uvicorn", "src.main:app", "--host", "0.0.0.0", "--port", "8000", "--log-level", "info"]
5 changes: 3 additions & 2 deletions backend/etc/entrypoint-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ if [ "$ROSALUTION_ENV" = "production" ]; then
DEBUG='-O'
fi

ROSALUTION_KEY="$(< /dev/urandom tr -dc A-Za-z0-9 | head -c 65)" && export ROSALUTION_KEY && \
python $DEBUG -m uvicorn src.main:app --host 0.0.0.0 --port 8000 --log-level info "$@"
ROSALUTION_KEY="$(< /dev/urandom tr -dc A-Za-z0-9 | head -c 65)" && export ROSALUTION_KEY

exec python $DEBUG -m uvicorn src.main:app --host 0.0.0.0 --port 8000 --log-level info "$@"
2 changes: 1 addition & 1 deletion backend/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ itsdangerous==2.1.2
pymongo==4.6.3
jq==1.6.0

python-multipart==0.0.7
python-multipart==0.0.18
PyJWT[crypto]==2.8.0
bcrypt==4.2.0

Expand Down
2 changes: 1 addition & 1 deletion docker-compose.local-production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ services:
environment:
- ROSALUTION_ENV=production
- MONGODB_HOST=rosalution-db
entrypoint: ['/bin/sh', '-c', './entrypoint-init.sh']
command: ['./etc/entrypoint-init.sh']
labels:
- "traefik.enable=true"
- "traefik.docker.network=rosalution-network"
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ services:
- ROSALUTION_ENV=production
- MONGODB_HOST=rosalution-db
- CAS_LOGIN_ENABLE=True
entrypoint: ['/bin/sh', '-c', './entrypoint-init.sh']
command: ['./etc/entrypoint-init.sh']
deploy:
labels:
- "traefik.enable=true"
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ services:
- ./backend:/app
environment:
- MONGODB_HOST=rosalution-db
entrypoint: ['/bin/sh', '-c', './etc/entrypoint-init.sh --reload']
command: ['./etc/entrypoint-init.sh', '--reload']
networks:
- rosalution-network
labels:
Expand Down
27 changes: 0 additions & 27 deletions frontend/.eslintrc.cjs

This file was deleted.

113 changes: 113 additions & 0 deletions frontend/eslint-config-cgds.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
import stylistic from '@stylistic/eslint-plugin-js';

export default [{
plugins: {
'@stylistic/js': stylistic,
},
rules: {
// Possible Errors
'no-cond-assign': 'off',
'no-irregular-whitespace': 'error',
'no-unexpected-multiline': 'error',

// Best Practices
'curly': ['error', 'multi-line'],
'guard-for-in': 'error',
'no-caller': 'error',
'no-extend-native': 'error',
'no-extra-bind': 'error',
'no-invalid-this': 'off',
'no-multi-str': 'error',
'no-new-wrappers': 'error',
'no-throw-literal': 'error',
'no-with': 'error',
'prefer-promise-reject-errors': 'error',

// Variables
'no-unused-vars': ['error', {args: 'none'}],

// Stylistic
'@stylistic/js/array-bracket-newline': 'off',
'@stylistic/js/array-bracket-spacing': ['error', 'never'],
'@stylistic/js/array-element-newline': 'off',
'@stylistic/js/block-spacing': ['error', 'never'],
'@stylistic/js/brace-style': 'error',
'camelcase': ['error', {properties: 'never'}],
'@stylistic/js/comma-dangle': ['error', 'always-multiline'],
'@stylistic/js/comma-spacing': 'error',
'@stylistic/js/comma-style': 'error',
'@stylistic/js/computed-property-spacing': 'error',
'@stylistic/js/eol-last': 'error',
'@stylistic/js/func-call-spacing': 'error',
'@stylistic/js/indent': [
'error', 2, {
'CallExpression': {
'arguments': 2,
},
'FunctionDeclaration': {
'body': 1,
'parameters': 2,
},
'FunctionExpression': {
'body': 1,
'parameters': 2,
},
'MemberExpression': 2,
'ObjectExpression': 1,
'SwitchCase': 1,
'ignoredNodes': [
'ConditionalExpression',
],
},
],
'@stylistic/js/key-spacing': 'error',
'@stylistic/js/keyword-spacing': 'error',
'@stylistic/js/linebreak-style': 'error',
'@stylistic/js/max-len': ['error', {
code: 120,
tabWidth: 2,
ignoreUrls: true,
ignorePattern: 'goog.(module|require)',
}],
'new-cap': 'error',
'no-array-constructor': 'error',
'@stylistic/js/no-mixed-spaces-and-tabs': 'error',
'@stylistic/js/no-multiple-empty-lines': ['error', {max: 2}],
'no-new-object': 'error',
'@stylistic/js/no-tabs': 'error',
'@stylistic/js/no-trailing-spaces': 'error',
'@stylistic/js/object-curly-spacing': 'error',
'one-var': ['error', {
var: 'never',
let: 'never',
const: 'never',
}],
'@stylistic/js/operator-linebreak': ['error', 'after'],
'@stylistic/js/padded-blocks': ['error', 'never'],
'@stylistic/js/quote-props': ['error', 'consistent'],
'@stylistic/js/quotes': ['error', 'single', {allowTemplateLiterals: true}],
'@stylistic/js/semi': 'error',
'@stylistic/js/semi-spacing': 'error',
'@stylistic/js/space-before-blocks': 'error',
'@stylistic/js/space-before-function-paren': ['error', {
asyncArrow: 'always',
anonymous: 'never',
named: 'never',
}],
'@stylistic/js/spaced-comment': ['error', 'always'],
'@stylistic/js/switch-colon-spacing': 'error',

// ECMA 2022 rulesets
'@stylistic/js/arrow-parens': ['error', 'always'],
'constructor-super': 'error',
'@stylistic/js/generator-star-spacing': ['error', 'after'],
'no-new-symbol': 'error',
'no-this-before-super': 'error',
'no-var': 'error',
'prefer-const': ['error', {destructuring: 'all'}],
'prefer-rest-params': 'error',
'prefer-spread': 'error',
'rest-spread-spacing': 'error',
'yield-star-spacing': ['error', 'after'],
},
}];
71 changes: 71 additions & 0 deletions frontend/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import js from '@eslint/js';
import pluginVue from 'eslint-plugin-vue';
import globals from 'globals';
import cgds from './eslint-config-cgds.js';


export default [
{
ignores: [
'node_modules/**',
'dist/**',
'test/__mocks__/**',
],
},
js.configs.recommended,
// {
...cgds,
// Temporarily setting only essential rules; will make update after team discussion
// as to which level to increase vuejs linting rules too.
...pluginVue.configs['flat/essential'],
// files: ['src/**/*.js', 'src/**/*.vue', 'test/**/*.spec.js'],
{
languageOptions: {
sourceType: 'module',
ecmaVersion: 2022,
globals: {
...globals.browser,
...globals.node,
process: 'readonly',
},
},
},
{
rules: {
'vue/prop-name-casing': 'off',
'vue/require-default-prop': 'off',
'vue/max-attributes-per-line': ['error', {
'singleline': {
'max': 6,
},
'multiline': {
'max': 2,
},
}],
// Disabling error temporarilly until team can reconvence and make a decision on us moving forward regarding
// this configuration.
'vue/html-self-closing': ['off', {
'html': {
'void': 'never',
'normal': 'always',
'component': 'always',
},
'svg': 'always',
'math': 'always',
}],
// We inconsistently 2 space tab in SFC template section at the template base.
// Will update in future update to set rule and make consistent in seperate PR
// after team discussion.
'vue/html-indent': ['off'],
// 'vue/singleline-html-element-content-newline': ['error', {
// 'ignoreWhenNoAttributes': true,
// 'ignoreWhenEmpty': true,
// 'ignores': ['pre', 'textarea', ...INLINE_ELEMENTS],
// 'externalIgnores': []
// }],
// 'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
// 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
// },
},
},
];
19 changes: 10 additions & 9 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"build": "vite build",
"dev": "vite",
"dev:host": "vite --host 0.0.0.0 --port 80",
"lint": "eslint --ext .js,.vue ./",
"lint:auto": "eslint --ext .js,.vue ./ --fix",
"lint": "eslint ./",
"lint:auto": "eslint ./ --fix",
"serve": "vite preview",
"test:unit": "vitest run",
"test:unit:watch": "vitest",
Expand All @@ -25,16 +25,17 @@
"vue-router": "4.2.5"
},
"devDependencies": {
"@stylistic/eslint-plugin-js": "2.12.1",
"@vitejs/plugin-vue": "5.1.4",
"@vitest/coverage-v8": "2.1.1",
"@vitest/ui": "2.1.1",
"@vitest/coverage-v8": "v3.0.0-beta.2",
"@vitest/ui": "v3.0.0-beta.2",
"@vue/test-utils": "2.4.1",
"eslint": "8.50.0",
"eslint-config-google": "0.14.0",
"eslint-plugin-vue": "9.17.0",
"happy-dom": "14.12.3",
"eslint": "9.16.0",
"eslint-plugin-vue": "9.32.0",
"happy-dom": "15.10.2",
"sinon": "19.0.2",
"vite": "5.4.8",
"vitest": "2.1.1"
"vitest": "v3.0.0-beta.2"

}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<template>
<div class="legend">
<div v-for="status in workflow" :key="status" :data-test="status" class="status" @click="toggleFilter(status)">
<font-awesome-icon :icon="StatusType[status].icon" size="lg" :style="{
color: isFiltered(status)
? `var(${StatusType[status].color})`
: 'var(--rosalution-grey-300)',
}" />
<font-awesome-icon :icon="StatusType[status].icon" size="lg"
:style="{
color: isFiltered(status)
? `var(${StatusType[status].color})`
: 'var(--rosalution-grey-300)',
}"
/>
<p :style="{
color: isFiltered(status)
? 'var(--rosalution-black)'
Expand Down
26 changes: 15 additions & 11 deletions frontend/src/components/AnalysisView/GeneBox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@
<div>
<div class="gene-box-header">
<router-link class="gene-link" :to="{
name: 'annotation',
params: {
analysis_name: this.name,
},
state: {
gene: this.gene,
...(variants.length > 0 ? { variant: getCompleteHgvsVariantName(variants[0]) } : {}),
}
}" data-test="gene-route">
name: 'annotation',
params: {
analysis_name: this.name,
},
state: {
gene: this.gene,
...(variants.length > 0 ? { variant: getCompleteHgvsVariantName(variants[0]) } : {}),
}
}"
data-test="gene-route"
>
<font-awesome-icon icon="angles-right" size="sm" />
<h2 data-test="gene-name"> {{ gene }} </h2>
</router-link>
Expand All @@ -30,13 +32,15 @@
gene: this.gene,
variant: getCompleteHgvsVariantName(variant),
},
}" :data-test="`variant-route-${index}`">
}"
:data-test="`variant-route-${index}`">
<font-awesome-icon icon="angles-right" size="sm" />
<span class="variant-transcript">{{ variant.hgvs_variant.split(':')[0] }}:</span>
<span>{{ variant.c_dot }}</span>
<span v-if="variant.p_dot">({{ variant.p_dot }})</span>
</router-link>
<font-awesome-icon :icon="['far', 'copy']" class="copy-icon" @click="copyToClipboard(variant.hgvs_variant)"
<font-awesome-icon :icon="['far', 'copy']" class="copy-icon"
@click="copyToClipboard(variant.hgvs_variant)"
data-test="copy-button" />
<span class="genomic-build"> {{ getBuild(variant.build) }} </span>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,16 @@
Attach
</button>
<font-awesome-icon v-if="!isDataUnavailable" :icon="typeIcon" size="lg" />
<div v-if="!isDataUnavailable && content.type == 'file'" @click="$emit('download', content)" target="_blank"
rel="noreferrer noopener" class="attachment-name">
<div v-if="!isDataUnavailable && content.type == 'file'" @click="$emit('download', content)"
target="_blank" rel="noreferrer noopener"
class="attachment-name"
>
{{ content.name }}
</div>
<a v-if="!isDataUnavailable && content.type == 'link'" :href="content.data" target="_blank"
rel="noreferrer noopener" class="attachment-name">
<a v-if="!isDataUnavailable && content.type == 'link'" :href="content.data"
target="_blank" rel="noreferrer noopener"
class="attachment-name"
>
{{ content.name }}
</a>
</div>
Expand Down
Loading

0 comments on commit e988603

Please sign in to comment.