diff --git a/.eslintrc.js b/.eslintrc.js index 568a385..ca98568 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -8,7 +8,7 @@ module.exports = { extends: [ 'eslint:recommended', 'plugin:@typescript-eslint/recommended', - 'plugin:prettier/recommended', + 'prettier', ], root: true, env: { diff --git a/.github/workflows/deploy-manually.yml b/.github/workflows/deploy-manually.yml index 681ee97..2306da9 100644 --- a/.github/workflows/deploy-manually.yml +++ b/.github/workflows/deploy-manually.yml @@ -13,6 +13,11 @@ on: - stg - stg2 - prd + push_to_dockerhub: + description: "Push image to Dockerhub?" + required: true + type: boolean + default: false jobs: extract_environment: @@ -39,11 +44,11 @@ jobs: new_release_version: ${{ (steps.semantic.outputs.new_release_published == 'true' && steps.semantic.outputs.new_release_version) || (github.event_name == 'workflow_dispatch' && '0.0.0') }} steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - if: github.event_name != 'workflow_dispatch' name: Semantic Release - uses: cycjimmy/semantic-release-action@v3 + uses: cycjimmy/semantic-release-action@v4 id: semantic with: extra_plugins: | @@ -76,7 +81,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Update Pip run: | @@ -95,14 +100,14 @@ jobs: python3 -m pip install awsebcli --upgrade - name: Configure AWS Region - uses: aws-actions/configure-aws-credentials@v1-node16 + uses: aws-actions/configure-aws-credentials@v4 id: aws with: aws-region: us-east-1 - name: Login to AWS ECR id: login_ecr - uses: aws-actions/amazon-ecr-login@v1 + uses: aws-actions/amazon-ecr-login@v2 - name: Build, Tag, and Push Image to AWS ECR env: @@ -113,6 +118,23 @@ jobs: docker-compose -f build.docker-compose.yml build docker-compose -f build.docker-compose.yml push + - name: Login to Docker Hub + if: ${{inputs.push_to_dockerhub}} + uses: docker/login-action@v2 + with: + username: dadosfera + password: ${{ secrets.DOCKERHUB_PASSWORD }} + + - name: Build, Tag, and Push Image to Dockerhub + if: ${{inputs.push_to_dockerhub}} + env: + ENV: ${{ needs.extract_environment.outputs.environment }} + IMAGE_TAG: ${{ needs.semantic_release.outputs.new_release_version }} + ACCOUNT_ID: ${{ steps.aws.outputs.aws-account-id }} + run: | + docker-compose -f build.docker-compose.dockerhub.yml build + docker-compose -f build.docker-compose.dockerhub.yml push + - name: Create ZIP file to Deploy AWS Beanstalk env: ENV: ${{ needs.extract_environment.outputs.environment }} @@ -146,7 +168,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Extract Docs BlockId and PageId env: diff --git a/.vscode/launch.json b/.vscode/launch.json index 94770e3..31fd46b 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -12,6 +12,7 @@ "start:debug" ], "runtimeExecutable": "npm", + "runtimeVersion": "18.10.0", "skipFiles": [ "/**" ], diff --git a/build.docker-compose.dockerhub.yml b/build.docker-compose.dockerhub.yml new file mode 100644 index 0000000..7c21c52 --- /dev/null +++ b/build.docker-compose.dockerhub.yml @@ -0,0 +1,5 @@ +version: "3.8" +services: + maestro: + build: . + image: dadosfera/maestro_${ENV}:${IMAGE_TAG} \ No newline at end of file diff --git a/docker-compose.dockerhub.yml b/docker-compose.dockerhub.yml new file mode 100644 index 0000000..6747892 --- /dev/null +++ b/docker-compose.dockerhub.yml @@ -0,0 +1,29 @@ +version: "3.8" +services: + maestro: + image: dadosfera/maestro_${ENV}:${IMAGE_TAG} + container_name: maestro + restart: always + ports: + - 3333:3333 + env_file: + - .env + + node_exporter: + image: ${NODE_EXPORTER_URL} + container_name: node_exporter + restart: always + volumes: + - /proc:/host/proc:ro + - /sys:/host/sys:ro + - /:/rootfs:ro + - /run/dbus/system_bus_socket:/var/run/dbus/system_bus_socket:ro + command: + - '--path.procfs=/host/proc' + - '--path.rootfs=/rootfs' + - '--path.sysfs=/host/sys' + - '--collector.filesystem.ignored-mount-points=^/(sys|proc|dev|host|etc)($$|/)' + - '--collector.systemd' + - '--collector.processes' + network_mode: host + pid: host diff --git a/docsfera.json b/docsfera.json index d8d8575..4428699 100644 --- a/docsfera.json +++ b/docsfera.json @@ -2688,6 +2688,45 @@ ] } }, + "/pipelinesV2/monitoring-dashboard": { + "get": { + "operationId": "PipelinesController_getMonitoringDashboard", + "parameters": [ + { + "name": "dadosfera-lang", + "in": "header", + "required": false, + "schema": { + "enum": [ + "pt-br", + "en-us" + ], + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "object" + } + } + } + } + }, + "tags": [ + "PipelinesV2" + ], + "security": [ + { + "access-token": [] + } + ] + } + }, "/pipelinesV2": { "post": { "operationId": "PipelinesController_create", diff --git a/package-lock.json b/package-lock.json index d9fda7b..a89f38d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6770,6 +6770,12 @@ "integrity": "sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==", "dev": true }, + "node_modules/graphemer": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/graphemer/-/graphemer-1.4.0.tgz", + "integrity": "sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==", + "dev": true + }, "node_modules/has": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", @@ -8902,6 +8908,12 @@ "integrity": "sha512-Tj+HTDSJJKaZnfiuw+iaF9skdPpTo2GtEly5JHnWV/hfv2Qj/9RKsGISQtLh2ox3l5EAGw487hnBee0sIJ6v2g==", "dev": true }, + "node_modules/natural-compare-lite": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/natural-compare-lite/-/natural-compare-lite-1.4.0.tgz", + "integrity": "sha512-Tj+HTDSJJKaZnfiuw+iaF9skdPpTo2GtEly5JHnWV/hfv2Qj/9RKsGISQtLh2ox3l5EAGw487hnBee0sIJ6v2g==", + "dev": true + }, "node_modules/negotiator": { "version": "0.6.3", "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz", diff --git a/src/modules/auth/auth.service.ts b/src/modules/auth/auth.service.ts index 6db5c8c..8822086 100644 --- a/src/modules/auth/auth.service.ts +++ b/src/modules/auth/auth.service.ts @@ -164,6 +164,8 @@ export class AuthClientService implements OnModuleInit { async oauthSignIn(data: { username: string; token: string }) { const { username, token } = data; - return lastValueFrom(this.authService.AuthOauthSignIn({ token, username })); + return lastValueFrom( + this.authService.AuthOauthSignIn({ token, username, refreshToken: '' }), + ); } } diff --git a/src/modules/pipelinesV2/pipelines.controller.ts b/src/modules/pipelinesV2/pipelines.controller.ts index 9e75e93..512a705 100644 --- a/src/modules/pipelinesV2/pipelines.controller.ts +++ b/src/modules/pipelinesV2/pipelines.controller.ts @@ -14,6 +14,7 @@ import { Patch, HttpException, BadRequestException, + CacheTTL, } from '@nestjs/common'; import { ApiCreatedResponse, @@ -86,6 +87,18 @@ export class PipelinesController { this.logger = dadosferaLogger.logger; } + @Get('monitoring-dashboard') + async getMonitoringDashboard(@User() user: RequestUser) { + this.logger.info('PipelinesController - getMonitoringDashboard', { user }); + + const metadata = PackTheMetadata(user); + + const response = + await this.pipelinesClientService.getMonitoringDashboardUrl(metadata); + + return response; + } + @Post() @ApiCreatedResponse({ type: IPipelineV2 }) async create( diff --git a/src/modules/pipelinesV2/pipelines.service.ts b/src/modules/pipelinesV2/pipelines.service.ts index 9d545c6..9b9be63 100644 --- a/src/modules/pipelinesV2/pipelines.service.ts +++ b/src/modules/pipelinesV2/pipelines.service.ts @@ -321,4 +321,22 @@ export class PipelinesService implements OnModuleInit { ); }); } + + async getMonitoringDashboardUrl(metadata: Metadata) { + this.logger.info('PipelinesClientService - getMonitoringDashboardUrl'); + + const res = await lastValueFrom( + this.pipelineReadService.PipelineV2GetDashboardUrl( + { + dashboard_id: '83', + exp: '15m', + metabase_customer_name: 'dadosferatech', + }, + metadata, + ), + ); + this.logger.info('Done'); + + return res; + } }