diff --git a/.github/workflows/build-indy-node-monitor.yaml b/.github/workflows/build-indy-node-monitor.yaml new file mode 100644 index 0000000..fbd9c43 --- /dev/null +++ b/.github/workflows/build-indy-node-monitor.yaml @@ -0,0 +1,77 @@ +name: Publish Docker image + +on: + push: + branches: + - main + paths: + - 'fetch-validator-status/**' # Build only if their are changes in this directory + + workflow_dispatch: + inputs: + ref: + required: false + type: string + description: "This is the tag version, don't include the v like this 2.4.6, if you dont provide a version we will get the latest tag" + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository main + uses: actions/checkout@v4 + with: + fetch-depth: 0 # Required due to the way Git works, without it this action won't be able to find any or the correct tags + + - name: Extract latest version from Git tag, excludind the v. + run: | + LATEST_TAG=$(git describe --tags `git rev-list --tags --max-count=1` | cut -c2-) + echo "LATEST_TAG=$LATEST_TAG" >> $GITHUB_ENV + echo "LATEST_TAG=$LATEST_TAG" + + - name: Checkout repository specific tag + uses: actions/checkout@v4 + with: + ref: v${{ inputs.ref || env.LATEST_TAG }} + + - name: Log in to the GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Set lowercase username + run: echo "USERNAME=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV + - name: Checkout repository main + uses: actions/checkout@v4 + with: + fetch-depth: 0 # Required due to the way Git works, without it this action won't be able to find any or the correct tags + + - name: Extract latest version from Git tag, excludind the v. + run: | + LATEST_TAG=$(git describe --tags `git rev-list --tags --max-count=1` | cut -c2-) + echo "LATEST_TAG=$LATEST_TAG" >> $GITHUB_ENV + echo "LATEST_TAG=$LATEST_TAG" + + - name: Checkout repository specific tag + uses: actions/checkout@v4 + with: + ref: v${{ inputs.ref || env.LATEST_TAG }} + + - name: Log in to the GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Set lowercase username + run: echo "USERNAME=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV + + - name: Build the Docker image + run: docker build -t ghcr.io/${{ env.USERNAME }}/${{ github.event.repository.name }}/indy-node-monitor:${{ inputs.ref || env.LATEST_TAG }} ./fetch-validator-status/ + + - name: Push the Docker image + run: docker push ghcr.io/${{ env.USERNAME }}/${{ github.event.repository.name }}/indy-node-monitor:${{ inputs.ref || env.LATEST_TAG }} diff --git a/fetch-validator-status/Dockerfile b/fetch-validator-status/Dockerfile index adcb60e..764770b 100644 --- a/fetch-validator-status/Dockerfile +++ b/fetch-validator-status/Dockerfile @@ -45,12 +45,13 @@ RUN usermod -a -G root $user # Note: PIP_NO_CACHE_DIR environment variable should be cleared to allow caching RUN mkdir -p \ $HOME/log \ + $HOME/cache \ $(python -m site --user-site) # The root group needs access the directories under $HOME for the container to function in OpenShift. # Also ensure the permissions on the python 'site-packages' folder are set correctly. RUN chown -R $user:root $HOME && \ - chmod -R ug+rw $HOME $HOME/log && \ + chmod -R ug+rw $HOME $HOME/log $HOME/cache && \ chmod +rx $(python -m site --user-site) USER $user diff --git a/fetch-validator-status/networks.py b/fetch-validator-status/networks.py index d079d74..2916ef7 100644 --- a/fetch-validator-status/networks.py +++ b/fetch-validator-status/networks.py @@ -59,7 +59,7 @@ def get_NetworkEnum() -> NetworkEnum: def resolve(self, network_id: str = None, genesis_url: str = None, genesis_path: str = None): network_name = None - genesis_path_base = f"{self.__get_script_dir()}/" + genesis_path_base = f"{self.__get_script_dir()}/cache/" if network_id and network_id in self.ids: log("Connecting to '{0}' ...".format(self.networks[network_id]["name"])) diff --git a/fetch-validator-status/rest_api.py b/fetch-validator-status/rest_api.py index ea98cc2..7e63995 100644 --- a/fetch-validator-status/rest_api.py +++ b/fetch-validator-status/rest_api.py @@ -78,7 +78,7 @@ async def networks(): @app.get("/networks/{network}") async def network(network: Network = Path(path=example_network_enum, example=example_network_name, description="The network code."), - status: bool = Query(False, description="Filter results to status only."), + status: bool = Query(False, description="Filter results to status only."), alerts: bool = Query(False, description="Filter results to alerts only."), seed: Optional[str] = Header(None, description="Your network monitor seed.")): monitor_plugins = set_plugin_parameters(status, alerts) @@ -93,10 +93,18 @@ async def network(network: Network = Path(path=example_network_enum, example=exa result = await pool.get_transactions() return result +@app.get("/networks/{network}/pool/verifiers") +async def network(network: Network = Path(path=example_network_enum, example=example_network_name, description="The network code.")): + set_plugin_parameters() + pool, _ = await pool_collection.get_pool(network.value) + await pool.refresh() + result = await pool.get_verifiers() + return result + @app.get("/networks/{network}/{node}") async def node(network: Network = Path(path=example_network_enum, example=example_network_name, description="The network code."), node: str = Path(..., example="FoundationBuilder", description="The node name."), - status: bool = Query(False, description="Filter results to status only."), + status: bool = Query(False, description="Filter results to status only."), alerts: bool = Query(False, description="Filter results to alerts only."), seed: Optional[str] = Header(None, description="Your network monitor seed.")): monitor_plugins = set_plugin_parameters(status, alerts) @@ -107,4 +115,4 @@ async def node(network: Network = Path(path=example_network_enum, example=exampl print(error) raise HTTPException(status_code=400, detail=str(error)) - return result \ No newline at end of file + return result