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 support for --project-directory #216

Closed
R0Wi opened this issue Sep 27, 2021 · 7 comments
Closed

Add support for --project-directory #216

R0Wi opened this issue Sep 27, 2021 · 7 comments
Assignees
Milestone

Comments

@R0Wi
Copy link

R0Wi commented Sep 27, 2021

First of all thanks for creating this awesome library!

I have a question which might result in a feature request. My current setup contains two different docker-compose.yml files in two different directories (let's call them docker-compose.v1.yml and docker-compose.v2.yml). I want to set docker-compose.v1.yml as my base file and then have some test specific overrides in docker-compose.v2.yml, which especially override some relative host mount points i need for my tests.

docker-compose.v1.yml:

version: '2.4'
services:
  s1:
    # ... 
    volumes:
        - ./myprodfiles:/etc/files

docker-compose.v2.yml:

version: '2.4'
services:
  s1:
    # ... 
    volumes:
        - ./mytestfiles:/etc/files

So what i would do in my console is something like

docker-compose -f ../../../docker-compose.v1.yml -f ./docker-compose.v2.yml --project-directory . up

The important part is the --project-directory parameter (see https://docs.docker.com/compose/reference/). If i omit this parameter, docker-compose would try to resolve all relative host mount points to the first given docker-compose.yml-file (docker-compose.v1.yml in that case). But i would like to have my relative paths resolved relative to docker-compose.v2.yml, so relative to the current directory. According to the docs (see link above):

When you use multiple Compose files, all paths in the files are relative to the first configuration file specified with -f. You can use the --project-directory option to override this base path.

Question: is it possible to achieve this with FluentDocker library? Unfortunately i did not find a possibility to add the --project-directory-parameter and i did not find any workaround neither.

Thanks so much!

@mariotoffia
Copy link
Owner

mariotoffia commented Sep 28, 2021

Hi @R0Wi, and thanks for this excellent feature report! 👍🏻

I'll add

UseProjectDirectory()

in the FluentAPI - OK?

Cheers,
Mario :)

@mariotoffia mariotoffia self-assigned this Sep 28, 2021
@mariotoffia mariotoffia added this to the 3.0.0-RELEASE milestone Sep 28, 2021
@mariotoffia mariotoffia added the waiting-for-feedback Waiting for someone to give feedback until this issue can be brought further. label Sep 28, 2021
@R0Wi
Copy link
Author

R0Wi commented Sep 28, 2021

Sounds great to me! Just let me know if i can support you by implementing or testing things 🚀

@mariotoffia
Copy link
Owner

mariotoffia commented Sep 28, 2021

Hi @R0Wi,

I've done a first quick attempt at this. Use the standard builder but add the

UseProjectDir(".")

to allow rendering --project-directory .

You may use any environment and macros since it is a TemplateString.

Please let me know how if it works properly or if there's something to fix or otherwise alter!

Cheers,
Mario :)

@R0Wi
Copy link
Author

R0Wi commented Sep 28, 2021

Great, thanks. Really looking forward to check the feature out these days 😎

@mariotoffia
Copy link
Owner

If you'd like to help - could you please write a simple unittest for this feature?

In the:
Ductus.FluentDocker.Tests.FluentApiTests.FluentDockerComposeTests

Cheers,
Mario

@R0Wi
Copy link
Author

R0Wi commented Sep 29, 2021

Sure 👍

@mariotoffia mariotoffia removed the waiting-for-feedback Waiting for someone to give feedback until this issue can be brought further. label Sep 29, 2021
@mariotoffia
Copy link
Owner

mariotoffia commented Sep 29, 2021

I've merged it into the master so it will be available on NuGet since it won't have any compatibility issues.
(main issue is that I'm using a git version task that does not work properly in every situation - need to replace that :))

Don't hesitate to reopen this issue if it is not working for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants