Skip to content
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 --profile NAME option to support selectively enabling services #430

Closed
redsaz opened this issue Feb 16, 2022 · 14 comments · Fixed by #592
Closed

Add --profile NAME option to support selectively enabling services #430

redsaz opened this issue Feb 16, 2022 · 14 comments · Fixed by #592
Labels
enhancement New feature or request

Comments

@redsaz
Copy link

redsaz commented Feb 16, 2022

docker-compose supports selectively enabling services through specifying profiles in the docker-compose.yaml file, and then running those service with docker-compose --profile NAME.

This option would be nice to have in podman-compose as well, as I have times where some services don't need started, like when I'm writing changes for an app, but still need the other services up to test against.

A workaround I'm using now is to specify different compose config files, which works, but is less convenient than having one file with the entirety of the config.

@redsaz redsaz added the enhancement New feature or request label Feb 16, 2022
@dixonwhitmire
Copy link
Contributor

I have the bandwidth to work on this issue (but I'm not a maintainer). Would a reasonable "first pass" include support for both --profile and the COMPOSE_PROFILES env variable?

Based on what I've read in the documentation these would be evaluated for the up and run commands. If anyone has a link which states which commands evaluate --profile I will be happy to review it.

@dixonwhitmire
Copy link
Contributor

dixonwhitmire commented Oct 28, 2022

This to-do list may change a bit as I start working on the feature but here is what I think I will need to do from a high level. I'll update this comment as items are completed:

  • Test case scaffolding
  • review _parse_args and how to best handle --profile
  • Tests cases for config, up, and down

@jjjj326562
Copy link

@dixonwhitmire Looks like a good start to me

@Arano-kai
Copy link

I have the bandwidth to work on this issue (but I'm not a maintainer). Would a reasonable "first pass" include support for both --profile and the COMPOSE_PROFILES env variable?

Based on what I've read in the documentation these would be evaluated for the up and run commands. If anyone has a link which states which commands evaluate --profile I will be happy to review it.

As I recall --profile also applies to config, down and stop.
If it helps: For the docker-compose-plugin --profile is valid immediately after compose, but throws errors after run and others, which may indicate an application to any command that manipulates containers.

@dixonwhitmire
Copy link
Contributor

dixonwhitmire commented Nov 1, 2022

I have the bandwidth to work on this issue (but I'm not a maintainer). Would a reasonable "first pass" include support for both --profile and the COMPOSE_PROFILES env variable?
Based on what I've read in the documentation these would be evaluated for the up and run commands. If anyone has a link which states which commands evaluate --profile I will be happy to review it.

As I recall --profile also applies to config, down and stop. If it helps: For the docker-compose-plugin --profile is valid immediately after compose, but throws errors after run and others, which may indicate an application to any command that manipulates containers.

@Arano-kai - thanks for the feedback. I'll see if I can get compose up and running again on my laptop so that I can test a bit before embarking down the podman compose path.

I do recognize that --profile is a global option of sorts. What I will also need to do is see if I can filter the services in podman compose prior to invoking the associated command, so that I don't have to update "N" number of command implementations.

@dixonwhitmire
Copy link
Contributor

dixonwhitmire commented Nov 1, 2022

And here's the official doc. The sections on auto-enablement and dependency resolution are helpful.

Although for this first PR I think it may be helpful to have a narrower scope and start out with the changes required to support "explicit enablement" with --profile and COMPOSE_PROFILES. I'm concerned that "doing more" will significantly increase the "time to deliver" and will also change quite a bit in the current code-base which is defined within a single source file.

<Updated this comment to include "profile aware" compose commands>

Profile aware commands:

  • convert/config (convert is an alias for config)
  • down
  • kill
  • restart
  • stop
  • start
  • up
  • pause
  • unpause

@Hubbitus
Copy link

Hubbitus commented Jun 3, 2023

Hello. Sorry, what is the version of podman-compose supporting --profile option?

@hedayat
Copy link
Contributor

hedayat commented Jun 7, 2023

I also like this feature, and it's sad that it just got merged a day after releasing 1.0.6. I'd say this change by itself justified having another 1.0.7 release :D :P

Anyway, hope it'll be release soon. thanks for your work :)

@lzap
Copy link

lzap commented Jun 8, 2023

Also looking forward this feature! Cut the release please :-D Cheers.

@dottorblaster
Copy link

Same 🥲

@brunomcuesta
Copy link

Any updates on this feature?

@rnestler
Copy link

Judging from the release notes it looks like this is included in 1.1.0: https://github.com/containers/podman-compose/releases/tag/v1.1.0

Added support for profile argument.

@piotr-dobrogost
Copy link

piotr-dobrogost commented Oct 4, 2024

Profile aware commands:

convert/config (convert is an alias for config)
down
kill
restart
stop
start
up
pause
unpause

This list is missing compose config --profiles (plural) (which is different than compose --profile NAME config) which lists all profiles and which should be treated as an integral part of profile support.
I raised this problem as #1052

@ch-reck
Copy link

ch-reck commented Nov 7, 2024

podman-compose.py is still ignoring the COMPOSE_PROFILES setting in .env
See issue that solved this for docker compose: docker-archive/compose-cli#1492

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.