-
Notifications
You must be signed in to change notification settings - Fork 51
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: Connection to host network from LocalStack container #1198
Conversation
if (localStackDevServicesBuildTimeConfig.accessToHost()) { | ||
Testcontainers.exposeHostPorts(localStackDevServicesBuildTimeConfig.hostPort()); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (localStackDevServicesBuildTimeConfig.accessToHost()) { | |
Testcontainers.exposeHostPorts(localStackDevServicesBuildTimeConfig.hostPort()); | |
} | |
container.withAccessToHost(localStackDevServicesBuildTimeConfig.accessToHost); |
This would force the host access setup and let users configure exposed host port themself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How would users be able to configure exposed port?
I've tried by intercepting the quarkus startup event on my application:
@ApplicationScoped
@IfBuildProfile("dev")
public class DevLifecycleBean {
@ConfigProperty(name = "quarkus.http.port")
int port;
void onStart(@Observes StartupEvent ev) {
Testcontainers.exposeHostPorts(port);
}
}
exposeHostPorts()
gets called with the right port as argument but then connection to host is refused, I've not investigated why though.
Apart from the difficulties, I do not like much this solution because a seamless integration is being traded for boilerplate code + testcontainers runtime dependency on the application side.
In my solution the host port is user-configurable via host-port
property, however most of the time would be retrieved from quarkus.http.port
property without requiring tweaks.
An edit I could make is accepting multiple ports instead of just 1, if that's useful.
The same approach is used on the Quarkus Jib extension.
This PR is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 14 days. |
This PR is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 14 days. |
This PR was closed because it has been stalled for 10 days with no activity. |
close #1161