-
Notifications
You must be signed in to change notification settings - Fork 143
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
Add ability to select a docker-compose file #1142
Comments
+1 on this feature |
[pdcastro] This issue has attached support thread https://jel.ly.fish/#/support-thread~4115ae1d-c2da-41c6-bbe4-667e366c314f |
+1 on this feature What are the chances of someone starting to work on this? there is already a flag: |
+1000 to this feature, I'm currently using bash script on my deploys just because of it. |
@krasi-georgiev and others -- thanks for the feedback and upvoting. 👍 |
[camerondiver] This issue has attached support thread https://jel.ly.fish/#/b957d2b3-67b8-4b63-987a-2744af73a940 |
+1. We use different compose files to specify different environments, and having to use scripts is (1) a headache to develop, maintain, document (2) just lost me a bunch of time to even figure out. |
Implementation note: Docker's documentation for the docker-compose.yml CONTEXT instruction states that the context path is "interpreted as relative to the location of the Compose file" (https://docs.docker.com/compose/compose-file/compose-file-v2/#context). Therefore, allowing the specification of an alternative |
As an addition to this, as I can't see anywhere it's been made clear, the CLI should allow multiple |
Update: I believe the main reasons why this issue hasn't been implemented yet are the complications and implications of the alternative docker-compose file being outside the "project root folder" - given that Docker's spec / docs state that the build context should be relative to the location of the docker-compose file. |
That would be a welcome feature, as it would suffice to solve our issues. |
[pdcastro] This issue has attached support thread https://jel.ly.fish/e1e54d6c-cac2-4eb8-b4fb-e07783107fa7 |
+1 on this feature Really needed to avoid duplicate source code, or doing shell scripts that override docker-compose.yaml with the risk of this. |
Re-commenting here after discussion on #2177 that shallow merges Using
I think this would be a preferable merge method, for parity. This way you can have a minimal services:
app:
ports:
- "9229:9229" |
Sigh. I just came across this issue because I created two different docker-compose files, I don't think #2177 solves anything and, even worse it's implicit, unexpected behavior and nowhere documented. My development and production docker-compose files are completely different, so overriding stuff doesn't do the trick.
I don't really understand the issue. |
Are you saying that when you do docker-compose up it automatically merges the docker-compose.dev.yml files? Or only when you specify it with --f file1.yml --f docker-compose.dev.yml? |
On a somewhat more abstract level: @pdcastro Is there a (documented) way for me to talk to the balena supervisor on my local device directly? This is not the first issue I'm dealing with when it comes to Dockerfiles. Other issues I've encountered are:
All in all, these issues come down to the fact that we're forced to write entirely static Basically, what I have in mind is writing a build script in Python that assembles my Dockerfile dynamically and hands it over to the balena supervisor on my target device / the build server together with the proper build context. (If it were the Docker engine, not the balena supervisor, the latter part could be achieved through e.g. https://github.com/docker/docker-py ) Dynamically composing my Docker containers would then be a piece of cake as docker-compose is only a wrapper around the from this_package_doesnt_exist_yet import Dockerfile
d = Dockerfile()
d.FROM("balenalib/jetson-nano-ubuntu:bionic")
d.ENV(...)
d.RUN(...)
d.CMD(...)
if __name__ == "__main__":
from docker import APIClient
client = APIClient("my device IP")
# Compare https://docker-py.readthedocs.io/en/stable/api.html#module-docker.api.image
client.build(fileobj=d.as_fileobj(), custom_context=...) |
You probably meant to write $ ls -l | grep docker-compose
-rw------- 1 user user 284 Apr 1 18:10 docker-compose.dev.yml
-rw------- 1 user user 342 Apr 1 18:10 docker-compose.prod.yml
$ balena push balena.local
[Info] Starting build on device 192.168.2.134
[Info] Docker compose dev overlay detected (docker-compose.dev.yml) - merging. I suppose you get my confusion. :) |
I did mean push. Oh boy, yes, that's an issue for sure. Not only in it's step away from Docker etiquette - with Docker as our base documentation for understanding balena engine - but it is a breaking change for a bunch of repos when I next update as I have dev files named like that sitting alongside quite happily (until this). Eek.. I see the premise of what is trying to be achieved here, but would suggest reverting to Docker formats post-haste: https://docs.docker.com/compose/extends/#adding-and-overriding-configuration In short, it would mean automatically merging docker-compose.override.yml files, not docker-compose.dev.yml files. If someone wants to merge a dev file, they can simply name it docker-compose.override.yml. And we don't end up bricking everyone else. We can then apply our existing Docker understanding and docker docs to our use. Might just be the one liner here, based on the search of the pull request @pdcastro : balena-cli/lib/utils/compose_ts.ts Line 175 in f3d750a
|
Oh wow, you're right. This is even worse than I had thought.
I don't think a hard-coded, implicit file name is a good idea – it will only provide a solution in the simplest of use cases and even then it's not clear what it does if one doesn't read the Balena docs carefully. On top of that, it still deviates from |
An override by default file actually aligns with Docker practice, and is quite a handy feature. It's clear naming though prevents these issues happening accidentally: https://docs.docker.com/compose/extends/#understanding-multiple-compose-files The additional feature that is also based on Docker, is to specify files with -f file1 -f file2 and them then merge, which is also useful although not really in the critical category for a feature. But I think where this thread started, and would be most useful, is to just be able to specify the file you want to use '-f filename.yml' (after fixing the current merge issue). Also common Docker practice. Mostly because I can then have my development as docker-compose.yml and my production as docker-compose.prod.yml. I call my development .yml file far more than my prod, so people tend to have them this way around. I can then bring up whichever environment I need without having to rename files (which can lead to the issue of pushing those changes to my repo by mistake). |
@srlowe, @joshbwlng, FYI, see 7 comments above (1st April 2021) regarding |
Is there any update on this? It really is quite a significant issue, forcing non-standard naming conventions and bound to be tripping more people up down the line. How about changing docker-compose.dev.yml to docker-compose.overlay.yml until the larger refactor planned is complete? It seems to align with what it is the feature does, and doesn’t clash with docker naming conventions. |
I'm running into the separate docker-compose file problem too. The compose specification has a profile option which if a flag was added for push/deploy/build could maybe solve some of these headaches? |
Any update on this? Being able to select a docker compose file ( All the thumbs up and length of this thread seems to suggest there is demand for it. |
I am using an NX workspace mono-repo and having the ability to push a specific docker-compose would be great. Currently, I have multiple compose files "competing" in the root directory. |
[the-real-kenna] This issue has attached support thread https://jel.ly.fish/44dd2470-431d-4327-917b-51a7e22181ce |
In the meantime I had some success with a workaround:
Now when you call However, if you navigate to the This worked for me by starting with balena-nodejs-hello-world, moving
I was able to One gotcha was that I also had to duplicate the |
[hraftery] This has attached https://jel.ly.fish/469950c3-704b-4c50-8f2e-89db97b1f79f |
@hraftery, concerning this comment:
I was able to use symlinks between the project root and |
I (along with ChatGPT ;) ) created a wrapper script for the Balena CLI, which addresses the issue. The use |
+1 for this long-running request, even the MVP of only allowing docker-compose files that are in the same top-level directory would be helpful. It's very common in my work to see two patterns involving docker-compose naming: Renaming the "prod" compose definition:
Using a different definition which adds containers that only work on certain platforms
In Balena, I'd use this to deploy the same robot project to two fleets - One which is running on Jetson and needs to include CV containers in the release, and one running on RPi which does not need to include + run the CV containers in the release. Docker compose itself makes this easy with the |
I could not find anything in the Balena feature requests that documents this, so I've created one here: https://feature-requests.balena.io/posts/152/cli-support-for-non-default-or-multiple-compose-files |
Given a directory with more than one docker-compose file, users would like the ability to be able to select one or another of them.
Probably the best way to do this would be a flag to
balena push
.Please keep in mind that we try to use the issue tracker of this repository for specific bug reports & CLI feature requests. General & troubleshooting questions are encouraged to be posted to the balena forums where the community can both contribute and benefit from the answers.
Before submitting this issue please check that this issue is not a duplicate. If there is another issue describing the same problem or feature please add your information to the existing issue's comments.
Front conversations
The text was updated successfully, but these errors were encountered: