mirror of
https://github.com/go-gitea/gitea.git
synced 2026-03-13 02:57:44 -05:00
Web deployment with static content #9849
Closed
opened 2025-11-02 08:51:14 -06:00 by GiteaMirror
·
16 comments
No Branch/Tag Specified
main
release/v1.25
release/v1.24
release/v1.23
release/v1.22
release/v1.21
release/v1.20
release/v1.19
release/v1.18
release/v1.17
release/v1.16
release/v1.15
release/v1.14
release/v1.13
release/v1.12
release/v1.11
release/v1.10
release/v1.9
release/v1.8
v1.25.3
v1.25.2
v1.25.1
v1.25.0
v1.24.7
v1.25.0-rc0
v1.26.0-dev
v1.24.6
v1.24.5
v1.24.4
v1.24.3
v1.24.2
v1.24.1
v1.24.0
v1.23.8
v1.24.0-rc0
v1.25.0-dev
v1.23.7
v1.23.6
v1.23.5
v1.23.4
v1.23.3
v1.23.2
v1.23.1
v1.23.0
v1.23.0-rc0
v1.24.0-dev
v1.22.6
v1.22.5
v1.22.4
v1.22.3
v1.22.2
v1.22.1
v1.22.0
v1.23.0-dev
v1.22.0-rc1
v1.21.11
v1.22.0-rc0
v1.21.10
v1.21.9
v1.21.8
v1.21.7
v1.21.6
v1.21.5
v1.21.4
v1.21.3
v1.21.2
v1.20.6
v1.21.1
v1.21.0
v1.21.0-rc2
v1.21.0-rc1
v1.20.5
v1.22.0-dev
v1.21.0-rc0
v1.20.4
v1.20.3
v1.20.2
v1.20.1
v1.20.0
v1.19.4
v1.21.0-dev
v1.20.0-rc2
v1.20.0-rc1
v1.20.0-rc0
v1.19.3
v1.19.2
v1.19.1
v1.19.0
v1.19.0-rc1
v1.20.0-dev
v1.19.0-rc0
v1.18.5
v1.18.4
v1.18.3
v1.18.2
v1.18.1
v1.18.0
v1.17.4
v1.18.0-rc1
v1.19.0-dev
v1.18.0-rc0
v1.17.3
v1.17.2
v1.17.1
v1.17.0
v1.17.0-rc2
v1.16.9
v1.17.0-rc1
v1.18.0-dev
v1.16.8
v1.16.7
v1.16.6
v1.16.5
v1.16.4
v1.16.3
v1.16.2
v1.16.1
v1.16.0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3.2
v1.3.1
v1.3.0
v1.3.0-rc2
v1.3.0-rc1
v1.2.3
v1.2.2
v1.2.1
v1.2.0
v1.2.0-rc3
v1.2.0-rc2
v1.1.4
v1.2.0-rc1
v1.1.3
v1.1.2
v1.1.1
v1.1.0
v1.0.2
v1.0.1
v1.0.0
v0.9.99
Labels
Clear labels
$20
$250
$50
$500
backport/done
💎 Bounty
docs-update-needed
good first issue
hacktoberfest
issue/bounty
issue/confirmed
issue/critical
issue/duplicate
issue/needs-feedback
issue/not-a-bug
issue/regression
issue/stale
issue/workaround
lgtm/need 2
modifies/api
modifies/translation
outdated/backport/v1.18
outdated/theme/markdown
outdated/theme/timetracker
performance/bigrepo
performance/cpu
performance/memory
performance/speed
pr/breaking
proposal/accepted
proposal/rejected
pr/wip
pull-request
reviewed/wontfix
💰 Rewarded
skip-changelog
status/blocked
topic/accessibility
topic/api
topic/authentication
topic/build
topic/code-linting
topic/commit-signing
topic/content-rendering
topic/deployment
topic/distribution
topic/federation
topic/gitea-actions
topic/issues
topic/lfs
topic/mobile
topic/moderation
topic/packages
topic/pr
topic/projects
topic/repo
topic/repo-migration
topic/security
topic/theme
topic/ui
topic/ui-interaction
topic/ux
topic/webhooks
topic/wiki
type/bug
type/deprecation
type/docs
type/enhancement
type/feature
type/miscellaneous
type/proposal
type/question
type/refactoring
type/summary
type/testing
type/upstream
Mirrored from GitHub Pull Request
No Label
type/question
Milestone
No items
No Milestone
Projects
Clear projects
No project
No Assignees
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/gitea#9849
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @KB3HNS on GitHub (Nov 17, 2022).
Description
Hello. I need some clarification.
I've built my own version of gitea for Debian 11 (bullseye) including PAM and excluding the built-ins. I'm currently running a local instance of APACHE 2 with appropriate mod_proxy and mod_proxy_http. I am able to confirm that apache is correctly passing requests to gitea. However, all requests are resulting in a 500 internal server error. Even when manually running gitea with the --verbose option there is very little information to go on as shown below (redacting some potentially sensitive information):
I have copied the contents of ${BUILD_DIR}/"public" to /var/www-ssl/git-static, based on this documentation and the resulting gitea executable to /usr/local/bin. I have also set up an appropriate account to run under and systemd startup script based on these instructions.
My current app.ini:
If I run the application in the build directory it executes fine. However, the build directory resides on a dedicated build server and the build environment is purposefully not available on the production server (both the build system and the production server are running identically patched versions of Debian 11 - only that the production server does not have the ability to compile software for security reasons).
I desire to avoid building in the static content as this server has a heavy load and is somewhat stretched for resources as it is. PAM authentication is required as I have already implemented a system-wide user database and do not desire to maintain a separate authentication system.
Gitea Version
1.17.3 built with GNU Make 4.3, go1.19.1 : pam
Can you reproduce the bug on the Gitea demo site?
No
Log Gist
Logs inline
Screenshots
-N/A- see logs
Git Version
2.30.2
Operating System
Linux xxxxxx 5.10.0-19-amd64 #1 SMP Debian 5.10.149-2 (2022-10-21) x86_64 GNU/Linux
How are you running Gitea?
See description.
Database
MySQL
@KB3HNS commented on GitHub (Nov 17, 2022):
Further clarification, command line to execute gitea:
/usr/local/bin/gitea web -c /etc/gitea/app.ini@KB3HNS commented on GitHub (Nov 18, 2022):
After doing some searching, I believe that this is related to #18110
@clarfonthey commented on GitHub (Nov 18, 2022):
Are you sure that the JS you're using matches the version of gitea correctly? Since my issue was having stale extracts and it not matching what the frontend was actually looking for.
@KB3HNS commented on GitHub (Nov 18, 2022):
In my case, yes as I directly copied the public folder into my www-ssl directory (renamed, of course).
@wxiaoguang commented on GitHub (Nov 18, 2022):
You are doing something wrong, unrelated to 18110
Please follow the guideline strictly, for example: the document https://docs.gitea.io/en-us/install-from-source/ has told you
TAGS="bindata" make buildYou may need
TAGS="bindata pam" make buildto build with PAM@KB3HNS commented on GitHub (Nov 18, 2022):
As per my description: adding
bindatais not desired. I would much prefer to have the static content hosted separately so it will be cached by my CDN and therefore won't require server resources to provide. According to documentation,bindatais an optional flag.@wxiaoguang commented on GitHub (Nov 18, 2022):
I can not understand why "bindata" is not desired (
you didn't mention in your description eitherHmm, I didn't understand that before). It's only optional for experienced users who clearly know what they want and fully understand how Gitea assets work.If you want to play with
bindataby yourself, please also put the template files in the correct places, following to the document.For a quick and stable solution: just use
bindata. You can still serve these static resources via CDN (just proxy the static assets to Gitea instance, it's very fast and will be cached soon)@wxiaoguang commented on GitHub (Nov 18, 2022):
Another choice is that you still build Gitea with
bindata, then copy the JS/CSS resources to your filesystem as your plan (I won't recommend so, you will run into other problems if you upgrade Gitea but forgot the update the resources).bindatais not only for JS/CSS, it also contains templates, which is not related to your CDN, but used by Gitea internally.@KB3HNS commented on GitHub (Nov 18, 2022):
Primary issue is that the current server is a VPS with limited memory and CPU resources. It is shared between 3 total developers and has very low code velocity. I would prefer for static assets to be served directly by apache and not proxied through an additional application - this will allow cloudflare to properly cache them while continuing to forward dynamic content through to the application. I am running many other services on the same web server - all using FCGI for HTTP/2 and as a result apache has a 512MB/instance overhead so I am limited to the total number of apache instances that I can support (3). An instance that is being used to forward a request for what amounts to a static file is an instance that could have been put to better use generating dynamic content.
To get around the 500 error, I did to a build with bindata to prove out the issue - again not desired. There was no setting of
STATIC_URL_PREFIXthat would allow the control panel (first page prior to database provisioning) to properly load without throwing the pop-up exception referred to in the referenced issue, hence why I do believe this to be a legitimate bug.@wxiaoguang commented on GitHub (Nov 18, 2022):
I see, if you want to save memory heavily, you should look into the
bindatadetails to separate the assets carefully and put bindata files in your deployment manually. I doubt that it won't save too much memory ....ps: I proposed a PR to fix the document: #21853
@wxiaoguang commented on GitHub (Nov 18, 2022):
At the moment, there are 3 kinds of bindata assets:
When Gitea is running, only 1 can be put in other servers (to be served by other HTTP sites)
2 & 3 are necessary for Gitea, either bundle them into Gitea binary, or put them in Gitea's working directory (IIRC some documents about customizing may have mentioned that)
@KB3HNS commented on GitHub (Nov 18, 2022):
Ok. Thanks for the PR and clarification there.
At this point not nearly that important but; it would be nice to know what content can be put at
STATIC_URL_PREFIX. It seems that whatever I put there (even withbindataadded as a tag) the system throws the web error. At this point, system is working with PAM authentication and the option commented out in app.ini.Further note - this is for reference only, perhaps someone in the future will find this helpful:
This works on "Debian 11 AKA BullsEye" but I imagine that it will work for any other debian based system (Ubuntu, Mint, etc). The correct "PAM Service Name" for using the normal Linux Password authentication mechanism is
common-session-noninteractive.@wxiaoguang commented on GitHub (Nov 18, 2022):
I think they are the JS/CSS files (under the
http://gitea/assets, which is called aspublicin source code, i.e the kind 1)Do you mean it could be documented, or be changed in source code?
ps: I do not use STATIC_URL_PREFIX nor PAM 😂, if you could help to improve the document and code, I can help to review and approve. Or you can tell me how to improve the document and code, then I will propose PRs.
@KB3HNS commented on GitHub (Nov 18, 2022):
So.. About that
#3above... Is it possible that, theSTATIC_URL_PREFIXis being incorrectly applied to items in this bucket? That actually would align with the behavior that I was seeing after addingbindata.1It's getting a bit late here in Central US and I have to get up early for work tomorrow. I'll fork and put together a PR to try and improve some of that documentation around PAM - give me a few days. Can't help on the
STATIC_URL_PREFIXyet because I can't reproduce a working system.Along with that PR, I may also try to see if I can find some time to investigate the prefix issue myself to see if I can better see what's going on. Haven't screwed with GO much at all, I'm a C/C++/Python/Assembly guy so will be a bit of a learning curve there. But your comment plus my addiction to regular expression hunting may be just enough to be able to triage this a bit. ↩︎
@wxiaoguang commented on GitHub (Nov 18, 2022):
STATIC_URL_PREFIXis only applied to the generated JS/CSS URLs in HTML pages, and only for the/assets/directory.Not sure whehter I understand your question correctly, the logic is like this:
STATIC_URL_PREFIX/assets/index.jsSTATIC_URL_PREFIX/assets/index.jsSTATIC_URL_PREFIX/assets/index.jsisserver-gitea/assets/index.js, so Gitea serves it@KB3HNS commented on GitHub (Nov 19, 2022):
Very interesting. So, now that I have the server, the behavior is working as expected. It was an issue when I did not have the server configured - a bit of a chicken-and-egg thing in that I couldn't set up the server (pop-up dialog A-la linked issue). Now that the server has been configured and database initialized, the site works as expected. And it was specifically having issues with
index.js. Can't really explain that one, but I will also update / clarify that section of the documentation as well in my PR.