Skip to content

Commit

Permalink
Merge pull request #108 from aguibert/liberty-optional-configdir
Browse files Browse the repository at this point in the history
 Add toleration for liberty image building when config dir is not present
  • Loading branch information
aguibert committed Nov 11, 2019
2 parents 86c8696 + 2692f61 commit 4a491f6
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,18 +97,25 @@ public void setConfigProperties(Map<String, String> 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/<appFile> /config/dropins
// COPY src/main/liberty/config /config/
// ADD build/libs/<appFile> /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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,13 @@
*/
public class MicroProfileApplication extends GenericContainer<MicroProfileApplication> {

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;
Expand Down Expand Up @@ -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);
}
}
}
Expand Down Expand Up @@ -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:
* <ol><li>The MicroProfile Health 2.0 readiness endpoint <code>/health/readiness</code>,
* if MP Health 2.0 API is accessible</li>
* <li>Otherwise, the application context root</li>
* </ol>
* 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.
Expand All @@ -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:
* <ol><li>The MicroProfile Health 2.0 readiness endpoint <code>/health/readiness</code>,
* if MP Health 2.0 API is accessible</li>
* <li>Otherwise, the application context root</li>
* </ol>
* 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.
Expand Down

0 comments on commit 4a491f6

Please sign in to comment.