# One github repository for docker-compose application consisting of a node-red application

**URL:** <https://discourse.nodered.org/t/one-github-repository-for-docker-compose-application-consisting-of-a-node-red-application/44523>\
**Category:** General\
**Created:** [22 April 2021 07:29 UTC](https://discourse.nodered.org/t/one-github-repository-for-docker-compose-application-consisting-of-a-node-red-application/44523 "2021-04-22T07:29:55Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![janvda](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/janvda/32/234_2.png) [@janvda](https://discourse.nodered.org/u/janvda)\
**Post date:** [22 April 2021 07:29 UTC](https://discourse.nodered.org/t/one-github-repository-for-docker-compose-application-consisting-of-a-node-red-application/44523/1 "2021-04-22T07:29:55Z")

</div>

**The context:**

I am developing a docker compose application consisting of multiple services  
of which one (or more) service is a node-red application with its specific node-red flows.

For development I am using 2 machines:

1. laptop (macbook) where I am creating/editing all the files of my docker compose application _excluding the specific files of my node-red application._
2. docker environment (intel nuc) where my docker compose application is running and where I am editing the node-red flows of my node-red application using the node-red editor in a browser.

Currently I am creating the following 2 github repositories for this:

1. docker-compose application (without the node-red flows)
2. node-red application flows

When deploying my docker-compose application to a new docker environment I must also open the node-red editor and clone the appropriate node-red application flows repository using the node-red project feature.

**The goal**

1. Have one single github repository containing the complete docker compose application _ **including the node-red flows.** _
2. Using the node-red editor it should also be possible to update the node-red flows and push those changes to this github repository.

---

<div class="post-metadata">

**Author:** ![nlecaude](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nlecaude/32/25_2.png) [@nlecaude](https://discourse.nodered.org/u/nlecaude)\
**Post date:** [22 April 2021 19:58 UTC](https://discourse.nodered.org/t/one-github-repository-for-docker-compose-application-consisting-of-a-node-red-application/44523/2 "2021-04-22T19:58:33Z")

</div>

I've tried doing something similar and failed so far...  
I currently do you approach: separate repositories for each node-red project and a deploy repository containing the compose files.  
Let me know if you find something out...

---

<div class="post-metadata">

**Author:** ![janvda](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/janvda/32/234_2.png) [@janvda](https://discourse.nodered.org/u/janvda)\
**Post date:** [24 April 2021 12:25 UTC](https://discourse.nodered.org/t/one-github-repository-for-docker-compose-application-consisting-of-a-node-red-application/44523/3 "2021-04-24T12:25:59Z")

</div>

If I find some time, I will give it a shot.

I see that the location of the `flows.json` file and `package.json` can be edited via project settings.  
So maybe this can be changed to a specific relative subfolder.  
It is not clear to me where these project settings are stored and if they can be configured (e.g. via the node-red settings.js file) without using the node-red editor. So that is the first thing I need to figure out.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/d/ddfcd9fd135ec167806cbd6070ed41d1511d3fb8.png)

---

<div class="post-metadata">

**Author:** ![janvda](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/janvda/32/234_2.png) [@janvda](https://discourse.nodered.org/u/janvda)\
**Post date:** [25 April 2021 11:42 UTC](https://discourse.nodered.org/t/one-github-repository-for-docker-compose-application-consisting-of-a-node-red-application/44523/4 "2021-04-25T11:42:43Z")

</div>

I did some further testing (see [janvda/docker-compose-with-node-red-flows](https://github.com/janvda/docker-compose-with-node-red-flows)) and selecting the right `package.json` (located in a subfolder) seem to be working for a very simple flow.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/9/698ae4631f25bc463314061b67b09a742ba3062a.png)

Instead of manually specifying the location of the package json file using above Project settings tab is it also possible to configure this ? The idea is that when cloning this github project that it automatically will look for the package.json file in the correct subfolder ( = `./node-red-service1/`) @knolleary

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [26 April 2021 07:03 UTC](https://discourse.nodered.org/t/one-github-repository-for-docker-compose-application-consisting-of-a-node-red-application/44523/5 "2021-04-26T07:03:39Z")

</div>

Hi @janvda

> [@janvda](#):
>
> Instead of manually specifying the location of the package json file using above Project settings tab is it also possible to configure this

Each project's configuration is stored in `~/.node-red/.config.projects.json` - this includes the `credentialSecret` used to decrypt the credentials file and `rootPath` used to specify where in the repo the Node-RED project is (if it isn't at the root of the repo).

Depending on what workflow you want to achieve, you could pre-create that file somehow with the right contents.

---

<div class="post-metadata">

**Author:** ![janvda](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/janvda/32/234_2.png) [@janvda](https://discourse.nodered.org/u/janvda)\
**Post date:** [26 April 2021 08:28 UTC](https://discourse.nodered.org/t/one-github-repository-for-docker-compose-application-consisting-of-a-node-red-application/44523/6 "2021-04-26T08:28:33Z")

</div>

> [@knolleary](#):
>
> and `rootPath` used to specify where in the repo the Node-RED project is (if it isn't at the root of the repo)

Thanks, it is indeed the `rootPath` parameter that needs to be set properly.

I can create a `.config.projects.json` with the proper contents but when cloning the repository using the node-red editor it is overwriting these project settings.  
I can consider also doing the git clone in the dockerfile but that it is going a bit too far.

... actually I think I can live with the fact that I need to select the `package.json` from the right folder after cloning the repository using the node-red editor 🙂

---

<div class="post-metadata">

**Author:** ![janvda](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/janvda/32/234_2.png) [@janvda](https://discourse.nodered.org/u/janvda)\
**Post date:** [26 April 2021 15:45 UTC](https://discourse.nodered.org/t/one-github-repository-for-docker-compose-application-consisting-of-a-node-red-application/44523/7 "2021-04-26T15:45:17Z")

</div>

> [@nlecaude](#):
>
> Let me know if you find something out...

I found something :

So if you want to maintain in a **"single"** github repository:

1. a docker-compose application having a node-red application `X` as one of its services AND
2. the node-red flows and flow credentials of the node-red application `X`

then I would suggest to have a look at:

- [janvda/docker-compose-with-node-red-flows](https://github.com/janvda/docker-compose-with-node-red-flows)

I performed some testing and it is working.

More details can be found in the [readme](https://github.com/janvda/docker-compose-with-node-red-flows#readme).

Any feedback, comments or [github issues](https://github.com/janvda/docker-compose-with-node-red-flows/issues) are welcome.  
Jan

---

<div class="post-metadata">

**Author:** ![nlecaude](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nlecaude/32/25_2.png) [@nlecaude](https://discourse.nodered.org/u/nlecaude)\
**Post date:** [26 April 2021 19:13 UTC](https://discourse.nodered.org/t/one-github-repository-for-docker-compose-application-consisting-of-a-node-red-application/44523/8 "2021-04-26T19:13:29Z")

</div>

So in that case on the target machine there are still 2 cloned repositories ? The first clone that clones your compose file and then the manual clone that will clone the project in the projects folder.

---

<div class="post-metadata">

**Author:** ![janvda](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/janvda/32/234_2.png) [@janvda](https://discourse.nodered.org/u/janvda)\
**Post date:** [27 April 2021 12:46 UTC](https://discourse.nodered.org/t/one-github-repository-for-docker-compose-application-consisting-of-a-node-red-application/44523/9 "2021-04-27T12:46:54Z")

</div>

There are indeed 2 cloned repositories but in my case not on the same machine.

1. The first clone (used to edit my compose file and everything else not related to the node-red flows) is made on my laptop (= my build machine)
2. I deploy my docker compose application to my target machine (`nuc-xxx.local`) by
  1. setting the [DOCKER\_HOST](https://docs.docker.com/compose/reference/envvars/#docker_host) environment variable ( `export DOCKER_HOST=ssh://root@nuc-xxx.local`) on my laptop
  2. followed by command : `docker-compose up --build -d`

3. If I want to edit my flows then I open the node-red editor on my target machine and first clone the repository as outlined in the [readme](https://github.com/janvda/docker-compose-with-node-red-flows#how-to-update-the-node-red-flows-).

`DOCKER_HOST` is really an interesting feature. It allows you to make any changes on one machine (build machine) and deploy them to another machine (target machine). Your build machine doesn't need to be online all the time. It must only be online when you want to deploy your application changes.

I think it is also possible to do everything from one machine with a single clone.  
For that you must make the clone under folder `...XXX/projects/` and in folder `...XXX/` your docker compose application must create a file `.config.projects.json` with the proper contents.  
... of course there are several other things you must figure out to get this bootstrapping working. I admit it is a bit like pulling yourself up on your shoelace.

---

<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:** [26 June 2021 12:47 UTC](https://discourse.nodered.org/t/one-github-repository-for-docker-compose-application-consisting-of-a-node-red-application/44523/10 "2021-06-26T12:47:55Z")

</div>

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