Skip to content
Richard edited this page Aug 11, 2025 · 9 revisions

Welcome to Continuous Deployment (CD) Wiki for Peer Network

This page serves as the single orientation/explainer point for DevOps and Administrators for Peer.


πŸš€ What is Peer Network?

Peer Network is a blockchain-integrated social network where users post content, earn tokens, Chat, and importantly (Monetize Participation).


🧱 Architecture Overview

The system is made up of multiple coordinated repositories:

Component Description
peer_backend Main GraphQL API: users, content, chat, wallet, moderation
peer_backend_CI/CD Main DevOps repository
peer_cd This repo

Each client connects to the backend via GraphQL, and the backend handles blockchain interaction and rewards.

Peer CD

This repo is to facilitate automatic updates to the other back-end servers from DevOps. This allows DevOps to push to this repo and have those changes apply to the testing environment of Peer. There is a webhook monitoring this repo for any pushs to dev branch. The main branch pushes to production (when verified).

The setup of the repo is part of how the webhook work and the placement of the scrips from DevOps.

Each directory has a point where the code is copied (rsync) remotely or locally.

Format of Peer CD

Each directory contains a project. The project needs to have all of the files: data, config, scripts, environment, and other. One can have sub-directories in there as well (examples above). If you have files that should not be versioned (.env or secrets), then document them in the wiki or have a text explaining what files do what. Please be clear in what you want so we can help make your project work.

As of 04.08.2025 The directory structure is:

β”œβ”€β”€ mintbot
β”‚Β Β  β”œβ”€β”€ scripts
β”‚Β Β  └── secrets
β”œβ”€β”€ monitoring-stack
β”‚Β Β  β”œβ”€β”€ postman_collection
β”‚Β Β  └── scripts
β”œβ”€β”€ peer_cd_test_deploy
β”œβ”€β”€ php-webhook
└── Python3_webhooK

Here is an example of tracked directories. For mintbot there is a large set of logs that are not versioned, but need to be known. Logs is a important part of the project and needs to be noted.

β”œβ”€β”€ mintbot
β”‚Β Β  β”œβ”€β”€ logs
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ mint_20250728094801
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ mint_20250728111201
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ mint_20250728111501
...
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ mint_20250809100001
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ mint_20250810100001
β”‚Β Β  β”‚Β Β  └── mint_20250811100001
β”‚Β Β  β”œβ”€β”€ scripts
β”‚Β Β  └── secrets

The current main projects are

Project Description
- mintbot Mining token system check runs once a day at 10:00 CET
- monitor-stack Postman check for the backend updates
- php_webhook PHP Datebase monitor
- Python3_webhook & peer_cd_test_deploy This is the deployment code for Peer CD

Python3_webhook & peer_cd_test_deploy

These directories contain the webhook for this repo. The webhook listens for a "push" to Github. Then the script sorts the target directory and then calls the peer test and deploy script to perforem unit tests (Linting for now) and rsync to the remote servers. The (local server is beta_testing jumphost) is is where a local copy of of this repo and active scripts resides.

For DevOps

How to create a new project for Peer CD

  1. Contact the Administrator of the repo.
  2. Explain what is needed with the new project.
  • Limitation: The source code needs to be in a single parent directory, other child directories can be used.
  • The target location will be needed.
  • Logs placement need to be defined (var/log/...) or in the project directory.
  1. Create new directory in the repo.
  2. Add code
  3. Create wiki page detailed the functions of the project, any extra dependencies needed, and extra useful information.
  4. Push to dev
  5. Deploy and test.

To have pushes to this repo to be be 'pushed' to the repected servers. This CD will be split between

  • Main
    • This brach will push changes for monitoring Prod systems
  • Dev
    • This brach will push to the testing envirnment

DevOps then can push to Dev easily and can test there changes. When all parties are happy then a merge to Main and push to effect Prod.

The /opt/application/ directory

