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..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: @@ -67,10 +56,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 1dcdf8bf4..f9889021b 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 @@ -128,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 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) } } 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/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") } 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,((три четыре);();(зайчонка лисы);(пищат шумят);();())