Add support for provisioning and rebuilding via interface
This commit is contained in:
parent
f5c5999f44
commit
ddb4bb3546
76 changed files with 1306 additions and 625 deletions
|
|
@ -34,8 +34,8 @@ type Instance struct {
|
|||
// The filesystem path the system can be found under
|
||||
FilesystemBase string `gorm:"column:filesystem_base;not null"`
|
||||
|
||||
// DockerBaseImage is the php base image to use
|
||||
DockerBaseImage string `gorm:"column:docker_base;not_null"`
|
||||
// information about the system being used
|
||||
System `gorm:"embed"`
|
||||
|
||||
// SQL Database credentials for the system
|
||||
SqlDatabase string `gorm:"column:sql_database;not null"`
|
||||
|
|
@ -48,38 +48,6 @@ type Instance struct {
|
|||
GraphDBPassword string `gorm:"column:graphdb_password;not null"`
|
||||
}
|
||||
|
||||
// TODO: Cleanup this stuff
|
||||
const (
|
||||
PHP_DEFAULT_IMAGE = PHP8_1_IMAGE
|
||||
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 PHP_DEFAULT_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 {
|
||||
return bool(i.AutoBlindUpdateEnabled)
|
||||
}
|
||||
|
|
|
|||
50
internal/models/instances_system.go
Normal file
50
internal/models/instances_system.go
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
package models
|
||||
|
||||
// System represents system information.
|
||||
// It is embedded into the instances struct by gorm.
|
||||
type System struct {
|
||||
// NOTE(twiesing): Any changes here should be reflected in instance_{provision,rebuild}.html and remote/api.ts.
|
||||
PHP string `gorm:"column:php;not null"`
|
||||
OpCacheDevelopment bool `gorm:"column:opcache_devel;not null"`
|
||||
}
|
||||
|
||||
const (
|
||||
imagePrefix = "docker.io/library/php:"
|
||||
imageSuffix = "-apache-bullseye"
|
||||
)
|
||||
|
||||
// OpCacheMode returns the name of the `opcache-*.ini` configuration being included in the docker image
|
||||
func (system System) OpCacheMode() string {
|
||||
if system.OpCacheDevelopment {
|
||||
return "devel"
|
||||
}
|
||||
return "prod"
|
||||
}
|
||||
|
||||
var (
|
||||
phpVersions = []string{"8.0", "8.1", "8.2"}
|
||||
phpVersionMap = (func() map[string]struct{} {
|
||||
m := make(map[string]struct{}, len(phpVersions))
|
||||
for _, v := range phpVersions {
|
||||
m[v] = struct{}{}
|
||||
}
|
||||
return m
|
||||
})()
|
||||
)
|
||||
|
||||
// DefaultPHPVersion is the default php version
|
||||
const DefaultPHPVersion = "8.1"
|
||||
|
||||
// KnownPHPVersions returns a slice of php versions.
|
||||
func KnownPHPVersions() []string {
|
||||
return append([]string(nil), phpVersions...)
|
||||
}
|
||||
|
||||
// GetDockerBaseImage returns the docker base image used by the given system.
|
||||
func (system System) GetDockerBaseImage() string {
|
||||
version := DefaultPHPVersion
|
||||
if _, ok := phpVersionMap[system.PHP]; ok {
|
||||
version = system.PHP
|
||||
}
|
||||
return imagePrefix + version + imageSuffix
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue