openkfw / TruBudget

A blockchain-based workflow tool for efficient and transparent project management
https://openkfw.github.io/trubudget-website/
GNU General Public License v3.0
83 stars 40 forks source link

"Update" button for simpler upgrades of TruBudget versions #1863

Open jzakotnik opened 3 weeks ago

jzakotnik commented 3 weeks ago

Discussed in https://github.com/openkfw/TruBudget/discussions/1754

Originally posted by **jzakotnik** March 27, 2024 One pain point from the pilots is that the upgrading is a somewhat complex process and no "update" Button exists in TruBudget. What would be the options and architecture how this could be done?
galethil commented 3 weeks ago

Hi @jzakotnik I believe that in order to accomplish this we will need to introduce new piece of infrastructure on the level of server where docker is running.

Here's a high-level description of the solution:

High-Level Steps to Enable an "Upgrade" Button for Docker Infrastructure

  1. Host-Level Script:

    • Create a shell script (upgrade.sh) on the host machine that:
      • Updates the environment variable with the new Docker image tag.
      • Pulls the new Docker images.
      • Restarts the services using Docker Compose.
  2. Host-Level API Service:

    • Set up a lightweight API server on the host machine using Node.js and Express.
    • This server will expose an endpoint to trigger the upgrade.sh script.
  3. Backend Service:

    • Modify your backend service (running in a container) to send HTTP requests to the host-level API.
    • This backend service will handle requests from the frontend to initiate the upgrade process.
  4. Frontend Integration:

    • Add an "Upgrade" button to your frontend.
    • This button will send a request to the backend service with the desired new version tag.
  5. Secure Communication:

    • Ensure secure communication between the backend service and the host-level API to prevent unauthorized access.

Workflow

  1. User Interaction:

    • A user clicks the "Upgrade" button on the frontend and enters the desired version tag.
  2. Frontend Request:

    • The frontend sends the version tag to the backend service.
  3. Backend Processing:

    • The backend service forwards the version tag to the host-level API.
  4. Host-Level Execution:

    • The host-level API triggers the upgrade.sh script to update the environment variables, pull the new images, and restart the services using Docker Compose.

By following these high-level steps, you can set up your infrastructure to support an "Upgrade" button on the frontend, allowing seamless upgrades of your Docker-based application.

graph TD;
    A[Frontend] -->|1. Click 'Upgrade' Button| B[Backend Service];
    B -->|2. Send Version Tag| C[Host-Level API];
    C -->|3. Trigger upgrade.sh| D[upgrade.sh Script];
    D -->|4. Update .env and Pull New Images| E[Docker Compose];
    E -->|5. Restart Services| F[Docker Services];

    style A fill:#f9f,stroke:#333,stroke-width:4px;
    style B fill:#bbf,stroke:#333,stroke-width:4px;
    style C fill:#f96,stroke:#333,stroke-width:4px;
    style D fill:#ff9,stroke:#333,stroke-width:4px;
    style E fill:#96f,stroke:#333,stroke-width:4px;
    style F fill:#6f9,stroke:#333,stroke-width:4px;