Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Secret store local file, relative file pathing #58

Open
joelsteventurner opened this issue Aug 22, 2023 · 2 comments
Open

Secret store local file, relative file pathing #58

joelsteventurner opened this issue Aug 22, 2023 · 2 comments

Comments

@joelsteventurner
Copy link

In the Dapr Secret store local file examples they tend to use relative file paths to the secrets file, which doesn't seem to work when using SideKick. I keep getting a fatal error , can't find secrets file.

I suspect the fix for this would be to make the working directory for the application consuming the yaml files based on the application you are building rather than the Dapr infrastructure directories.

Any suggestions?

@IliasP91
Copy link
Contributor

IliasP91 commented Sep 27, 2023

Okay I have a little update. I managed to write a working solution using the existing released version of sidekick.

If you notice i build a new file path for the daprd.exe and set CopyProcessFile to true
The reason is that sidekick starts the managed process in the location of the dapr cli installation and sets its working directory to the same directory. For that reason relative paths dont work in components as its not within our project, however if we copy it like this, its located in the correct place so everything works out.

A better solution would be an option to allow us set/override the working directory. I will raise a PR for that but in the short term this works great.

var builder = WebApplication.CreateBuilder(args);
var environment = builder.Environment;
var configuration = builder.Configuration;

// Manage local dapr sidecar
if (environment.IsDevelopment())
{
    var sidecarOptions = new DaprSidecarOptions
    {
        AppId = "my-service",
        AppPort = 5000,
        // Replace the following with ResourcesDirectory = Path.Combine(Environment.ContentRootPath, "Dapr/Components"), on the next release
        ComponentsDirectory = "./Dapr/Components",
        CustomArguments = $"--resources-path {Path.Combine(environment.ContentRootPath, "Dapr/Components")}",

        // Currently there's no option to override the working directory when the managed daprd process starts
        // so we copy it to the project directory to let the local components use relative paths
        ProcessFile = Path.Combine(environment.ContentRootPath, "daprd.exe"),
        CopyProcessFile = true
    };

    // Add Dapr Sidekick hosted service, it will attach and reuse the already started process above
    builder.Services.AddDaprSidekick(
        configuration,
        c =>
        {
            c.Sidecar = sidecarOptions;
        });
}

...etc

@IliasP91
Copy link
Contributor

relevant PR #59

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants