diff --git a/modules/liberty/src/main/java/org/testcontainers/containers/liberty/LibertyAdapter.java b/modules/liberty/src/main/java/org/testcontainers/containers/liberty/LibertyAdapter.java index 929cd1d2..4de2abe0 100644 --- a/modules/liberty/src/main/java/org/testcontainers/containers/liberty/LibertyAdapter.java +++ b/modules/liberty/src/main/java/org/testcontainers/containers/liberty/LibertyAdapter.java @@ -97,18 +97,25 @@ public void setConfigProperties(Map properties) { @Override public ImageFromDockerfile getDefaultImage(File appFile) { - String appName = appFile.getName(); + final String appName = appFile.getName(); + final File configDir = new File("src/main/liberty/config"); + final boolean configDirExists = configDir.exists() && configDir.canRead(); // Compose a docker image equivalent to doing: // FROM open-liberty:microProfile3 - // ADD build/libs/ /config/dropins // COPY src/main/liberty/config /config/ + // ADD build/libs/ /config/dropins ImageFromDockerfile image = new ImageFromDockerfile() - .withDockerfileFromBuilder(builder -> builder.from(getBaseDockerImage()) - .add("/config/dropins/" + appName, "/config/dropins/" + appName) - .copy("/config", "/config") - .build()) - .withFileFromFile("/config/dropins/" + appName, appFile) - .withFileFromFile("/config", new File("src/main/liberty/config")); + .withDockerfileFromBuilder(builder -> { + builder.from(getBaseDockerImage()); + if (configDirExists) { + builder.copy("/config", "/config"); + } + builder.add("/config/dropins/" + appName, "/config/dropins/" + appName); + builder.build(); + }) + .withFileFromFile("/config/dropins/" + appName, appFile); + if (configDirExists) + image.withFileFromFile("/config", configDir); return image; } diff --git a/modules/testcontainers/src/main/java/org/microshed/testing/testcontainers/MicroProfileApplication.java b/modules/testcontainers/src/main/java/org/microshed/testing/testcontainers/MicroProfileApplication.java index 0b7d48bb..3796a66f 100644 --- a/modules/testcontainers/src/main/java/org/microshed/testing/testcontainers/MicroProfileApplication.java +++ b/modules/testcontainers/src/main/java/org/microshed/testing/testcontainers/MicroProfileApplication.java @@ -65,18 +65,13 @@ */ public class MicroProfileApplication extends GenericContainer { - private static final String MP_HEALTH_READINESS_PATH = "/health/ready"; + /** + * A path representing the MicroProfile Health 2.0 readiness check + */ + public static final String MP_HEALTH_READINESS_PATH = "/health/ready"; + private static final Logger LOGGER = LoggerFactory.getLogger(MicroProfileApplication.class); - private static final boolean mpHealth20Available; private static final boolean isHollow = isHollow(); - static { - Class readinessClass = null; - try { - readinessClass = Class.forName("org.eclipse.microprofile.health.Readiness"); - } catch (ClassNotFoundException e) { - } - mpHealth20Available = readinessClass != null; - } private String appContextRoot; private ServerAdapter serverAdapter; @@ -232,13 +227,12 @@ protected void configure() { super.configure(); // If the readiness path was not set explicitly, default it to: // A) The value defined by ServerAdapter.getReadinessPath(), if any - // B) The standard MP Health 2.0 readiness endpoint (if available) - // C) the app context root + // B) the app context root if (!readinessPathSet) { - if (serverAdapter != null && serverAdapter.getReadinessPath().isPresent() && !serverAdapter.getReadinessPath().get().trim().isEmpty()) { + if (serverAdapter != null && serverAdapter.getReadinessPath().isPresent()) { withReadinessPath(serverAdapter.getReadinessPath().get()); } else { - withReadinessPath(mpHealth20Available ? MP_HEALTH_READINESS_PATH : appContextRoot); + withReadinessPath(appContextRoot); } } } @@ -322,11 +316,7 @@ public MicroProfileApplication withAppContextRoot(String appContextRoot) { /** * Sets the path to be used to determine container readiness. The readiness check will * timeout after a sensible amount of time has elapsed. - * If unspecified, the readiness path with defailt to either: - *
  1. The MicroProfile Health 2.0 readiness endpoint /health/readiness, - * if MP Health 2.0 API is accessible
  2. - *
  3. Otherwise, the application context root
  4. - *
+ * If unspecified, the readiness path with defailt to the application context root * * @param readinessUrl The HTTP endpoint to be polled for readiness. Once the endpoint * returns HTTP 200 (OK), the container is considered to be ready. @@ -340,11 +330,7 @@ public MicroProfileApplication withReadinessPath(String readinessUrl) { /** * Sets the path to be used to determine container readiness. The readiness check will * timeout after a sensible amount of time has elapsed. - * If unspecified, the readiness path with defailt to either: - *
  1. The MicroProfile Health 2.0 readiness endpoint /health/readiness, - * if MP Health 2.0 API is accessible
  2. - *
  3. Otherwise, the application context root
  4. - *
+ * If unspecified, the readiness path with defailt to the application context root * * @param readinessUrl The HTTP endpoint to be polled for readiness. Once the endpoint * returns HTTP 200 (OK), the container is considered to be ready.