fix(websocket): Nginx lane이 job 컨테이너 안의 앱에도 닿게 한다

websocketNginxTest의 Nginx 컨테이너는 host.docker.internal을
host-gateway(Docker 호스트)로 풀어 시험 JVM의 앱에 붙었다. desktop에서는
Docker 호스트가 곧 JVM의 호스트라 됐지만, Gitea runner처럼 job이 자기
컨테이너 안에서 돌면 앱은 거기 없다. release 수동 실행(run 51)의
websocket-stable-release-gate가 upgrade마다 DeploymentException으로
실패했다.

Testcontainers의 호스트 포트 노출(exposeHostPorts, withAccessToHost)로
host.testcontainers.internal을 이 JVM으로 잇는다. 두 환경에서 같은
이름이다. 버린 것: runner 설정을 host 네트워크로 바꾸기(platform-core 몫,
job 격리를 푼다).

위험: Testcontainers가 sshd 보조 컨테이너를 하나 더 띄운다(이미지는
Testcontainers가 고정한 것, container-images.properties 밖).

검증: desktop에서 :adapter:inbound:websocket:websocketNginxTest.
This commit is contained in:
DongHyeonka
2026-11-08 23:52:07 +09:00
parent d0c3f91a3b
commit b0bca2a62a
@@ -30,12 +30,15 @@ public final class NginxWebSocketHarness implements AutoCloseable {
*/
@SuppressWarnings("resource")
public NginxWebSocketHarness(int applicationPort, String configurationResource) {
// The application listens in this JVM's network, which a container reaches by name only through
// Testcontainers' host-port tunnel. `host-gateway` was the Docker host, which is this JVM's host
// on a workstation but not on a CI runner whose job runs in a container of its own (the Gitea
// runner): there Nginx reached nothing and every upgrade failed as a deployment error.
org.testcontainers.Testcontainers.exposeHostPorts(applicationPort);
this.nginx =
new GenericContainer<>(IMAGE)
.withExposedPorts(8080)
// host.docker.internal is not resolvable on stock Linux Docker; without the gateway
// the container fails with a connection refused that reads as a config error.
.withExtraHost("host.docker.internal", "host-gateway")
.withAccessToHost(true)
.withCopyToContainer(
Transferable.of(configuration(configurationResource, applicationPort)),
"/etc/nginx/nginx.conf");
@@ -68,7 +71,7 @@ public final class NginxWebSocketHarness implements AutoCloseable {
throw new IllegalStateException(resource + " is missing from the lane's resources");
}
return new String(stream.readAllBytes(), StandardCharsets.UTF_8)
.replace("APPLICATION_HOST", "host.docker.internal")
.replace("APPLICATION_HOST", "host.testcontainers.internal")
.replace("APPLICATION_PORT", Integer.toString(applicationPort));
} catch (IOException e) {
throw new IllegalStateException(resource + " could not be read", e);