component/web: Add http and https variants
This commit is contained in:
parent
735d032865
commit
55bee7422d
10 changed files with 88 additions and 13 deletions
|
|
@ -6,7 +6,9 @@ import (
|
|||
"github.com/FAU-CDI/wisski-distillery/internal/component"
|
||||
)
|
||||
|
||||
// Web implements the web component
|
||||
// Web implements the ingress gateway for the distillery.
|
||||
//
|
||||
// It consists of an nginx docker container and an optional letsencrypt container.
|
||||
type Web struct {
|
||||
component.ComponentBase
|
||||
}
|
||||
|
|
@ -15,24 +17,42 @@ func (Web) Name() string {
|
|||
return "web"
|
||||
}
|
||||
|
||||
//go:embed all:stack
|
||||
//go:embed web.env
|
||||
var resources embed.FS
|
||||
|
||||
func (web Web) Stack() component.Installable {
|
||||
HTTPS_METHOD := "nohttp"
|
||||
if web.Config.HTTPSEnabled() {
|
||||
HTTPS_METHOD = "redirect"
|
||||
return web.stackHTTPS()
|
||||
} else {
|
||||
return web.stackHTTP()
|
||||
}
|
||||
}
|
||||
|
||||
//go:embed all:web-https
|
||||
//go:embed web-https.env
|
||||
var httpsResources embed.FS
|
||||
|
||||
func (web Web) stackHTTPS() component.Installable {
|
||||
return web.MakeStack(component.Installable{
|
||||
Resources: resources,
|
||||
ContextPath: "stack",
|
||||
EnvPath: "web.env",
|
||||
Resources: httpsResources,
|
||||
ContextPath: "web-https",
|
||||
EnvPath: "web-https.env",
|
||||
|
||||
EnvContext: map[string]string{
|
||||
"DEFAULT_HOST": web.Config.DefaultDomain,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
//go:embed all:web-http
|
||||
//go:embed web-http.env
|
||||
var httpResources embed.FS
|
||||
|
||||
func (web Web) stackHTTP() component.Installable {
|
||||
return web.MakeStack(component.Installable{
|
||||
Resources: httpResources,
|
||||
ContextPath: "web-http",
|
||||
EnvPath: "web-http.env",
|
||||
|
||||
EnvContext: map[string]string{
|
||||
"DEFAULT_HOST": web.Config.DefaultDomain,
|
||||
"HTTPS_METHOD": HTTPS_METHOD,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue