From 96d3a1cd4d73f44dbc45b45bce3075643ee05933 Mon Sep 17 00:00:00 2001 From: Rebegea Dragos-Alexandru <42241923+dragos-rebegea@users.noreply.github.com> Date: Tue, 29 Oct 2024 10:20:22 +0200 Subject: [PATCH 1/2] added dockerfile, workflow and entrypoint (#1364) * added dockerfile, workflow and entrypoint * add entrypoint --------- Co-authored-by: liviuancas-elrond Co-authored-by: cfaur09 --- .github/workflows/build-docker-image.yaml | 45 ++++++++++++++++++++++ Dockerfile | 17 +++++++++ entrypoint.sh | 46 +++++++++++++++++++++++ 3 files changed, 108 insertions(+) create mode 100644 .github/workflows/build-docker-image.yaml create mode 100644 Dockerfile create mode 100644 entrypoint.sh diff --git a/.github/workflows/build-docker-image.yaml b/.github/workflows/build-docker-image.yaml new file mode 100644 index 000000000..4d0eff40d --- /dev/null +++ b/.github/workflows/build-docker-image.yaml @@ -0,0 +1,45 @@ +name: Publish Docker image + +on: + release: + types: [published] + workflow_dispatch: + +jobs: + push_to_registry: + name: Push Docker image to Docker Hub + runs-on: ubuntu-latest + permissions: + packages: write + contents: read + attestations: write + steps: + - name: Check out the repo + uses: actions/checkout@v4 + + - name: Set up Node.js + uses: actions/setup-node@v2 + with: + node-version: '18' # Specify your Node.js version + + - name: Log in to Docker Hub + uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 + with: + images: multiversx/mx-api-service + + - name: Build and push Docker image + id: push + uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671 + with: + context: . + file: ./Dockerfile + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..72127a190 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,17 @@ +FROM node:18.19-alpine + +WORKDIR /app +RUN chown -R node:node /app + +USER node +RUN mkdir -p /app/dist/src +COPY --chown=node . /app + +RUN npm install +RUN npm run init +RUN npm run build + +EXPOSE 3001 +RUN chmod +x entrypoint.sh + +CMD ["./entrypoint.sh"] diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 000000000..4d199798f --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,46 @@ +#!/bin/sh +# ENV VARIABLES + # MVX_ENV - defines what config to copy (default devnet) + # ELASTICSEARCH_URL - defines custom elasticsearch url - eg https://devnet-index.multiversx.com + # GATEWAY_URL - defines custom gateway url - eg https://devnet-gateway.multiversx.com + # REDIS_IP - defines redis ip - default 127.0.0.1 + +# CHECK IF ENV IS DEFINED +if [ -n "$MVX_ENV" ] && [ "$MVX_ENV" = "devnet" ]; then + # Copy config file + cp ./config/config.${MVX_ENV}.yaml /app/dist/config/config.yaml + + if [ $? -eq 0 ]; then + echo "Config file copied successfully from config/config.${MVX_ENV}.yaml /app/dist/config/config.yaml" + else + echo "Failed to copy the file." + fi + +else + cp ./config/config.devnet.yaml /app/dist/config/config.yaml + + if [ $? -eq 0 ]; then + echo "Default config file copied successfully from config/config.devnet.yaml /app/dist/config/config.yaml" + else + echo "Failed to copy the file." + fi +fi + +# Replaces urls if defined +if [ -n "$REDIS_IP" ]; then + echo "Redis IP defined: ${REDIS_IP}, replacing in config" + sed -i "s|redis: '127.0.0.1'|redis: '${REDIS_IP}'|g" /app/dist/config/config.yaml +fi + +if [ -n "$ELASTICSEARCH_URL" ]; then + echo "Elasticsearch url defined: ${ELASTICSEARCH_URL}, replacing in config" + sed -i "/^ elastic:/!b; n; s|.*| - '${ELASTICSEARCH_URL}'|" /app/dist/config/config.yaml +fi + +if [ -n "$GATEWAY_URL" ]; then + echo "Gateway url defined: ${GATEWAY_URL}, replacing in config" + sed -i "/^ gateway:/!b; n; s|.*| - '${GATEWAY_URL}'|" /app/dist/config/config.yaml +fi + + +exec /usr/local/bin/node dist/src/main.js From a815b286f29f706784e093ac9cb0a229b20d56bf Mon Sep 17 00:00:00 2001 From: Catalin Faur <52102171+cfaur09@users.noreply.github.com> Date: Tue, 12 Nov 2024 14:33:01 +0200 Subject: [PATCH 2/2] Add guardianData to GatewayComponentRequest in GatewayService (#1377) --- src/common/gateway/gateway.service.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/common/gateway/gateway.service.ts b/src/common/gateway/gateway.service.ts index e0bbb8cc3..e2c0ac7a2 100644 --- a/src/common/gateway/gateway.service.ts +++ b/src/common/gateway/gateway.service.ts @@ -30,6 +30,7 @@ export class GatewayService { GatewayComponentRequest.addressNftByNonce, GatewayComponentRequest.vmQuery, GatewayComponentRequest.transactionPool, + GatewayComponentRequest.guardianData, ]); private readonly deepHistoryRequestsSet: Set = new Set([