diff --git a/.github/workflows/push-master-environment.yaml b/.github/workflows/push-master-environment.yaml index 0bae43a9..c93de1b4 100644 --- a/.github/workflows/push-master-environment.yaml +++ b/.github/workflows/push-master-environment.yaml @@ -71,21 +71,24 @@ jobs: DB_SCHEMA: ${{ secrets.DB_SCHEMA }} EOS_API_ENDPOINT: https://bp.cryptolions.io VIRTUAL_HOST: 0.0.0.0 - VIRTUAL_PORT: "3005" + VIRTUAL_PORT: "9090" # hasura HASURA_GRAPHQL_DATABASE_URL: ${{ secrets.HASURA_GRAPHQL_DATABASE_URL }} HASURA_GRAPHQL_MIGRATIONS_DIR: /hasura-migrations HASURA_GRAPHQL_ADMIN_SECRET: ${{ secrets.HASURA_GRAPHQL_ADMIN_SECRET }} HASURA_GRAPHQL_UNAUTHORIZED_ROLE: ${{ secrets.HASURA_GRAPHQL_UNAUTHORIZED_ROLE }} + HASURA_GRAPHQL_ACTION_BASE_URL: ${{secrets.HASURA_GRAPHQL_ACTION_BASE_URL}} # pgweb DATABASE_URL: ${{ secrets.DATABASE_URL }} - - name: Deploy kubernetes files - uses: Consensys/kubernetes-action@master + - name: Setup and deploy kubernetes environment + uses: steebchen/kubectl@master env: KUBE_CONFIG_DATA: ${{ secrets.KUBE_CONFIG_DATA }} + NAMESPACE: mainnet-eosrate + K8S_BUILD_DIR: build_k8s with: - args: apply -f build_k8s -n mainnet-eosrate + args: version && make deploy-kubernetes - name: Create Release id: create_release diff --git a/.github/workflows/push-staging-environment.yaml b/.github/workflows/push-staging-environment.yaml index f8487705..ef707a55 100644 --- a/.github/workflows/push-staging-environment.yaml +++ b/.github/workflows/push-staging-environment.yaml @@ -71,23 +71,21 @@ jobs: DB_SCHEMA: ${{ secrets.DB_SCHEMA }} EOS_API_ENDPOINT: https://jungle3.cryptolions.io VIRTUAL_HOST: 0.0.0.0 - VIRTUAL_PORT: "3005" + VIRTUAL_PORT: "9090" # hasura HASURA_GRAPHQL_DATABASE_URL: ${{ secrets.HASURA_GRAPHQL_DATABASE_URL }} HASURA_GRAPHQL_MIGRATIONS_DIR: /hasura-migrations HASURA_GRAPHQL_ADMIN_SECRET: ${{ secrets.HASURA_GRAPHQL_ADMIN_SECRET }} HASURA_GRAPHQL_UNAUTHORIZED_ROLE: ${{ secrets.HASURA_GRAPHQL_UNAUTHORIZED_ROLE }} + HASURA_GRAPHQL_ACTION_BASE_URL: ${{secrets.HASURA_GRAPHQL_ACTION_BASE_URL}} # pgweb DATABASE_URL: ${{ secrets.DATABASE_URL }} - - name: Deploy kubernetes files - uses: Consensys/kubernetes-action@master + - name: Setup and deploy kubernetes environment + uses: steebchen/kubectl@master env: KUBE_CONFIG_DATA: ${{ secrets.KUBE_CONFIG_DATA }} + NAMESPACE: jungle-eosrate + K8S_BUILD_DIR: build_k8s with: - args: apply -f build_k8s -n jungle-eosrate - -# - name: Verify deployment -# id: verify_deployment -# run: | -# kubectl rollout status deployment/hapi + args: version && make deploy-kubernetes \ No newline at end of file diff --git a/docker-compose.staging.yml b/docker-compose.staging.yml index 2d191b96..7fa3e69a 100644 --- a/docker-compose.staging.yml +++ b/docker-compose.staging.yml @@ -33,13 +33,13 @@ services: context: ./services/hapi dockerfile: Dockerfile volumes: - - ./services/hapi:/opt/application - - /opt/application/node_modules + - ./services/hapi:/opt/application + - /opt/application/node_modules ports: - - '3005:3005' + - "3005:9090" environment: VIRTUAL_HOST: 0.0.0.0 - VIRTUAL_PORT: 3005 + VIRTUAL_PORT: 9090 DB_USER: user DB_PASSWORD: pass DB_PORT: 5432 @@ -49,7 +49,7 @@ services: EOS_API_ENDPOINT: "https://jungle.eosio.cr" depends_on: - - postgres + - postgres demux: container_name: eosrate_demux @@ -91,6 +91,7 @@ services: HASURA_GRAPHQL_MIGRATIONS_DIR: /hasura-migrations VIRTUAL_HOST: staging.eosrate.io VIRTUAL_PORT: 8088 + HASURA_GRAPHQL_ACTION_BASE_URL: http://hapi:9090 volumes: - ./services/hasura/migrations:/hasura-migrations # mount hasura migrations folder command: diff --git a/docker-compose.yml b/docker-compose.yml index fdf64c9d..3d23c4ef 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -36,10 +36,10 @@ services: - ./services/hapi:/opt/application - /opt/application/node_modules # prevents host/container conflicts ports: - - "3005:3005" + - "3005:9090" environment: VIRTUAL_HOST: 0.0.0.0 - VIRTUAL_PORT: 3005 + VIRTUAL_PORT: 9090 DB_USER: user DB_PASSWORD: pass DB_PORT: 5432 @@ -92,8 +92,8 @@ services: environment: HASURA_GRAPHQL_DATABASE_URL: postgres://user:pass@postgres:5432/eosrate?sslmode=disable HASURA_GRAPHQL_MIGRATIONS_DIR: /hasura-migrations - HASURA_GRAPHQL_ADMIN_SECRET: "${HASURA_GRAPHQL_ADMIN_SECRET}" - HASURA_GRAPHQL_UNAUTHORIZED_ROLE: "${HASURA_GRAPHQL_UNAUTHORIZED_ROLE}" + HASURA_GRAPHQL_ACTION_BASE_URL: http://hapi:9090 + volumes: - ./services/hasura/migrations:/hasura-migrations # mount hasura migrations folder command: diff --git a/kubernetes/configmaps.yaml b/kubernetes/configmaps.yaml index 813ae412..d53bf111 100644 --- a/kubernetes/configmaps.yaml +++ b/kubernetes/configmaps.yaml @@ -38,6 +38,7 @@ data: HASURA_GRAPHQL_MIGRATIONS_DIR: "${HASURA_GRAPHQL_MIGRATIONS_DIR}" HASURA_GRAPHQL_ADMIN_SECRET: "${HASURA_GRAPHQL_ADMIN_SECRET}" HASURA_GRAPHQL_UNAUTHORIZED_ROLE: "${HASURA_GRAPHQL_UNAUTHORIZED_ROLE}" + HASURA_GRAPHQL_ACTION_BASE_URL: "${HASURA_GRAPHQL_ACTION_BASE_URL}" --- apiVersion: v1 kind: ConfigMap diff --git a/kubernetes/cronjob.yaml b/kubernetes/cronjob.yaml index 5dac17e4..14c6c7b1 100644 --- a/kubernetes/cronjob.yaml +++ b/kubernetes/cronjob.yaml @@ -9,29 +9,29 @@ spec: template: spec: containers: - - name: hapi-cronjob - image: ${DOCKER_REGISTRY}/${IMAGE_NAME_HAPI}:${VERSION} - args: - - /bin/sh - - -c - - /usr/bin/node /opt/application/src/libs/sync-bps.js; /usr/bin/node /opt/application/src/libs/sync-proxies.js - env: - - name: DB_HOST - value: postgres - - name: DB_NAME - value: eosrate - - name: DB_PASSWORD - value: pass - - name: DB_PORT - value: "5432" - - name: DB_SCHEMA - value: public - - name: DB_USER - value: user - - name: EOS_API_ENDPOINT - value: https://bp.cryptolions.io - - name: VIRTUAL_HOST - value: 0.0.0.0 - - name: VIRTUAL_PORT - value: "3005" + - name: hapi-cronjob + image: ${DOCKER_REGISTRY}/${IMAGE_NAME_HAPI}:${VERSION} + args: + - /bin/sh + - -c + - /usr/bin/node /opt/application/src/libs/sync-bps.js; /usr/bin/node /opt/application/src/libs/sync-proxies.js + env: + - name: DB_HOST + value: postgres + - name: DB_NAME + value: eosrate + - name: DB_PASSWORD + value: pass + - name: DB_PORT + value: "5432" + - name: DB_SCHEMA + value: public + - name: DB_USER + value: user + - name: EOS_API_ENDPOINT + value: https://bp.cryptolions.io + - name: VIRTUAL_HOST + value: 0.0.0.0 + - name: VIRTUAL_PORT + value: "9090" restartPolicy: Never diff --git a/kubernetes/demux-deployment.yaml b/kubernetes/demux-deployment.yaml deleted file mode 100644 index 6a27ac0f..00000000 --- a/kubernetes/demux-deployment.yaml +++ /dev/null @@ -1,44 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - labels: - app: demux - name: demux -spec: - replicas: 1 - selector: - matchLabels: - app: demux - strategy: - type: Recreate - template: - metadata: - labels: - app: demux - spec: - containers: - - env: - - name: DB_HOST - value: postgres - - name: DB_NAME - value: eosrate - - name: DB_PASSWORD - value: pass - - name: DB_PORT - value: "5432" - - name: DB_SCHEMA - value: public - - name: DB_USER - value: user - - name: EOS_API_ENDPOINT - value: https://bp.cryptolions.io - - name: WAIT_HOSTS - value: postgres:5432, hasura:8080 - - name: WAIT_HOSTS_TIMEOUT - value: "60" - image: eoscostarica506/demux - imagePullPolicy: "Always" - name: eosrate-demux - ports: - - containerPort: 3030 - restartPolicy: Always diff --git a/kubernetes/demux-service.yaml b/kubernetes/demux-service.yaml deleted file mode 100644 index d8824c11..00000000 --- a/kubernetes/demux-service.yaml +++ /dev/null @@ -1,13 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - labels: - app: demux - name: demux -spec: - ports: - - name: "3030" - port: 3030 - targetPort: 3030 - selector: - app: demux diff --git a/makefile b/makefile index a324b508..78ee7997 100644 --- a/makefile +++ b/makefile @@ -54,7 +54,7 @@ deploy-kubernetes: $(K8S_BUILD_DIR) -n $(NAMESPACE) || echo "SSL cert already configured."; @echo "Applying kubernetes files..." @for file in $(shell find $(K8S_BUILD_DIR) -name '*.yaml' | sed 's:$(K8S_BUILD_DIR)/::g'); do \ - kubectl apply -f $(K8S_BUILD_DIR)/$$file -n $(NAMESPACE); \ + kubectl apply -f $(K8S_BUILD_DIR)/$$file -n $(NAMESPACE) || echo "${file} Cannot be updated."; \ done build-docker-images: ##@devops Build docker images diff --git a/services/frontend/.env b/services/frontend/.env index 9e0e9413..e099e17c 100644 --- a/services/frontend/.env +++ b/services/frontend/.env @@ -1,4 +1,4 @@ -REACT_APP_GRAPHQL_HTTP_URL=https://graphql-jungle.eosrate.io/v1alpha1/graphql +REACT_APP_GRAPHQL_HTTP_URL=https://graphql-jungle.eosrate.io/v1/graphql REACT_APP_API_URL=https://jungle.eosio.cr REACT_APP_GRAPHQL_WS_URL=wss://graphql-jungle.eosrate.io/v1alpha1/graphql REACT_APP_EOS_API_URL=https://jungle.eosio.cr diff --git a/services/frontend/.env.staging b/services/frontend/.env.staging index 9e0e9413..2b2a98a6 100644 --- a/services/frontend/.env.staging +++ b/services/frontend/.env.staging @@ -1,6 +1,6 @@ -REACT_APP_GRAPHQL_HTTP_URL=https://graphql-jungle.eosrate.io/v1alpha1/graphql +REACT_APP_GRAPHQL_HTTP_URL=https://graphql-jungle.eosrate.io/v1/graphql REACT_APP_API_URL=https://jungle.eosio.cr -REACT_APP_GRAPHQL_WS_URL=wss://graphql-jungle.eosrate.io/v1alpha1/graphql +REACT_APP_GRAPHQL_WS_URL=wss://graphql-jungle.eosrate.io/v1/graphql REACT_APP_EOS_API_URL=https://jungle.eosio.cr REACT_APP_EOS_API_HOST=jungle.eosio.cr REACT_APP_EOS_API_PORT=443 diff --git a/services/frontend/src/services/graphql.js b/services/frontend/src/services/graphql.js index 129a6c44..8984deda 100644 --- a/services/frontend/src/services/graphql.js +++ b/services/frontend/src/services/graphql.js @@ -7,17 +7,13 @@ import { InMemoryCache } from 'apollo-cache-inmemory' // Create an http link: const httpLink = new HttpLink({ - uri: - process.env.REACT_APP_GRAPHQL_HTTP_URL || - 'http://localhost:8088/v1alpha1/graphql', + uri: process.env.REACT_APP_GRAPHQL_HTTP_URL, credentials: 'same-origin' }) // Create a WebSocket link: const wsLink = new WebSocketLink({ - uri: - process.env.REACT_APP_GRAPHQL_WS_URL || - 'ws://localhost:8088/v1alpha1/graphql', + uri: process.env.REACT_APP_GRAPHQL_WS_URL, options: { reconnect: true } diff --git a/services/hapi/src/index.js b/services/hapi/src/index.js index a1fed60f..422ee614 100644 --- a/services/hapi/src/index.js +++ b/services/hapi/src/index.js @@ -9,7 +9,7 @@ const Hapi = require('@hapi/hapi') const init = async () => { const server = Hapi.server({ - port: VIRTUAL_PORT || 3005, + port: VIRTUAL_PORT || 9090, host: VIRTUAL_HOST || '0.0.0.0' }) diff --git a/services/hasura/migrations/.env b/services/hasura/migrations/.env new file mode 100644 index 00000000..b7125be9 --- /dev/null +++ b/services/hasura/migrations/.env @@ -0,0 +1 @@ +HASURA_GRAPHQL_ACTION_BASE_URL=http://hapi:9090 \ No newline at end of file diff --git a/services/hasura/migrations/metadata.yaml b/services/hasura/migrations/metadata.yaml index 9d71b229..7407f974 100644 --- a/services/hasura/migrations/metadata.yaml +++ b/services/hasura/migrations/metadata.yaml @@ -1,127 +1,127 @@ version: 2 tables: -- table: - schema: public - name: producers - select_permissions: - - role: anonymous - permission: - columns: - - bpjson - - general_info - - owner - - system - filter: {} -- table: - schema: public - name: producers_list - select_permissions: - - role: anonymous - permission: - columns: - - owner - - bpjson - - system - - candidate_name - - total_votes - - average - - transparency - - infrastructure - - trustiness - - community - - development - - ratings_cntr - - general_info - filter: {} -- table: - schema: public - name: proxies - select_permissions: - - role: anonymous - permission: - columns: - - owner - - name - - website - - slogan - - philosophy - - background - - logo_256 - - telegram - - steemit - - twitter - - wechat - - voter_info - filter: {} -- table: - schema: public - name: ratings_stats - select_permissions: - - role: anonymous - permission: - columns: - - bp - - ratings_cntr - - average - - transparency - - infrastructure - - trustiness - - community - - development - - created_at - - updated_at - filter: {} -- table: - schema: public - name: user_ratings - select_permissions: - - role: anonymous - permission: - columns: - - ratings - - tx_data - - bp - - uniq_rating - - user - filter: {} - delete_permissions: - - role: anonymous - permission: - filter: {} + - table: + schema: public + name: producers + select_permissions: + - role: anonymous + permission: + columns: + - bpjson + - general_info + - owner + - system + filter: {} + - table: + schema: public + name: producers_list + select_permissions: + - role: anonymous + permission: + columns: + - owner + - bpjson + - system + - candidate_name + - total_votes + - average + - transparency + - infrastructure + - trustiness + - community + - development + - ratings_cntr + - general_info + filter: {} + - table: + schema: public + name: proxies + select_permissions: + - role: anonymous + permission: + columns: + - owner + - name + - website + - slogan + - philosophy + - background + - logo_256 + - telegram + - steemit + - twitter + - wechat + - voter_info + filter: {} + - table: + schema: public + name: ratings_stats + select_permissions: + - role: anonymous + permission: + columns: + - bp + - ratings_cntr + - average + - transparency + - infrastructure + - trustiness + - community + - development + - created_at + - updated_at + filter: {} + - table: + schema: public + name: user_ratings + select_permissions: + - role: anonymous + permission: + columns: + - ratings + - tx_data + - bp + - uniq_rating + - user + filter: {} + delete_permissions: + - role: anonymous + permission: + filter: {} actions: -- name: rateProducer - definition: - handler: http://hapi:3005/ratebp - output_type: RatingOutput - arguments: - - name: ratingInput - type: RatingInput! - type: mutation - kind: synchronous - permissions: - - role: anonymous + - name: rateProducer + definition: + handler: "{{HASURA_GRAPHQL_ACTION_BASE_URL}}/ratebp" + output_type: RatingOutput + arguments: + - name: ratingInput + type: RatingInput! + type: mutation + kind: synchronous + permissions: + - role: anonymous custom_types: input_objects: - - name: RatingInput - fields: - - name: user - type: String! - - name: producer - type: String! + - name: RatingInput + fields: + - name: user + type: String! + - name: producer + type: String! objects: - - name: RatingOutput - fields: - - name: message - type: String! - - name: uniq_rating - type: String - - name: user - type: String - - name: bp - type: String - - name: ratings - type: jsonb - - name: deleteUserRateOutput - fields: - - name: message - type: String! + - name: RatingOutput + fields: + - name: message + type: String! + - name: uniq_rating + type: String + - name: user + type: String + - name: bp + type: String + - name: ratings + type: jsonb + - name: deleteUserRateOutput + fields: + - name: message + type: String!