Skip to content

Commit 077c844

Browse files
authored
Deprecate setCustomContent and withCustomContent at NginxContainer (#5997)
In order to make `NginxContainer` friendly with remote environments, we should avoid the use of `addFileSystemBind`. Example has been updated in order to show how to do it.
1 parent 00c5e88 commit 077c844

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

modules/nginx/src/main/java/org/testcontainers/containers/NginxContainer.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,12 @@ public URL getBaseUrl(String scheme, int port) throws MalformedURLException {
5656
return new URL(scheme + "://" + getHost() + ":" + getMappedPort(port));
5757
}
5858

59+
@Deprecated
5960
public void setCustomContent(String htmlContentPath) {
6061
addFileSystemBind(htmlContentPath, "/usr/share/nginx/html", BindMode.READ_ONLY);
6162
}
6263

64+
@Deprecated
6365
public SELF withCustomContent(String htmlContentPath) {
6466
this.setCustomContent(htmlContentPath);
6567
return self();

modules/nginx/src/test/java/org/testcontainers/junit/SimpleNginxTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import org.testcontainers.containers.NginxContainer;
88
import org.testcontainers.containers.wait.strategy.HttpWaitStrategy;
99
import org.testcontainers.utility.DockerImageName;
10+
import org.testcontainers.utility.MountableFile;
1011

1112
import java.io.*;
1213
import java.net.URL;
@@ -26,7 +27,7 @@ public class SimpleNginxTest {
2627
// creatingContainer {
2728
@Rule
2829
public NginxContainer<?> nginx = new NginxContainer<>(NGINX_IMAGE)
29-
.withCustomContent(tmpDirectory)
30+
.withCopyFileToContainer(MountableFile.forHostPath(tmpDirectory), "/usr/share/nginx/html")
3031
.waitingFor(new HttpWaitStrategy());
3132

3233
// }

0 commit comments

Comments
 (0)