From 0025ca79429291082eea5e07b2aad9447a96433b Mon Sep 17 00:00:00 2001 From: Elena Moshnikova Date: Sun, 13 Oct 2024 10:41:44 +0300 Subject: [PATCH 1/6] Update README.md --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 0a037640c..cea610a26 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,6 @@ Product Vision https://github.com/Brain-up/brn/wiki/Product-Vision. - Scientific basis of the project: https://www.ncbi.nlm.nih.gov/pmc/articles/PMC6417420/ ## Published ARTICLES about our project -- https://aw.club/global/en/blog/volunteer/brain-up?utm_source=telegram&utm_medium=social&utm_campaign=ongoing 11.08.2022 (russian, english) will be fixed soon - https://wearecommunity.io/communities/community-platform/articles/753 01.12.2020 russian - https://habr.com/ru/company/epam_systems/blog/530824 01.12.2020 - https://anywhere.epam.com/volunteer/pages-1/brainApp.html (will be fixed soon) 05.05.2020 From 310cfcae2b9780740554396271444388258ce8da Mon Sep 17 00:00:00 2001 From: Elena Moshnikova Date: Wed, 16 Oct 2024 19:20:07 +0300 Subject: [PATCH 2/6] 000 small refactrnig (#2621) * 2508: fix and switch on job which clear unused pictures * 2508: fix and switch on job which clear unused pictures * 2590 fix version update * 2590 fix version update --------- Co-authored-by: Elena Moshnikova --- src/main/kotlin/com/epam/brn/config/SwaggerConfig.kt | 2 +- src/main/kotlin/com/epam/brn/service/TokenHelperUtils.kt | 3 +-- src/main/resources/initFiles/series_sentences_ru.csv | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/com/epam/brn/config/SwaggerConfig.kt b/src/main/kotlin/com/epam/brn/config/SwaggerConfig.kt index d2f386855..6d4d4cc91 100644 --- a/src/main/kotlin/com/epam/brn/config/SwaggerConfig.kt +++ b/src/main/kotlin/com/epam/brn/config/SwaggerConfig.kt @@ -21,7 +21,7 @@ class SwaggerConfig { .contact( Contact() .name("Elena.Moshnikova") - .url("https://www.epam.com/") + .url("https://t.me/ElenaLovesSpb") .email("brainupproject@yandex.ru") ) diff --git a/src/main/kotlin/com/epam/brn/service/TokenHelperUtils.kt b/src/main/kotlin/com/epam/brn/service/TokenHelperUtils.kt index 070f99528..1a2b3ebf3 100644 --- a/src/main/kotlin/com/epam/brn/service/TokenHelperUtils.kt +++ b/src/main/kotlin/com/epam/brn/service/TokenHelperUtils.kt @@ -10,9 +10,8 @@ class TokenHelperUtils { fun getBearerToken(request: HttpServletRequest): String? { var bearerToken: String? = null val authorization = request.getHeader("Authorization") - if (StringUtils.hasText(authorization) && authorization.startsWith("Bearer ")) { + if (StringUtils.hasText(authorization) && authorization.startsWith("Bearer ")) bearerToken = authorization.substring(7) - } return bearerToken } } diff --git a/src/main/resources/initFiles/series_sentences_ru.csv b/src/main/resources/initFiles/series_sentences_ru.csv index 23d3dd00c..a4e270f56 100644 --- a/src/main/resources/initFiles/series_sentences_ru.csv +++ b/src/main/resources/initFiles/series_sentences_ru.csv @@ -50,7 +50,7 @@ level,code,exerciseName,orderNumber,words 12,sentence_with_3_words,Пойми предложение из 3 слов,2,(();(мудрая великая);(волшебница фея);(прощает поёт);();()) 13,sentence_with_3_words,Пойми предложение из 3 слов,2,(();(великодушный трусливый);(рыцарь кузнец);(спрашивает отвечает);();()) 13,sentence_with_3_words,Пойми предложение из 3 слов,2,(();(смелая храбрая);(муха лягушка);(сражается борется);();()) -14,sentence_with_3_words,Пойми предложение из 3 слов,2,((три семь);();(поросёнка волчонка);(строят дуют);();()) +14,sentence_with_3_words,Пойми предложение из 3 слов,2,((три четыре);();(поросёнка волчонка);(строят дуют);();()) 15,sentence_with_3_words,Пойми предложение из 3 слов,2,((двенадцать семнадцать);();(лебедей червяков);(летят ползут);();()) 16,sentence_with_3_words,Пойми предложение из 3 слов,2,((три два);();(дядюшки зайца);(бегут стоят);();()) 17,sentence_with_3_words,Пойми предложение из 3 слов,2,((три четыре);();(зайчонка лисы);(пищат шумят);();()) From 149143c20ef18ef417ee620d1b33cd72069b1b13 Mon Sep 17 00:00:00 2001 From: Dmitriy Stoyanov Date: Sat, 26 Oct 2024 17:19:12 +0300 Subject: [PATCH 3/6] Update docker-compose to use as plugin instead of separate tool (#2626) --- .github/workflows/certbot-update-cert.yml | 6 +++--- .github/workflows/create_cert.yml | 2 +- .github/workflows/docker-build-push-redeploy.yml | 6 +++--- .github/workflows/instances-redeploy.yml_tmp | 6 +++--- Dockerfile | 2 +- Dockerfile_frontend | 4 ++-- Dockerfile_frontend_with_tls | 4 ++-- Makefile | 8 ++++---- README.md | 4 ++-- docker-compose-run.yml | 15 +++++++-------- docker-compose-unit-test.yml | 1 - docker-compose-with-secret.yml | 1 - docker-compose.yml | 1 - 13 files changed, 28 insertions(+), 32 deletions(-) diff --git a/.github/workflows/certbot-update-cert.yml b/.github/workflows/certbot-update-cert.yml index 786f85b16..01edccaf2 100644 --- a/.github/workflows/certbot-update-cert.yml +++ b/.github/workflows/certbot-update-cert.yml @@ -26,7 +26,7 @@ jobs: API_GITHUB_TOKEN: ${{ secrets.API_GITHUB_TOKEN }} - name: Update certs run: | - docker-compose pull - docker-compose run --rm certbot renew --allow-subset-of-names - docker-compose restart brn_fe_with_tls + docker compose pull + docker compose run --rm certbot renew --allow-subset-of-names + docker compose restart brn_fe_with_tls docker image prune -af diff --git a/.github/workflows/create_cert.yml b/.github/workflows/create_cert.yml index 113d343d5..a2506de12 100644 --- a/.github/workflows/create_cert.yml +++ b/.github/workflows/create_cert.yml @@ -22,4 +22,4 @@ jobs: API_GITHUB_TOKEN: ${{ secrets.API_GITHUB_TOKEN }} - name: Create cert run: | - docker-compose run --rm certbot certonly --webroot --webroot-path=/var/www/html --email brainupproject@yandex.ru -d brainup.fun + docker compose run --rm certbot certonly --webroot --webroot-path=/var/www/html --email brainupproject@yandex.ru -d brainup.fun diff --git a/.github/workflows/docker-build-push-redeploy.yml b/.github/workflows/docker-build-push-redeploy.yml index 1f501a15b..90b9fd0fe 100644 --- a/.github/workflows/docker-build-push-redeploy.yml +++ b/.github/workflows/docker-build-push-redeploy.yml @@ -67,10 +67,10 @@ jobs: # Link 2: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idstepsif - name: Redeploy backend run: | - docker-compose pull - docker-compose up -d --no-deps brn + docker compose pull + docker compose up -d --no-deps brn - name: Redeploy frontend selectel if: matrix.runners == 'selectel' - run: docker-compose up -d --no-deps brn_fe_with_tls + run: docker compose up -d --no-deps brn_fe_with_tls - name: Remove old images run: docker image prune -af diff --git a/.github/workflows/instances-redeploy.yml_tmp b/.github/workflows/instances-redeploy.yml_tmp index 719a9f2a6..36072deb5 100644 --- a/.github/workflows/instances-redeploy.yml_tmp +++ b/.github/workflows/instances-redeploy.yml_tmp @@ -27,6 +27,6 @@ jobs: POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }} - name: Redeploy application run: | - docker-compose pull - docker-compose down - docker-compose up -d + docker compose pull + docker compose down + docker compose up -d diff --git a/Dockerfile b/Dockerfile index d3aded2f5..ea6142eba 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM gradle:jdk17 as builder +FROM gradle:jdk17 AS builder WORKDIR /brn ADD . /brn diff --git a/Dockerfile_frontend b/Dockerfile_frontend index e97286b9f..7304ee2f5 100644 --- a/Dockerfile_frontend +++ b/Dockerfile_frontend @@ -1,4 +1,4 @@ -FROM node:12 as build-frontend +FROM node:12 AS build-frontend ARG FIREBASE_PROJECT_ID ENV FIREBASE_PROJECT_ID ${FIREBASE_PROJECT_ID:-} ARG FIREBASE_AUTH_DOMAIN @@ -10,7 +10,7 @@ WORKDIR /src RUN yarn RUN node node_modules/ember-cli/bin/ember deploy production -FROM node:12 as build-frontend-angular +FROM node:12 AS build-frontend-angular COPY frontend-angular/ /src/ WORKDIR /src RUN npm ci diff --git a/Dockerfile_frontend_with_tls b/Dockerfile_frontend_with_tls index 3874d34c1..433cd13e7 100644 --- a/Dockerfile_frontend_with_tls +++ b/Dockerfile_frontend_with_tls @@ -1,10 +1,10 @@ -FROM node:12 as build-frontend +FROM node:12 AS build-frontend COPY frontend/ /src/ WORKDIR /src RUN yarn RUN node node_modules/ember-cli/bin/ember deploy production -FROM node:12 as build-frontend-angular +FROM node:12 AS build-frontend-angular COPY frontend-angular/ /src/ WORKDIR /src RUN npm ci diff --git a/Makefile b/Makefile index a224ef5f5..b3f615eae 100644 --- a/Makefile +++ b/Makefile @@ -12,15 +12,15 @@ docker_clean_app_images: stop docker rmi brn_test db_brn brn docker_clean_test_containers: - docker-compose -f docker-compose-unit-test.yml down + docker compose -f docker-compose-unit-test.yml down docker_unit_test: clean - docker-compose -f docker-compose-unit-test.yml up --build --force-recreate --exit-code-from brn-test + docker compose -f docker-compose-unit-test.yml up --build --force-recreate --exit-code-from brn-test start: - docker-compose up --build --force-recreate + docker compose up --build --force-recreate stop: - docker-compose down + docker compose down restart: clean stop start diff --git a/README.md b/README.md index cea610a26..9702eb0ff 100644 --- a/README.md +++ b/README.md @@ -127,11 +127,11 @@ Note that if you are using IntelliJ, you may want to use version 2019.2 and late (back-end part and front-end parts, but it is rather slow. it is better to use GitPod) From console, from project's folder, execute: ```bash -docker-compose up --build +docker compose up --build ``` Alternatively, use daemon mode (no console output): ```bash -docker-compose up --build -d +docker compose up --build -d ``` Local REST API will be accessible at http://localhost:8081/api/swagger-ui.html Public is always here https://brainup.site/admin/swagger (login with ADMIN role user) diff --git a/docker-compose-run.yml b/docker-compose-run.yml index 0401b4032..b3425f92f 100644 --- a/docker-compose-run.yml +++ b/docker-compose-run.yml @@ -1,4 +1,3 @@ -version: '3.8' services: db_brn: image: postgres:13 @@ -33,13 +32,13 @@ services: - firebase_config_json depends_on: - db_brn - brn_fe: - image: brainup/brn-frontend:latest - container_name: brn_fe -# ports: -# - 80:80 - depends_on: - - brn +# brn_fe: +# image: brainup/brn-frontend:latest +# container_name: brn_fe +# # ports: +# # - 80:80 +# depends_on: +# - brn brn_fe_with_tls: image: brainup/brn-frontend-with-tls:latest container_name: brn_fe_with_tls diff --git a/docker-compose-unit-test.yml b/docker-compose-unit-test.yml index ff4ccf698..63d012cb0 100644 --- a/docker-compose-unit-test.yml +++ b/docker-compose-unit-test.yml @@ -1,4 +1,3 @@ -version: '3.8' services: db: image: postgres:13 diff --git a/docker-compose-with-secret.yml b/docker-compose-with-secret.yml index 49660c0fd..0f8933f09 100644 --- a/docker-compose-with-secret.yml +++ b/docker-compose-with-secret.yml @@ -1,4 +1,3 @@ -version: '3.8' services: db_brn: image: postgres:13 diff --git a/docker-compose.yml b/docker-compose.yml index 1f10d5bb6..a2737bfef 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,4 +1,3 @@ -version: '3.8' services: db_brn: container_name: db_brn From a51faf3e7598e853aa1aecdc5222559ddee50e26 Mon Sep 17 00:00:00 2001 From: Elena Moshnikova Date: Sat, 26 Oct 2024 17:33:11 +0300 Subject: [PATCH 4/6] 000 refactor for devpos check (#2622) * 2508: fix and switch on job which clear unused pictures * 2508: fix and switch on job which clear unused pictures * 2590 fix version update * refactor for devops check --------- Co-authored-by: Elena Moshnikova Co-authored-by: Dmitriy Stoyanov --- .../kotlin/com/epam/brn/config/FirebaseConfig.kt | 2 -- .../kotlin/com/epam/brn/config/GoogleCloudConfig.kt | 13 +++++++------ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/main/kotlin/com/epam/brn/config/FirebaseConfig.kt b/src/main/kotlin/com/epam/brn/config/FirebaseConfig.kt index 64ceac36a..f72d74920 100644 --- a/src/main/kotlin/com/epam/brn/config/FirebaseConfig.kt +++ b/src/main/kotlin/com/epam/brn/config/FirebaseConfig.kt @@ -20,11 +20,9 @@ class FirebaseConfig { fun firebaseApp(): FirebaseApp { if (FirebaseApp.getApps().isEmpty()) { val refreshToken = FileInputStream(firebaseCredentialsPath) - val options = FirebaseOptions.builder() .setCredentials(GoogleCredentials.fromStream(refreshToken)) .build() - FirebaseApp.initializeApp(options) } return FirebaseApp.getInstance() diff --git a/src/main/kotlin/com/epam/brn/config/GoogleCloudConfig.kt b/src/main/kotlin/com/epam/brn/config/GoogleCloudConfig.kt index 06ca4830f..0957a74d1 100644 --- a/src/main/kotlin/com/epam/brn/config/GoogleCloudConfig.kt +++ b/src/main/kotlin/com/epam/brn/config/GoogleCloudConfig.kt @@ -4,7 +4,6 @@ import com.google.auth.oauth2.GoogleCredentials import com.google.cloud.storage.Storage import com.google.cloud.storage.StorageOptions import com.google.common.collect.Lists -import org.apache.logging.log4j.kotlin.logger import org.springframework.beans.factory.annotation.Value import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty import org.springframework.context.annotation.Configuration @@ -20,8 +19,6 @@ class GoogleCloudConfig( @Value("\${cloud.expireAfterDuration}") expireAfterDuration: String ) { - private val log = logger() - @Value("\${google.bucketName}") val bucketName: String = "" @Value("\${google.bucketLink}") @@ -31,11 +28,15 @@ class GoogleCloudConfig( final var storage: Storage? init { - val credentials = GoogleCredentials.fromStream(FileInputStream(credentialsPath)) + val credentials = GoogleCredentials + .fromStream(FileInputStream(credentialsPath)) .createScoped(Lists.newArrayList(credentialScope)) storage = - StorageOptions.newBuilder().setCredentials(credentials).setProjectId(projectId) - .build().getService() + StorageOptions.newBuilder() + .setCredentials(credentials) + .setProjectId(projectId) + .build() + .service expireAfter = Duration.parse(expireAfterDuration) } } From 4b9cc6287972c776b681b1606b6ff6dbd5887851 Mon Sep 17 00:00:00 2001 From: Elena Moshnikova Date: Sat, 26 Oct 2024 17:50:23 +0300 Subject: [PATCH 5/6] 001 for devops check (#2625) * 2508: fix and switch on job which clear unused pictures * 2508: fix and switch on job which clear unused pictures * 2590 fix version update * refactor delete extra code --------- Co-authored-by: Elena Moshnikova Co-authored-by: Dmitriy Stoyanov --- .../epam/brn/service/AudiometryHistoryService.kt | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main/kotlin/com/epam/brn/service/AudiometryHistoryService.kt b/src/main/kotlin/com/epam/brn/service/AudiometryHistoryService.kt index a3733976e..f939e6921 100644 --- a/src/main/kotlin/com/epam/brn/service/AudiometryHistoryService.kt +++ b/src/main/kotlin/com/epam/brn/service/AudiometryHistoryService.kt @@ -26,18 +26,20 @@ class AudiometryHistoryService( val headphonesFromUser = getSpecificHeadphonesFromCurrentUser(currentUser.headphones, request.headphones) val audiometryHistory = request.toEntity(currentUser, audiometryTask, headphonesFromUser) val savedAudiometryHistory = audiometryHistoryRepository.save(audiometryHistory) - if (!request.sinAudiometryResults.isNullOrEmpty()) { + if (!request.sinAudiometryResults.isNullOrEmpty()) request.sinAudiometryResults!!.forEach { (frequency, sound) -> sinAudiometryResultRepository.save( - SinAudiometryResult(frequency = frequency, soundLevel = sound, audiometryHistory = savedAudiometryHistory) + SinAudiometryResult( + frequency = frequency, + soundLevel = sound, + audiometryHistory = savedAudiometryHistory + ) ) } - } return savedAudiometryHistory.id!! } private fun getSpecificHeadphonesFromCurrentUser(headphones: MutableSet, headphonesId: Long?) = - headphones.find() { entity -> - entity.id == headphonesId - } ?: throw IllegalArgumentException("Current user has ho headphones with id=$headphonesId") + headphones.find { entity -> entity.id == headphonesId } + ?: throw IllegalArgumentException("Current user has ho headphones with id=$headphonesId") } From 1cf4d44cd6e342e0f37cd45bfb092d74ba211af6 Mon Sep 17 00:00:00 2001 From: Dmitriy Stoyanov Date: Sat, 26 Oct 2024 18:25:23 +0300 Subject: [PATCH 6/6] Remove separate frontend image from building process (#2628) Right now we have two images for frontend app - one with tls and one without. Right now without tls not used. So to reduce time of building on master branch, I've decided to remove building frontend app without tls, as it is not used anymore after removal of epam instance --- .github/workflows/docker-build-push-redeploy.yml | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/.github/workflows/docker-build-push-redeploy.yml b/.github/workflows/docker-build-push-redeploy.yml index 90b9fd0fe..ada03f308 100644 --- a/.github/workflows/docker-build-push-redeploy.yml +++ b/.github/workflows/docker-build-push-redeploy.yml @@ -16,17 +16,6 @@ jobs: name: brainup/brn-backend username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - build_and_publish_frontend: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Publish to Registry brainup/brn-frontend - uses: elgohr/Publish-Docker-Github-Action@master - with: - name: brainup/brn-frontend - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - dockerfile: Dockerfile_frontend build_and_publish_frontend_with_tls: runs-on: ubuntu-latest steps: @@ -39,7 +28,7 @@ jobs: password: ${{ secrets.DOCKER_PASSWORD }} dockerfile: Dockerfile_frontend_with_tls redeploy_instance: - needs: [ build_and_publish_backend, build_and_publish_frontend, build_and_publish_frontend_with_tls] + needs: [ build_and_publish_backend, build_and_publish_frontend_with_tls] runs-on: ${{ matrix.runners }} strategy: matrix: