Add environment variable to specify custom UI path
When using SERVE_UI=1
This commit is contained in:
parent
43f89d1929
commit
b66cbf9274
|
@ -85,6 +85,7 @@ ENV PHOTOVIEW_LISTEN_IP 127.0.0.1
|
||||||
ENV PHOTOVIEW_LISTEN_PORT 80
|
ENV PHOTOVIEW_LISTEN_PORT 80
|
||||||
|
|
||||||
ENV PHOTOVIEW_SERVE_UI 1
|
ENV PHOTOVIEW_SERVE_UI 1
|
||||||
|
ENV PHOTOVIEW_UI_PATH /ui
|
||||||
|
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
|
|
||||||
|
|
|
@ -103,7 +103,7 @@ func main() {
|
||||||
shouldServeUI := utils.ShouldServeUI()
|
shouldServeUI := utils.ShouldServeUI()
|
||||||
|
|
||||||
if shouldServeUI {
|
if shouldServeUI {
|
||||||
spa := routes.NewSpaHandler("/ui", "index.html")
|
spa := routes.NewSpaHandler(utils.UIPath(), "index.html")
|
||||||
rootRouter.PathPrefix("/").Handler(spa)
|
rootRouter.PathPrefix("/").Handler(spa)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ type EnvironmentVariable string
|
||||||
const (
|
const (
|
||||||
EnvDevelopmentMode EnvironmentVariable = "PHOTOVIEW_DEVELOPMENT_MODE"
|
EnvDevelopmentMode EnvironmentVariable = "PHOTOVIEW_DEVELOPMENT_MODE"
|
||||||
EnvServeUI EnvironmentVariable = "PHOTOVIEW_SERVE_UI"
|
EnvServeUI EnvironmentVariable = "PHOTOVIEW_SERVE_UI"
|
||||||
|
EnvUIPath EnvironmentVariable = "PHOTOVIEW_UI_PATH"
|
||||||
EnvMediaCachePath EnvironmentVariable = "PHOTOVIEW_MEDIA_CACHE"
|
EnvMediaCachePath EnvironmentVariable = "PHOTOVIEW_MEDIA_CACHE"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -49,3 +50,12 @@ func ShouldServeUI() bool {
|
||||||
func DevelopmentMode() bool {
|
func DevelopmentMode() bool {
|
||||||
return EnvDevelopmentMode.GetValue() == "1"
|
return EnvDevelopmentMode.GetValue() == "1"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// UIPath returns the value from where the static UI files are located if SERVE_UI=1
|
||||||
|
func UIPath() string {
|
||||||
|
if path := EnvUIPath.GetValue(); path != "" {
|
||||||
|
return path
|
||||||
|
}
|
||||||
|
|
||||||
|
return "./ui"
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue