feat: add the landing page to Flow Platform
Welcome :)
This commit is contained in:
parent
5a757d2ed5
commit
4eba300480
8 changed files with 70 additions and 23 deletions
2
config
2
config
|
@ -1 +1 @@
|
|||
Subproject commit d17177a0636e3e1b89cb2e3891aed2d6e5a1ed12
|
||||
Subproject commit 46b27c4c2bda5d2109a4dbe9b84bb6efe881da7d
|
|
@ -17,6 +17,7 @@ type config struct {
|
|||
Forgejo forgejoConfig `json:"forgejo"`
|
||||
GoToSocial gotosocialConfig `json:"gotosocial"`
|
||||
Woodpecker woodpeckerConfig `json:"woodpecker"`
|
||||
Landing landingConfig `json:"landing"`
|
||||
}
|
||||
|
||||
type traefikConfig struct {
|
||||
|
@ -95,6 +96,21 @@ type woodpeckerConfig struct {
|
|||
ForgejoClientSecret string `json:"forgejoClientSecret"`
|
||||
}
|
||||
|
||||
type landingConfig struct {
|
||||
Version string `json:"version"`
|
||||
ContainerIpv4Address string `json:"containerIpv4Address"`
|
||||
Services []landingConfigLinks `json:"services"`
|
||||
Profiles []landingConfigLinks `json:"profiles"`
|
||||
Port int32 `json:"port"`
|
||||
ImageDigest string `json:"imageDigest"`
|
||||
}
|
||||
|
||||
type landingConfigLinks struct {
|
||||
Title string
|
||||
URL string
|
||||
Rel string
|
||||
}
|
||||
|
||||
func newConfig(path string) (config, error) {
|
||||
var c config
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ func Download(name string) error {
|
|||
return fmt.Errorf("an error occurred whilst getting the packages for Woodpecker; %w", err)
|
||||
}
|
||||
default:
|
||||
fmt.Printf("'%s' has no files to download.\n", name)
|
||||
fmt.Printf("There's no files to download for %q.\n", name)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
|
@ -95,6 +95,16 @@ func render(cfg config, component string) error {
|
|||
|
||||
templateDirName := filepath.Join(rootTemplatesDir, component)
|
||||
|
||||
_, err := os.Stat(templateDirName)
|
||||
if err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
fmt.Printf("There's no template directory for %q.\n", component)
|
||||
return nil
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
files, err := os.ReadDir(templateDirName)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to read files from %s; %w ", templateDirName, err)
|
||||
|
@ -140,10 +150,14 @@ func render(cfg config, component string) error {
|
|||
func copyAssets(service string) error {
|
||||
assetsDirName := filepath.Join(rootAssetsDir, service)
|
||||
if _, err := os.Stat(assetsDirName); err != nil {
|
||||
log.Printf("There's no assets directory for %s.\n", service)
|
||||
if os.IsNotExist(err) {
|
||||
fmt.Printf("There's no assets directory for %q.\n", service)
|
||||
return nil
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
buildDirName := filepath.Join(rootBuildDir, service, "assets")
|
||||
|
||||
walkDirFunc := func(path string, d fs.DirEntry, err error) error {
|
||||
|
|
|
@ -143,3 +143,23 @@ services:
|
|||
- type: "bind"
|
||||
source: "{{ .Woodpecker.DataHostDirectory }}"
|
||||
target: "{{ .Woodpecker.DataContainerDirectory }}"
|
||||
# -- Landing Page --
|
||||
landing:
|
||||
container_name: "landing-page"
|
||||
command:
|
||||
- --address={{ .Landing.ContainerIpv4Address }}:{{ .Landing.Port }}
|
||||
{{ range .Landing.Services -}}
|
||||
- --service=title={{ .Title }},url={{ .URL }}{{ if gt (len .Rel) 0 }},rel={{ .Rel }}{{ end }}
|
||||
{{ end -}}
|
||||
{{ range .Landing.Profiles -}}
|
||||
- --profile=title={{ .Title }},url={{ .URL }}{{ if gt (len .Rel) 0 }},rel={{ .Rel }}{{ end }}
|
||||
{{ end -}}
|
||||
image: "codeflow.dananglin.me.uk/flow/landing:v{{ .Landing.Version }}@{{ .Landing.ImageDigest }}"
|
||||
expose:
|
||||
- "{{ .Landing.Port }}"
|
||||
networks:
|
||||
flow:
|
||||
ipv4_address: "{{ .Landing.ContainerIpv4Address }}"
|
||||
restart: "always"
|
||||
volumes:
|
||||
{{- template "defaultVolumes" }}
|
||||
|
|
|
@ -2,7 +2,7 @@ FROM traefik:{{ .Traefik.Version }}
|
|||
|
||||
ADD traefik.yaml /flow/traefik/
|
||||
|
||||
ADD dynamic_root_domain_redirect.yaml /tmp/dynamic_root_domain_redirect.yaml
|
||||
ADD dynamic_landing_page.yaml /tmp/dynamic_landing_page.yaml
|
||||
|
||||
ADD entrypoint.sh /
|
||||
|
||||
|
|
15
templates/traefik/dynamic_landing_page.yaml.gotmpl
Normal file
15
templates/traefik/dynamic_landing_page.yaml.gotmpl
Normal file
|
@ -0,0 +1,15 @@
|
|||
---
|
||||
http:
|
||||
routers:
|
||||
landing-page:
|
||||
entryPoints:
|
||||
- "https"
|
||||
rule: "Host(`{{ .RootDomain }}`)"
|
||||
service: landing-page
|
||||
tls:
|
||||
certResolver: resolver
|
||||
services:
|
||||
landing-page:
|
||||
loadBalancer:
|
||||
servers:
|
||||
- url: "http://{{ .Landing.ContainerIpv4Address }}:{{ .Landing.Port }}"
|
|
@ -1,18 +0,0 @@
|
|||
---
|
||||
http:
|
||||
routers:
|
||||
root-domain:
|
||||
entryPoints:
|
||||
- "https"
|
||||
rule: "Host(`{{ .RootDomain }}`)"
|
||||
middlewares:
|
||||
- "redirect-root-to-freeflow"
|
||||
service: noop@internal
|
||||
tls:
|
||||
certResolver: resolver
|
||||
middlewares:
|
||||
redirect-root-to-freeflow:
|
||||
redirectRegex:
|
||||
regex: "^(.*)"
|
||||
replacement: "https://{{ .GoToSocial.Subdomain }}.{{ .RootDomain }}/@{{ .GoToSocial.LandingPageUser }}"
|
||||
permanent: true
|
Loading…
Reference in a new issue