# Building an image via Github-Actions with flow provided by projects

**URL:** <https://discourse.nodered.org/t/building-an-image-via-github-actions-with-flow-provided-by-projects/79577>\
**Category:** General\
**Tags:** docker\
**Created:** [4 July 2023 12:21 UTC](https://discourse.nodered.org/t/building-an-image-via-github-actions-with-flow-provided-by-projects/79577 "2023-07-04T12:21:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![lizzardguki](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/lizzardguki/32/103637_2.png) [@lizzardguki](https://discourse.nodered.org/u/lizzardguki)\
**Post date:** [4 July 2023 12:21 UTC](https://discourse.nodered.org/t/building-an-image-via-github-actions-with-flow-provided-by-projects/79577/1 "2023-07-04T12:21:59Z")

</div>

So right now our organization is using portainer to get the last container from DOCR repository, edit it and push it back.  
The thing is when we need to edit something quickly, we would just edit it on the deployed instance, meaning if the node-red crashes all of the changes are gone.

So i looked in to projects, and how we can utilize one node-red instance (running projects) to be able to edit all of the deployed instances. And figured out i can use the Gh Actions to compile our flows & other stuff to a docker image and send it off to DOCR.

This is the deploy.yaml file i came up with:

```auto
name: Deploy Node-RED

on:
  push:
    branches:
      - main

env:
  DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
  DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}

jobs:
  deploy:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout code
        uses: actions/checkout@v2

      - name: Login to Docker registry
        run: echo $DOCKER_PASSWORD | docker login registry.digitalocean.com -u $DOCKER_USERNAME --password-stdin

      - name: Get Docker image
        run: |
          docker pull nodered/node-red:latest

      - name: Build and push Docker image
        run: |
          # Extract the base image into a container
          
          docker run -d --name temp-container nodered/node-red:latest
          docker cp package.json temp-container:/data/package.json 
          docker cp flows.json temp-container:/data/flows.json
          docker cp flows_cred.json temp-container:/data/flows_cred.json
          docker cp settings.js temp-container:/data/settings.js
          

          
          # Build the new image using the modified Node-RED data directory
          docker commit temp-container registry.digitalocean.com/lsolutions/node-red-ec-scraping:latest
          docker images -a 
          # Push the image to the registry
          
          docker push registry.digitalocean.com/lsolutions/node-red-ec-scraping:latest

          # Clean up the temporary directory
          docker stop temp-container
          rm -rf temp

```

Is this a good way of doing this? Just finished the file and didn't had time to test it out using any community nodes?  
Wanted to use Github packages registry, but i can't use any other registries in Digital ocean ,except theirs and DockerHub's.  
Also please suggest a new name for this topic so anyone who needs this can find it easily. Thank you!

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [5 July 2023 06:20 UTC](https://discourse.nodered.org/t/building-an-image-via-github-actions-with-flow-provided-by-projects/79577/2 "2023-07-05T06:20:12Z")

</div>

I am uncertain of your goal but it reads like you want to run node-red, containerised with persistent flows? In digital ocean? And you are trying to achieve this by dynamically recreating the image ?

I can't help you with that but I can offer a ready made solution. FlowForge was built for this kinda thing & you can run the open source version on digital ocean (or locally, or in docker, or k8s): [Docker on Digital Ocean • FlowForge Docs](https://flowforge.com/docs/install/docker/digital-ocean/#1-click-digital-ocean-droplet-install)

Of course, you could also simply take advantage of one of the cloud providers and it is all done for you/hassle free. [FlowForge](https://flowforge.com/) offers that too. _(Disclaimer: I work for FlowForge - but it is open source so you can do this for free if you wish)_

---

<div class="post-metadata">

**Author:** ![lizzardguki](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/lizzardguki/32/103637_2.png) [@lizzardguki](https://discourse.nodered.org/u/lizzardguki)\
**Post date:** [5 July 2023 12:15 UTC](https://discourse.nodered.org/t/building-an-image-via-github-actions-with-flow-provided-by-projects/79577/3 "2023-07-05T12:15:36Z")

</div>

Thanks, had a look @ Flow Forge previous month, and it is too expensive for our usage.

The idea was:  
To have one node-red instance to edit flows, and push changes to Github

From github we are packaging it and sending it off to DOCR where it gets auto deployed.  
All of our 'projects' have their own settings.js which prohibits users to change flows from deployed instances

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [3 September 2023 12:16 UTC](https://discourse.nodered.org/t/building-an-image-via-github-actions-with-flow-provided-by-projects/79577/4 "2023-09-03T12:16:09Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
