From c0186d95123521e3a912f4c0ba8b114da47e9a90 Mon Sep 17 00:00:00 2001 From: Jon Edvald Date: Thu, 7 Jun 2018 18:54:49 +0200 Subject: [PATCH] fix(container): build issue where Dockerfile is copied or generated --- src/plugins/container.ts | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/plugins/container.ts b/src/plugins/container.ts index 144f0cf753..a389cf6b61 100644 --- a/src/plugins/container.ts +++ b/src/plugins/container.ts @@ -8,7 +8,6 @@ import * as Joi from "joi" import * as childProcess from "child-process-promise" -import { PluginContext } from "../plugin-context" import { Module, ModuleConfig, @@ -245,10 +244,8 @@ export const helpers = { } }, - async pullImage(ctx: PluginContext, module: ContainerModule) { + async pullImage(module: ContainerModule) { const identifier = await helpers.getRemoteImageId(module) - - ctx.log.info({ section: module.name, msg: `pulling image ${identifier}...` }) await helpers.dockerCli(module, `pull ${identifier}`) }, @@ -264,11 +261,12 @@ export const helpers = { }, async hasDockerfile(module: ContainerModule) { - return pathExists(join(module.path, "Dockerfile")) + const buildPath = await module.getBuildPath() + return pathExists(join(buildPath, "Dockerfile")) }, } -export async function parseContainerModule({ ctx, moduleConfig }: ParseModuleParams) { +export async function parseContainerModule({ moduleConfig }: ParseModuleParams) { moduleConfig.spec = validate(moduleConfig.spec, containerModuleSpecSchema, { context: `module ${moduleConfig.name}` }) // validate services @@ -327,10 +325,8 @@ export async function parseContainerModule({ ctx, moduleConfig }: ParseModulePar variables: t.variables, })) - const module = new ContainerModule(ctx, moduleConfig, services, tests) - // make sure we can build the thing - if (!(await getImage(module)) && !(await helpers.hasDockerfile(module))) { + if (!moduleConfig.spec.image && !(await pathExists(join(moduleConfig.path, "Dockerfile")))) { throw new ConfigurationError( `Module ${moduleConfig.name} neither specifies image nor provides Dockerfile`, {}, @@ -364,7 +360,7 @@ export const gardenPlugin = (): GardenPlugin => ({ return { ready: !!identifier } }, - async buildModule({ ctx, module, logEntry }: BuildModuleParams) { + async buildModule({ module, logEntry }: BuildModuleParams) { const buildPath = await module.getBuildPath() const image = await getImage(module) @@ -373,7 +369,7 @@ export const gardenPlugin = (): GardenPlugin => ({ return { fresh: false } } logEntry && logEntry.setState(`Pulling image ${image}...`) - await helpers.pullImage(ctx, module) + await helpers.pullImage(module) return { fetched: true } }