Skip to content

Build docker #78

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 77 additions & 0 deletions .github/workflows/build-indy-node-monitor.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
3 changes: 2 additions & 1 deletion fetch-validator-status/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion fetch-validator-status/networks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]))
Expand Down
14 changes: 11 additions & 3 deletions fetch-validator-status/rest_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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
return result