fix(zitadel-image): refactor dockerfiles and gh action (#2027)

* early prototyp

* fix some errors

* remove docker image cache

* add comment

* add false

* typo

* test cache speed

* upload artifact

* remove tag

* seperate after build step

* debug

* debug

* debug

* debug

* debug

* test gh

* test

* test

* test

* test

* test golang

* test go

* test with release image

* fix

* use scratch to export

* test

* fix path

* ref

* typo

* debug

* test

* debug

* speed up docker

* test

* debug

* debug

* try scope

* test cache

* restore cache

* reenable operator build

* fix duplicate

* fix buildpush version

* test cache

* improve caching

* test release IF

* only run console and zitadel without dispatch

* test with reworked operator

* testing without release step

* lint yaml

* fix if

* improve wording

* enable release step & only notify sentry on main

* console from file system

* update docker file paths

* remove migration line

* add statik for operator

* console files using go 1.15

* fix console default path

* improve code QL

Co-authored-by: Livio Amstutz <livio.a@gmail.com>
This commit is contained in:
Florian Forster
2021-07-27 14:34:56 +02:00
committed by GitHub
parent e546988d2f
commit 8d96f1a895
16 changed files with 459 additions and 604 deletions

View File

@@ -7,18 +7,15 @@ import (
"strings"
"time"
"github.com/rakyll/statik/fs"
"github.com/caos/zitadel/internal/api/http/middleware"
_ "github.com/caos/zitadel/internal/ui/console/statik"
)
type Config struct {
Port string
EnvOverwriteDir string
ShortCache middleware.CacheConfig
LongCache middleware.CacheConfig
CSPDomain string
Port string
ConsoleOverwriteDir string
ShortCache middleware.CacheConfig
LongCache middleware.CacheConfig
CSPDomain string
}
type spaHandler struct {
@@ -26,9 +23,9 @@ type spaHandler struct {
}
const (
envRequestPath = "/assets/environment.json"
envDefaultDir = "/console/"
handlerPrefix = "/console"
envRequestPath = "/assets/environment.json"
consoleDefaultDir = "./console/"
handlerPrefix = "/console"
)
var (
@@ -53,14 +50,11 @@ func (i *spaHandler) Open(name string) (http.File, error) {
}
func Start(config Config) (http.Handler, string, error) {
statikFS, err := fs.NewWithNamespace("console")
if err != nil {
return nil, "", err
}
envDir := envDefaultDir
if config.EnvOverwriteDir != "" {
envDir = config.EnvOverwriteDir
consoleDir := consoleDefaultDir
if config.ConsoleOverwriteDir != "" {
consoleDir = config.ConsoleOverwriteDir
}
consoleHTTPDir := http.Dir(consoleDir)
cache := AssetsCacheInterceptorIgnoreManifest(
config.ShortCache.MaxAge.Duration,
config.ShortCache.SharedMaxAge.Duration,
@@ -69,8 +63,8 @@ func Start(config Config) (http.Handler, string, error) {
)
security := middleware.SecurityHeaders(csp(config.CSPDomain), nil)
handler := &http.ServeMux{}
handler.Handle("/", cache(security(http.FileServer(&spaHandler{statikFS}))))
handler.Handle(envRequestPath, cache(security(http.StripPrefix("/assets", http.FileServer(http.Dir(envDir))))))
handler.Handle("/", cache(security(http.FileServer(&spaHandler{consoleHTTPDir}))))
handler.Handle(envRequestPath, cache(security(http.StripPrefix("/assets", http.FileServer(consoleHTTPDir)))))
return handler, handlerPrefix, nil
}

View File

@@ -1,3 +0,0 @@
package statik
//go:generate statik -src=../../../../console/dist/console -dest=.. -ns=console