.
β”œβ”€β”€ LICENSE
β”œβ”€β”€ Python3_webhooK           (main webhook for the infrasctuture)
β”‚Β Β  β”œβ”€β”€ Beta_test_Py3_webhook.py
β”‚Β Β  └── Beta_test_Py3_webhook2.py  (current)
β”œβ”€β”€ README.md
β”œβ”€β”€ monitoring-stack    (DevOps monitoring)
β”‚Β Β  β”œβ”€β”€ postman_collection
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ postman_collections.json
β”‚Β Β  β”‚Β Β  └── postman_environment.json
β”‚Β Β  └── scripts
β”‚Β Β      β”œβ”€β”€ monitor_api.sh
β”‚Β Β      └── monitor_api_py.ph
β”œβ”€β”€ payload.json              (test .json)
β”œβ”€β”€ peer_cd_test_deploy       (Where the test and deploy scripts are located)
β”‚Β Β  β”œβ”€β”€ Beta_test_deploy.py   (Called from Python3_webhook2.py)
β”‚Β Β  β”œβ”€β”€ test_bash.sh
β”‚Β Β  β”œβ”€β”€ test_php.sh
β”‚Β Β  └── test_python.sh
β”œβ”€β”€ php-webhook               (update the backend)
β”‚Β Β  β”œβ”€β”€ deploy-backend.sh
β”‚Β Β  └── peer-deploy-hook.php
β”œβ”€β”€ restart-php.sh
└── update-database.sh

There is are ssh-keys to allow the transfer to the update to the remote servers. rsync-key
This key will only push github changes to the needed places.

Json file for the Data.

Please edit this file to add and or change target servers and endpoints. There are 2 sections for this test and deploy:

First, the target directory locations and the remote servers.

Target Project Entry example values
Key Value
'source_dir' 'Python3_webhook'
'target_server' 'local' or hostname 'monitor'
'target_path' '~/myenv/peer_cd/Python3_webhook'
'user' 'ubuntu'
'ip' None, or IP of the target server
'description' 'Python webhook to local server'
'excludes' [] or [ '.env','secrets/','logs/', or other ]

Second, the test scripts and what is being linted.

Test settings Notes
Key Value
'enabled' 'True' or 'False'
'extension' what file type to test
'test command file to run (a bash script that runs python to test syntax)
'timeout' number of seconds to wait
{ 
    "DEPLOYMENT_MAPPINGS": {
        "Python3_webhook": {
            "source_dir": "Python3_webhook",
            "target_server": "local",
            "target_path": "~/myenv/peer_cd/Python3_webhook",
            "user": "ubuntu",
            "ip": null,  
            "_note": "** For local deployment **",
            "description": "Python webhook to local server",
            "excludes": []
        },
        "peer_cd_test_deploy": {
            "source_dir": "peer_cd_test_deploy",
            "target_server": "local",
            "target_path": "/opt/application/peer_cd_test_deploy",
            "user": "ubuntu",
            "ip": null,
            "_note": "** For local deployment **",
            "description": "Test deployment files to local server",
            "excludes": []
        },
        "monitoring-stack": {
            "source_dir": "monitoring-stack",
            "target_server": "monitor",
            "target_path": "/home/ubuntu/peer_cd/monitoring-stack",
            "user": "ubuntu",
            "ip": "172.16.0.20",
            "_note": "For Test Monitor",
            "description": "Monitoring stack to monitor server",
            "excludes": []
        },
        "mintbot": {
            "source_dir": "mintbot",
            "target_server": "monitor",
            "target_path": "/home/ubuntu/peer_cd/mintbot",
            "user": "ubuntu",
            "ip": "172.16.0.20",
            "_note": "For Test Monitor",
            "description": "Monitoring for gem token queries",
            "excludes": [
                ".env",
                "secrets/*",
                "logs/*"
            ]
        },
        "php-webhook": {
            "source_dir": "php-webhook",
            "target_server": "deploy-server",
            "target_path": "/home/ubuntu/deploy-scripts",
            "user": "ubuntu",
            "ip": "172.16.10.194",
            "_note": "For Test Backend",
            "description": "PHP webhook to deploy server",
            "excludes": []
        }
    },
    "TEST_CONFIGS": {
        "python": {
            "enabled": true,
            "extension": ".py",
            "command": ["bash", "test_python.sh"],
            "timeout": 60
        },
        "php": {
            "enabled": true,
            "extension": ".php",
            "command": ["bash", "test_php.sh"],
            "timeout": 60
        },
        "bash": {
            "enabled": true,
            "extension": ".sh",
            "command": ["bash", "test_bash.sh"],
            "timeout": 60
        }
    }
}