-
Notifications
You must be signed in to change notification settings - Fork 3
Add static port mapping option for LocalStack docker container (fix #13) #15
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 static port mapping option for LocalStack docker container (fix #13) #15
Conversation
|
@Blind-Striker, it seems the pipeline is failing due to external issues. In my version of repo, only 2 Linux tests are failing (https://github.com/nazarii-piontko/dotnet-aspire-for-localstack/actions/runs/19018715149). Could you please help? What could be the issue? |
|
@nazarii-piontko, it’s probably a permission issue. Things are a bit hectic at work today, but I’ll take a look as soon as I can. |
|
I did consider this option, but the thing I'm confused about networking in aspire in general (docs), it seems that when the external and internal port are different, whatever you set This PR is an improvement, but how should this work more generally? I was hoping that aspire proxies the requests, and there wouldn't be a static configured host at all. |
|
Aspire does proxy this request. However, as I understand it, LocalStack needs the Also, setting a specific port value is useful for testing purposes. Imagine you’re using |
|
The only problem with this solution occurs when someone already has LocalStack running on their computer and then tries to run an Aspire project that configures a new LocalStack instance in persistent mode. In this case, the user might encounter a port allocation issue (depends on selected port), but the same thing would happen if a .NET project’s port conflicted with another process running on the machine. |
Hey @nazarii-piontko, I just pushed a small fix to master. Could you update this branch with the latest changes? The tests should now pass without any issues. I made the test report step fail gracefully. |
|
Hey @slang25 @nazarii-piontko, Back in the day, the reason I switched from a static port setup to a dynamic one (i.e., letting the Aspire lifecycle handle the assignment) was actually because of this issue: 👉 #4 Even though I had disabled port randomization, as documented here: https://github.com/dotnet/docs-aspire/blob/main/docs/testing/overview.md#disable-port-randomization Somehow, the Aspire test framework still couldn’t properly proxy requests to the LocalStack container. As a result, the library wasn’t compatible with the Aspire testing framework at that time. Honestly, I’m not entirely sure how we managed to get past that issue now 😅 From what I can tell, since we’re setting the LOCALSTACK_HOST here: it seems to work fine whether we’re using dynamic or static ports. The tests appear to be passing cleanly, which is great. I’m just wondering whether this concern really belongs to LocalStackContainerOptions or to LocalStackOptions (ConfigOptions) I’ve always designed As far as I can see, there’s no need to modify the |
|
Quick question for LocalStack experts (cc: @HarshCasper - not blocking this PR, just seeking your expertise!) In .NET Aspire, the orchestration layer automatically:
https://learn.microsoft.com/en-us/dotnet/aspire/fundamentals/networking-overview The flow: When using Questions:
All our unit and integration tests are passing ✅, so it's working in practice. Just want to ensure we're following LocalStack best practices and not setting unnecessary env vars or missing edge cases. Thanks for any insights! 🙏 |
Fix #13.
The root cause is the dynamic port assignment for the HTTP endpoint, which causes the
LOCALSTACK_HOSTenvironment variable to change between runs, leading to container recreation. Ideally, the port should be configurable viaLocalStackContainerOptions. However, it’s also important to keep the port dynamic whenContainerLifetimeis set toSessionto maintain backward compatibility.