Make default StaticRootPath compile time settable (#12371)
Make it possible to compile the default location of StaticRootPath independent from AppWorkPath Co-authored-by: Andrew Thornton <art27@cantab.net>
This commit is contained in:
parent
0171dda728
commit
78d17b4b43
|
@ -143,7 +143,7 @@ Gitea will search for a number of things from the `CustomPath`. By default this
|
||||||
the `custom/` directory in the current working directory when running Gitea. It will also
|
the `custom/` directory in the current working directory when running Gitea. It will also
|
||||||
look for its configuration file `CustomConf` in `$CustomPath/conf/app.ini`, and will use the
|
look for its configuration file `CustomConf` in `$CustomPath/conf/app.ini`, and will use the
|
||||||
current working directory as the relative base path `AppWorkPath` for a number configurable
|
current working directory as the relative base path `AppWorkPath` for a number configurable
|
||||||
values.
|
values. Finally the static files will be served from `StaticRootPath` which defaults to the `AppWorkPath`.
|
||||||
|
|
||||||
These values, although useful when developing, may conflict with downstream users preferences.
|
These values, although useful when developing, may conflict with downstream users preferences.
|
||||||
|
|
||||||
|
@ -154,6 +154,7 @@ using the `LDFLAGS` environment variable for `make`. The appropriate settings ar
|
||||||
* To set the `CustomPath` use `LDFLAGS="-X \"code.gitea.io/gitea/modules/setting.CustomPath=custom-path\""`
|
* To set the `CustomPath` use `LDFLAGS="-X \"code.gitea.io/gitea/modules/setting.CustomPath=custom-path\""`
|
||||||
* For `CustomConf` you should use `-X \"code.gitea.io/gitea/modules/setting.CustomConf=conf.ini\"`
|
* For `CustomConf` you should use `-X \"code.gitea.io/gitea/modules/setting.CustomConf=conf.ini\"`
|
||||||
* For `AppWorkPath` you should use `-X \"code.gitea.io/gitea/modules/setting.AppWorkPath=working-path\"`
|
* For `AppWorkPath` you should use `-X \"code.gitea.io/gitea/modules/setting.AppWorkPath=working-path\"`
|
||||||
|
* For `StaticRootPath` you should use `-X \"code.gitea.io/gitea/modules/setting.StaticRootPath=static-root-path\"`
|
||||||
|
|
||||||
Add as many of the strings with their preceding `-X` to the `LDFLAGS` variable and run `make build`
|
Add as many of the strings with their preceding `-X` to the `LDFLAGS` variable and run `make build`
|
||||||
with the appropriate `TAGS` as above.
|
with the appropriate `TAGS` as above.
|
||||||
|
|
|
@ -652,7 +652,10 @@ func NewContext() {
|
||||||
PortToRedirect = sec.Key("PORT_TO_REDIRECT").MustString("80")
|
PortToRedirect = sec.Key("PORT_TO_REDIRECT").MustString("80")
|
||||||
OfflineMode = sec.Key("OFFLINE_MODE").MustBool()
|
OfflineMode = sec.Key("OFFLINE_MODE").MustBool()
|
||||||
DisableRouterLog = sec.Key("DISABLE_ROUTER_LOG").MustBool()
|
DisableRouterLog = sec.Key("DISABLE_ROUTER_LOG").MustBool()
|
||||||
StaticRootPath = sec.Key("STATIC_ROOT_PATH").MustString(AppWorkPath)
|
if len(StaticRootPath) == 0 {
|
||||||
|
StaticRootPath = AppWorkPath
|
||||||
|
}
|
||||||
|
StaticRootPath = sec.Key("STATIC_ROOT_PATH").MustString(StaticRootPath)
|
||||||
StaticCacheTime = sec.Key("STATIC_CACHE_TIME").MustDuration(6 * time.Hour)
|
StaticCacheTime = sec.Key("STATIC_CACHE_TIME").MustDuration(6 * time.Hour)
|
||||||
AppDataPath = sec.Key("APP_DATA_PATH").MustString(path.Join(AppWorkPath, "data"))
|
AppDataPath = sec.Key("APP_DATA_PATH").MustString(path.Join(AppWorkPath, "data"))
|
||||||
EnableGzip = sec.Key("ENABLE_GZIP").MustBool()
|
EnableGzip = sec.Key("ENABLE_GZIP").MustBool()
|
||||||
|
|
Loading…
Reference in New Issue