Skip to content

Commit 69e4b69

Browse files
6543zeripathtechknowlogick
authored
Make default StaticRootPath compile time settable (#12371) (#12652)
Make it possible to compile the default location of StaticRootPath independent from AppWorkPath Co-authored-by: Andrew Thornton <[email protected]> Co-authored-by: Andrew Thornton <[email protected]> Co-authored-by: techknowlogick <[email protected]>
1 parent 0e9dcc9 commit 69e4b69

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

docs/content/doc/installation/from-source.en-us.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ Gitea will search for a number of things from the `CustomPath`. By default this
141141
the `custom/` directory in the current working directory when running Gitea. It will also
142142
look for its configuration file `CustomConf` in `$CustomPath/conf/app.ini`, and will use the
143143
current working directory as the relative base path `AppWorkPath` for a number configurable
144-
values.
144+
values. Finally the static files will be served from `StaticRootPath` which defaults to the `AppWorkPath`.
145145

146146
These values, although useful when developing, may conflict with downstream users preferences.
147147

@@ -152,6 +152,7 @@ using the `LDFLAGS` environment variable for `make`. The appropriate settings ar
152152
* To set the `CustomPath` use `LDFLAGS="-X \"code.gitea.io/gitea/modules/setting.CustomPath=custom-path\""`
153153
* For `CustomConf` you should use `-X \"code.gitea.io/gitea/modules/setting.CustomConf=conf.ini\"`
154154
* For `AppWorkPath` you should use `-X \"code.gitea.io/gitea/modules/setting.AppWorkPath=working-path\"`
155+
* For `StaticRootPath` you should use `-X \"code.gitea.io/gitea/modules/setting.StaticRootPath=static-root-path\"`
155156

156157
Add as many of the strings with their preceding `-X` to the `LDFLAGS` variable and run `make build`
157158
with the appropriate `TAGS` as above.

modules/setting/setting.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,10 @@ func NewContext() {
666666
PortToRedirect = sec.Key("PORT_TO_REDIRECT").MustString("80")
667667
OfflineMode = sec.Key("OFFLINE_MODE").MustBool()
668668
DisableRouterLog = sec.Key("DISABLE_ROUTER_LOG").MustBool()
669-
StaticRootPath = sec.Key("STATIC_ROOT_PATH").MustString(AppWorkPath)
669+
if len(StaticRootPath) == 0 {
670+
StaticRootPath = AppWorkPath
671+
}
672+
StaticRootPath = sec.Key("STATIC_ROOT_PATH").MustString(StaticRootPath)
670673
StaticCacheTime = sec.Key("STATIC_CACHE_TIME").MustDuration(6 * time.Hour)
671674
AppDataPath = sec.Key("APP_DATA_PATH").MustString(path.Join(AppWorkPath, "data"))
672675
EnableGzip = sec.Key("ENABLE_GZIP").MustBool()

0 commit comments

Comments
 (0)