barrel: Use default value for base image
This commit is contained in:
parent
5a85494194
commit
154f9a93ea
6 changed files with 38 additions and 33 deletions
|
|
@ -6,6 +6,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/FAU-CDI/wisski-distillery/internal/config/validators"
|
"github.com/FAU-CDI/wisski-distillery/internal/config/validators"
|
||||||
|
"github.com/FAU-CDI/wisski-distillery/internal/models"
|
||||||
"github.com/FAU-CDI/wisski-distillery/internal/wisski"
|
"github.com/FAU-CDI/wisski-distillery/internal/wisski"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -14,29 +15,6 @@ var (
|
||||||
errRestrictedSlug = errors.New("restricted slug")
|
errRestrictedSlug = errors.New("restricted slug")
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
|
||||||
PHP8 = "8.0"
|
|
||||||
PHP8_IMAGE = "docker.io/library/php:8.0-apache-bullseye"
|
|
||||||
PHP8_1 = "8.1"
|
|
||||||
PHP8_1_IMAGE = "docker.io/library/php:8.1-apache-bullseye"
|
|
||||||
)
|
|
||||||
|
|
||||||
var errUnknownPHPVersion = errors.New("unknown php version")
|
|
||||||
|
|
||||||
// GetBaseImage returns the php base image to use
|
|
||||||
func GetBaseImage(php string) (string, error) {
|
|
||||||
switch php {
|
|
||||||
case "":
|
|
||||||
return PHP8_IMAGE, nil
|
|
||||||
case PHP8:
|
|
||||||
return PHP8_IMAGE, nil
|
|
||||||
case PHP8_1:
|
|
||||||
return PHP8_1_IMAGE, nil
|
|
||||||
default:
|
|
||||||
return "", errUnknownPHPVersion
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create fills the struct for a new WissKI instance.
|
// Create fills the struct for a new WissKI instance.
|
||||||
// It validates that slug is a valid name for an instance.
|
// It validates that slug is a valid name for an instance.
|
||||||
//
|
//
|
||||||
|
|
@ -88,7 +66,7 @@ func (instances *Instances) Create(slug string, phpversion string) (wissKI *wiss
|
||||||
}
|
}
|
||||||
|
|
||||||
// docker image
|
// docker image
|
||||||
wissKI.Liquid.Instance.DockerBaseImage, err = GetBaseImage(phpversion)
|
wissKI.Liquid.Instance.DockerBaseImage, err = models.GetBaseImage(phpversion)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import (
|
||||||
|
|
||||||
"github.com/FAU-CDI/wisski-distillery/internal/dis/component"
|
"github.com/FAU-CDI/wisski-distillery/internal/dis/component"
|
||||||
"github.com/FAU-CDI/wisski-distillery/internal/dis/component/instances"
|
"github.com/FAU-CDI/wisski-distillery/internal/dis/component/instances"
|
||||||
|
"github.com/FAU-CDI/wisski-distillery/internal/models"
|
||||||
"github.com/FAU-CDI/wisski-distillery/internal/wisski"
|
"github.com/FAU-CDI/wisski-distillery/internal/wisski"
|
||||||
"github.com/FAU-CDI/wisski-distillery/pkg/logging"
|
"github.com/FAU-CDI/wisski-distillery/pkg/logging"
|
||||||
"github.com/tkw1536/pkglib/fsx"
|
"github.com/tkw1536/pkglib/fsx"
|
||||||
|
|
@ -37,7 +38,7 @@ func (pv *Provision) ValidateFlags(flags ProvisionFlags) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// check for known php versions
|
// check for known php versions
|
||||||
if _, err := instances.GetBaseImage(flags.PHPVersion); err != nil {
|
if _, err := models.GetBaseImage(flags.PHPVersion); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
|
||||||
|
|
@ -34,11 +34,7 @@
|
||||||
Docker Base Image
|
Docker Base Image
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{{ if .Instance.DockerBaseImage }}
|
<code>{{ .Instance.GetDockerBaseImage }}</code>
|
||||||
<code>{{ .Instance.DockerBaseImage }}</code>
|
|
||||||
{{ else }}
|
|
||||||
(none)
|
|
||||||
{{ end }}
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ type Instance struct {
|
||||||
FilesystemBase string `gorm:"column:filesystem_base;not null"`
|
FilesystemBase string `gorm:"column:filesystem_base;not null"`
|
||||||
|
|
||||||
// DockerBaseImage is the php base image to use
|
// DockerBaseImage is the php base image to use
|
||||||
DockerBaseImage string `gorm:"column:docker_base;not_null`
|
DockerBaseImage string `gorm:"column:docker_base;not_null"`
|
||||||
|
|
||||||
// SQL Database credentials for the system
|
// SQL Database credentials for the system
|
||||||
SqlDatabase string `gorm:"column:sql_database;not null"`
|
SqlDatabase string `gorm:"column:sql_database;not null"`
|
||||||
|
|
@ -48,6 +48,36 @@ type Instance struct {
|
||||||
GraphDBPassword string `gorm:"column:graphdb_password;not null"`
|
GraphDBPassword string `gorm:"column:graphdb_password;not null"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const (
|
||||||
|
PHP8 = "8.0"
|
||||||
|
PHP8_IMAGE = "docker.io/library/php:8.0-apache-bullseye"
|
||||||
|
PHP8_1 = "8.1"
|
||||||
|
PHP8_1_IMAGE = "docker.io/library/php:8.1-apache-bullseye"
|
||||||
|
)
|
||||||
|
|
||||||
|
var errUnknownPHPVersion = errors.New("unknown php version")
|
||||||
|
|
||||||
|
// GetBaseImage returns the php base image to use
|
||||||
|
func GetBaseImage(php string) (string, error) {
|
||||||
|
switch php {
|
||||||
|
case "":
|
||||||
|
return PHP8_IMAGE, nil
|
||||||
|
case PHP8:
|
||||||
|
return PHP8_IMAGE, nil
|
||||||
|
case PHP8_1:
|
||||||
|
return PHP8_1_IMAGE, nil
|
||||||
|
default:
|
||||||
|
return "", errUnknownPHPVersion
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i Instance) GetDockerBaseImage() string {
|
||||||
|
if i.DockerBaseImage == "" {
|
||||||
|
return PHP8_IMAGE
|
||||||
|
}
|
||||||
|
return i.DockerBaseImage
|
||||||
|
}
|
||||||
|
|
||||||
func (i Instance) IsBlindUpdateEnabled() bool {
|
func (i Instance) IsBlindUpdateEnabled() bool {
|
||||||
return bool(i.AutoBlindUpdateEnabled)
|
return bool(i.AutoBlindUpdateEnabled)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ import (
|
||||||
"github.com/FAU-CDI/wisski-distillery/internal/wisski/ingredient/mstore"
|
"github.com/FAU-CDI/wisski-distillery/internal/wisski/ingredient/mstore"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Build builds or rebuilds the barel connected to this instance.
|
// Build builds or rebuilds the barrel connected to this instance.
|
||||||
//
|
//
|
||||||
// It also logs the current time into the metadata belonging to this instance.
|
// It also logs the current time into the metadata belonging to this instance.
|
||||||
func (barrel *Barrel) Build(ctx context.Context, progress io.Writer, start bool) error {
|
func (barrel *Barrel) Build(ctx context.Context, progress io.Writer, start bool) error {
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ func (barrel *Barrel) Stack() component.StackWithResources {
|
||||||
"DATA_PATH": filepath.Join(barrel.FilesystemBase, "data"),
|
"DATA_PATH": filepath.Join(barrel.FilesystemBase, "data"),
|
||||||
"RUNTIME_DIR": barrel.Malt.Config.Paths.RuntimeDir(),
|
"RUNTIME_DIR": barrel.Malt.Config.Paths.RuntimeDir(),
|
||||||
|
|
||||||
"BARREL_BASE_IMAGE": barrel.DockerBaseImage,
|
"BARREL_BASE_IMAGE": barrel.GetDockerBaseImage(),
|
||||||
},
|
},
|
||||||
|
|
||||||
MakeDirs: []string{"data", ".composer"},
|
MakeDirs: []string{"data", ".composer"},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue