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

feat: Update CosmosDb image to vnext-preview version #1324

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

NelsonBN
Copy link

@NelsonBN NelsonBN commented Dec 31, 2024

What does this PR do?

This PR updates the CosmosDb image to the new version Microsoft is working on

Linux-based emulator (preview)
GitHub Repository

Why is it important?

This new image significantly improves the container startup process, eliminates certificate-related workarounds, and integrates seamlessly with CI/CD pipelines like GitHub Actions. For reference, you can check some of my tests here and GitActions here.

Related issues

#1306

Details

Explorer UI Disabled

The explorer UI was disabled since the container's purpose is to test integration with the Cosmos DB API.

return base.Init()
    .WithImage(CosmosDbImage)
    .WithEnvironment("ENABLE_EXPLORER", "false");

Internal Routing Configuration

For internal routing to work as expected, the API port and mapping port need to be configured with the same value. References.

.WithEnvironment("PORT", CosmosDbPort.ToString())
.WithPortBinding(CosmosDbPort, CosmosDbPort);

CosmosClient Configuration

The CosmosClient must be configured to use Gateway mode. See the official guidance.

public CosmosClient CosmosClient => new(GetConnectionString(), new() { ConnectionMode = ConnectionMode.Gateway });

Copy link

netlify bot commented Dec 31, 2024

Deploy Preview for testcontainers-dotnet ready!

Name Link
🔨 Latest commit 53f35d8
🔍 Latest deploy log https://app.netlify.com/sites/testcontainers-dotnet/deploys/6776cfee4a8c1f00085cabdd
😎 Deploy Preview https://deploy-preview-1324--testcontainers-dotnet.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Collaborator

@HofmeisterAn HofmeisterAn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for creating the PR. Have you seen this discussion? I would like to wait until an official version is published. In addition, we do not use static ports. While GetAvailablePort() does not return a static port per se, it may fail for remote container runtimes (it does not resolve the mapped port from the container host).

For internal routing to work as expected, the API port and mapping port need to be configured with the same value. References.

According to the discussion, this is unnecessary, and it is why we used the DelegatingHandler in the past.

I think we can prepare a PR and merge it as soon as the official version is published, but I favor and would like to implement the proposed changes from the discussion.

@NelsonBN
Copy link
Author

Thanks for creating the PR. Have you seen this discussion? I would like to wait until an official version is published. In addition, we do not use static ports. While GetAvailablePort() does not return a static port per se, it may fail for remote container runtimes (it does not resolve the mapped port from the container host).

For internal routing to work as expected, the API port and mapping port need to be configured with the same value. References.

According to the discussion, this is unnecessary, and it is why we used the DelegatingHandler in the past.

I think we can prepare a PR and merge it as soon as the official version is published, but I favor and would like to implement the proposed changes from the discussion.

@HofmeisterAn Thanks for your comment. I hadn't come across that discussion. I only checked if there were any open issues. I ended up commenting there in the discussion as well.

Looking at the discussion, it seems that using the rewriting of the DelegatingHandler is still the best approach, as it also removes the need to know in advance the port where the container will be randomly opened. Even so, some workarounds, like bypassing the certificate, are no longer necessary.

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

Successfully merging this pull request may close these issues.

2 participants