Skip to content

Commit

Permalink
feat: allow to specify docker image variant
Browse files Browse the repository at this point in the history
  • Loading branch information
shyim committed Jan 29, 2024
1 parent 3ea9d7d commit 9b54b5f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions cmd/project/docker_build.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ func configureDockerfileTemplate(ctx context.Context, shopCfg *shop.Config) (map

templateVars := map[string]interface{}{
"PHP": shopCfg.Docker.PHP,
"Variant": shopCfg.Docker.Variant,
"ExcludePaths": shopCfg.Docker.ExcludePaths,
"BuildEnv": strings.Join(buildEnvironments, " "),
"RunEnv": strings.Join(runEnvironments, " "),
Expand Down
2 changes: 1 addition & 1 deletion cmd/project/templates/Dockerfile.tpl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#syntax=docker/dockerfile:1.4

# pin versions
FROM shopware/docker-base:{{.PHP.PhpVersion}} as base-image
FROM shopware/docker-base:{{.PHP.PhpVersion}}-{{ .Variant }} as base-image
FROM ghcr.io/friendsofshopware/shopware-cli:latest-php-{{.PHP.PhpVersion}} as shopware-cli

FROM base-image as base-extended
Expand Down
5 changes: 5 additions & 0 deletions shop/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ type ConfigDocker struct {
PHP ConfigDockerPHP `yaml:"php,omitempty"`
ExcludePaths []string `yaml:"exclude_paths,omitempty"`
Hooks ConfigDockerHooks `yaml:"hooks,omitempty"`
Variant string `yaml:"variant,omitempty"`
}

type ConfigDockerHooks struct {
Expand Down Expand Up @@ -171,6 +172,10 @@ func fillEmptyConfig(c *Config) *Config {
}
}

if c.Docker.Variant == "" {
c.Docker.Variant = "caddy"
}

return c
}

Expand Down
5 changes: 5 additions & 0 deletions shop/shopware-project-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@
"type": "array",
"items": {"type": "string"}
},
"variant": {
"type": "string",
"enum": ["caddy", "fpm"],
"default": "caddy"
},
"hooks": {
"type": "object",
"additionalProperties": false,
Expand Down

0 comments on commit 9b54b5f

Please sign in to comment.