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"`
|
Forgejo forgejoConfig `json:"forgejo"`
|
||||||
GoToSocial gotosocialConfig `json:"gotosocial"`
|
GoToSocial gotosocialConfig `json:"gotosocial"`
|
||||||
Woodpecker woodpeckerConfig `json:"woodpecker"`
|
Woodpecker woodpeckerConfig `json:"woodpecker"`
|
||||||
|
Landing landingConfig `json:"landing"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type traefikConfig struct {
|
type traefikConfig struct {
|
||||||
|
@ -95,6 +96,21 @@ type woodpeckerConfig struct {
|
||||||
ForgejoClientSecret string `json:"forgejoClientSecret"`
|
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) {
|
func newConfig(path string) (config, error) {
|
||||||
var c config
|
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)
|
return fmt.Errorf("an error occurred whilst getting the packages for Woodpecker; %w", err)
|
||||||
}
|
}
|
||||||
default:
|
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
|
return nil
|
||||||
|
|
|
@ -95,6 +95,16 @@ func render(cfg config, component string) error {
|
||||||
|
|
||||||
templateDirName := filepath.Join(rootTemplatesDir, component)
|
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)
|
files, err := os.ReadDir(templateDirName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("unable to read files from %s; %w ", templateDirName, err)
|
return fmt.Errorf("unable to read files from %s; %w ", templateDirName, err)
|
||||||
|
@ -140,8 +150,12 @@ func render(cfg config, component string) error {
|
||||||
func copyAssets(service string) error {
|
func copyAssets(service string) error {
|
||||||
assetsDirName := filepath.Join(rootAssetsDir, service)
|
assetsDirName := filepath.Join(rootAssetsDir, service)
|
||||||
if _, err := os.Stat(assetsDirName); err != nil {
|
if _, err := os.Stat(assetsDirName); err != nil {
|
||||||
log.Printf("There's no assets directory for %s.\n", service)
|
if os.IsNotExist(err) {
|
||||||
return nil
|
fmt.Printf("There's no assets directory for %q.\n", service)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
buildDirName := filepath.Join(rootBuildDir, service, "assets")
|
buildDirName := filepath.Join(rootBuildDir, service, "assets")
|
||||||
|
|
|
@ -143,3 +143,23 @@ services:
|
||||||
- type: "bind"
|
- type: "bind"
|
||||||
source: "{{ .Woodpecker.DataHostDirectory }}"
|
source: "{{ .Woodpecker.DataHostDirectory }}"
|
||||||
target: "{{ .Woodpecker.DataContainerDirectory }}"
|
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 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 /
|
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