Skip to content

Commit

Permalink
Let runner-base default to builder-base
Browse files Browse the repository at this point in the history
  • Loading branch information
lhstrh committed Jun 17, 2024
1 parent e911799 commit fdc0854
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
7 changes: 6 additions & 1 deletion core/src/main/java/org/lflang/generator/GeneratorBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,12 @@ protected boolean buildUsingDocker() {
dockerData.copyScripts(context);
dockerCompose.writeDockerComposeFile(List.of(dockerData));
} catch (IOException e) {
context.getErrorReporter().nowhere().error("Error while writing Docker files: " + (e.getMessage() == null ? "No cause given" : e.getMessage()));
context
.getErrorReporter()
.nowhere()
.error(
"Error while writing Docker files: "
+ (e.getMessage() == null ? "No cause given" : e.getMessage()));
return false;
}
return dockerCompose.buildIfRequested();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ protected String generateEntryPoint() {
/** Return a COPY command to copy the executable from the builder to the runner. */
protected String generateCopyOfExecutable() {
var lfModuleName = context.getFileConfig().name;
return "COPY --from=builder /lingua-franca/%s/bin/%s ./bin/%s" // safe because context.getFileConfig().name never contains spaces
// safe becaused context.getFileConfig().name never contains spaces
return "COPY --from=builder /lingua-franca/%s/bin/%s ./bin/%s"
.formatted(lfModuleName, lfModuleName, lfModuleName);
}

Expand Down Expand Up @@ -186,20 +187,24 @@ protected final List<String> getEntryPointCommands() {

/** Return the base image to be used during the building stage. */
protected String builderBase() {
return baseImage(context.getTargetConfig().get(DockerProperty.INSTANCE).builderBase());
return baseImage(
context.getTargetConfig().get(DockerProperty.INSTANCE).builderBase(), defaultImage());
}

/** Return the base image to be used during the running stage. */
protected String runnerBase() {
return baseImage(context.getTargetConfig().get(DockerProperty.INSTANCE).runnerBase());
return baseImage(
context.getTargetConfig().get(DockerProperty.INSTANCE).runnerBase(),
baseImage(
context.getTargetConfig().get(DockerProperty.INSTANCE).builderBase(), defaultImage()));
}

/** Return the selected base image, or the default one if none was selected. */
private String baseImage(String name) {
private String baseImage(String name, String defaultImage) {
if (name != null && !name.isEmpty()) {
return name;
}
return defaultImage();
return defaultImage;
}

/**
Expand Down

0 comments on commit fdc0854

Please sign in to comment.