Skip to content

Commit

Permalink
fix(maven-container): always copy Dockerfile to build dir before build
Browse files Browse the repository at this point in the history
  • Loading branch information
edvald committed Mar 18, 2019
1 parent d09e454 commit fada240
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions garden-service/src/plugins/maven-container/maven-container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { containerModuleSpecSchema } from "../container/config"
import { providerConfigBaseSchema } from "../../config/project"
import { openJdks } from "./openjdk"
import { maven } from "./maven"
import { LogEntry } from "../../logger/log-entry"

const defaultDockerfilePath = resolve(STATIC_DIR, "maven-container", "Dockerfile")

Expand Down Expand Up @@ -120,12 +121,7 @@ async function configure(params: ConfigureModuleParams<MavenContainerModule>) {
async function getBuildStatus(params: GetBuildStatusParams<MavenContainerModule>) {
const { module, log } = params

// Copy the default Dockerfile to the build directory, if the module doesn't provide one
// Note: Doing this here so that the build status check works as expected.
if (!(await containerHelpers.hasDockerfile(module))) {
log.debug(`Using default Dockerfile`)
await copy(defaultDockerfilePath, resolve(module.buildPath, "Dockerfile"))
}
await prepareBuild(module, log)

return getContainerBuildStatus(params)
}
Expand Down Expand Up @@ -178,9 +174,19 @@ async function build(params: BuildModuleParams<MavenContainerModule>) {
await copy(resolvedJarPath, resolve(module.buildPath, "app.jar"))

// Build the container
await prepareBuild(module, log)
return buildContainerModule(params)
}

async function prepareBuild(module: MavenContainerModule, log: LogEntry) {
// Copy the default Dockerfile to the build directory, if the module doesn't provide one
// Note: Doing this here so that the build status check works as expected.
if (!(await containerHelpers.hasDockerfile(module))) {
log.debug(`Using default Dockerfile`)
await copy(defaultDockerfilePath, resolve(module.buildPath, "Dockerfile"))
}
}

async function loadPom(dir: string) {
try {
const pomPath = resolve(dir, "pom.xml")
Expand Down

0 comments on commit fada240

Please sign in to comment.