1
Fork 0

Add environment variable to specify custom UI path

When using SERVE_UI=1
This commit is contained in:
viktorstrate 2021-02-26 15:10:28 +01:00
parent 43f89d1929
commit b66cbf9274
No known key found for this signature in database
GPG Key ID: 3F855605109C1E8A
3 changed files with 12 additions and 1 deletions

View File

@ -85,6 +85,7 @@ ENV PHOTOVIEW_LISTEN_IP 127.0.0.1
ENV PHOTOVIEW_LISTEN_PORT 80
ENV PHOTOVIEW_SERVE_UI 1
ENV PHOTOVIEW_UI_PATH /ui
EXPOSE 80

View File

@ -103,7 +103,7 @@ func main() {
shouldServeUI := utils.ShouldServeUI()
if shouldServeUI {
spa := routes.NewSpaHandler("/ui", "index.html")
spa := routes.NewSpaHandler(utils.UIPath(), "index.html")
rootRouter.PathPrefix("/").Handler(spa)
}

View File

@ -9,6 +9,7 @@ type EnvironmentVariable string
const (
EnvDevelopmentMode EnvironmentVariable = "PHOTOVIEW_DEVELOPMENT_MODE"
EnvServeUI EnvironmentVariable = "PHOTOVIEW_SERVE_UI"
EnvUIPath EnvironmentVariable = "PHOTOVIEW_UI_PATH"
EnvMediaCachePath EnvironmentVariable = "PHOTOVIEW_MEDIA_CACHE"
)
@ -49,3 +50,12 @@ func ShouldServeUI() bool {
func DevelopmentMode() bool {
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"
}