From d0a198d0c2f7d683e7bea38eece320fc47bada68 Mon Sep 17 00:00:00 2001 From: Soner Sayakci Date: Wed, 24 Jan 2024 17:33:52 +0100 Subject: [PATCH] feat: add hooks for docker image generation --- cmd/project/docker_build.go | 18 ++++++++++++++++++ cmd/project/templates/Dockerfile.tpl | 6 ++++++ shop/config.go | 10 +++++++++- shop/shopware-project-schema.json | 22 ++++++++++++++++++++++ 4 files changed, 55 insertions(+), 1 deletion(-) diff --git a/cmd/project/docker_build.go b/cmd/project/docker_build.go index b34a66b5..628c0c32 100644 --- a/cmd/project/docker_build.go +++ b/cmd/project/docker_build.go @@ -106,11 +106,29 @@ func configureDockerfileTemplate(ctx context.Context, shopCfg *shop.Config) (map } } + hooks := make(map[string]string) + if shopCfg.Docker.Hooks.PreUpdate != "" { + hooks["pre_update"] = shopCfg.Docker.Hooks.PreUpdate + } + + if shopCfg.Docker.Hooks.PostUpdate != "" { + hooks["post_update"] = shopCfg.Docker.Hooks.PostUpdate + } + + if shopCfg.Docker.Hooks.PreInstall != "" { + hooks["pre_install"] = shopCfg.Docker.Hooks.PreInstall + } + + if shopCfg.Docker.Hooks.PostInstall != "" { + hooks["post_install"] = shopCfg.Docker.Hooks.PostInstall + } + templateVars := map[string]interface{}{ "PHP": shopCfg.Docker.PHP, "ExcludePaths": shopCfg.Docker.ExcludePaths, "BuildEnv": strings.Join(buildEnvironments, " "), "RunEnv": strings.Join(runEnvironments, " "), + "Hooks": hooks, } return templateVars, nil diff --git a/cmd/project/templates/Dockerfile.tpl b/cmd/project/templates/Dockerfile.tpl index 2bddfb1a..b95d0a50 100644 --- a/cmd/project/templates/Dockerfile.tpl +++ b/cmd/project/templates/Dockerfile.tpl @@ -45,4 +45,10 @@ FROM base-extended ENV {{ .RunEnv }} {{- end }} +{{- range $key, $value := .Hooks }} +COPY --chmod=555 <