e079ce4cf4
This PR contains the following updates: | Package | Update | Change | |---|---|---| | [golangci/golangci-lint](https://github.com/golangci/golangci-lint) | minor | `v1.61.0` -> `v1.62.0` | --- ### Release Notes <details> <summary>golangci/golangci-lint (golangci/golangci-lint)</summary> ### [`v1.62.0`](https://github.com/golangci/golangci-lint/blob/HEAD/CHANGELOG.md#v1620) [Compare Source](https://github.com/golangci/golangci-lint/compare/v1.61.0...v1.62.0) 1. New linters - Add `recvcheck` linter https://github.com/raeperd/recvcheck - Add `iface` linter https://github.com/uudashr/iface 2. Updated linters - ⚠️ `execinquery`: deprecation step 2 - ⚠️ `gomnd`: deprecation step 2 (replaced by `mnd`) - `bidichk`: from 0.2.7 to 0.3.2 (important performance improvement) - `canonicalheader`: from 1.1.1 to 1.1.2 - `cyclop`: from 1.2.1 to 1.2.3 - `dupword`: from 0.1.1 to 0.1.3 - `errcheck`: from 1.7.0 to 1.8.0 - `errchkjson`: from 0.3.6 to 0.4.0 - `errname`: from 0.1.13 to 1.0.0 - `ginkgolinter`: from 0.17.0 to 0.18.0 (new option: `force-succeed`) - `go-check-sumtype`: from 0.1.4 to 0.2.0 (new option: `default-signifies-exhaustive`) - `go-critic`: from 0.11.4 to 0.11.5 - `go-printf-func-name`: from [`7558a9e`](https://github.com/golangci/golangci-lint/commit/7558a9eaa5af) to v0.1.0 - `godot`: from 1.4.17 to 1.4.18 - `gosec`: from 2.21.2 to 2.21.4 - `intrange`: from 0.2.0 to 0.2.1 - `loggercheck`: from 0.9.4 to 0.10.1 (`log/slog` support) - `musttag`: from 0.12.2 to 0.13.0 - `nakedret`: from 2.0.4 to 2.0.5 - `nilnil`: from 0.1.9 to 1.0.0 (new option: `detect-opposite`) - `noctx`: from 0.0.2 to 0.1.0 - `protogetter`: from 0.3.6 to 0.3.8 - `revive`: from 1.3.9 to 1.5.0 (new rules: `filename-format`, and `file-length-limit`) - `tenv`: from 1.10.0 to 1.12.1 (handle dot import) - `testifylint`: from 1.4.3 to 1.5.0 (new checkers: `contains`, `encoded-compare`, `regexp`) 3. Misc. - Type sizing when cross-compiling (32-bit). - code-climate: add check_name field - Improve Go version detection - Fix Go version propagation 4. Documentation - Adds a section about `exclude-dirs-use-default` - Improve 'install from sources' section - Improve FAQ about Go versions - Improve linter/rule/check docs - Improve new linter section - Improve `forbidigo` pattern examples for built-in functions </details> --- ### Configuration 📅 **Schedule**: Branch creation - "every weekend" (UTC), Automerge - "before 4am" (UTC). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy40NDAuNyIsInVwZGF0ZWRJblZlciI6IjM3LjQ0MC43IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJkZXBlbmRlbmNpZXMiXX0=--> Co-authored-by: woodpecker-bot <woodpecker-bot@obermui.de> Reviewed-on: https://codeberg.org/Codeberg/pages-server/pulls/402 Co-authored-by: Dependency bot <renovate-bot@noreply.codeberg.org> Co-committed-by: Dependency bot <renovate-bot@noreply.codeberg.org> |
||
---|---|---|
.gitea/ISSUE_TEMPLATE | ||
.vscode | ||
.woodpecker | ||
cli | ||
config | ||
examples/haproxy-sni | ||
html | ||
integration | ||
server | ||
.ecrc | ||
.editorconfig | ||
.env-dev | ||
.gitignore | ||
.golangci.yml | ||
.prettierrc.json | ||
.yamllint.yaml | ||
Dockerfile | ||
FEATURES.md | ||
Justfile | ||
LICENSE | ||
README.md | ||
example_config.toml | ||
flake.lock | ||
flake.nix | ||
go.mod | ||
go.sum | ||
main.go | ||
renovate.json |
README.md
Codeberg Pages
Gitea lacks the ability to host static pages from Git. The Codeberg Pages Server addresses this lack by implementing a standalone service that connects to Gitea via API. It is suitable to be deployed by other Gitea instances, too, to offer static pages hosting to their users.
End user documentation can mainly be found at the Wiki and the Codeberg Documentation.
Quickstart
This is the new Codeberg Pages server, a solution for serving static pages from Gitea repositories. Mapping custom domains is not static anymore, but can be done with DNS:
-
add a
.domains
text file to your repository, containing the allowed domains, separated by new lines. The first line will be the canonical domain/URL; all other occurrences will be redirected to it. -
add a CNAME entry to your domain, pointing to
[[{branch}.]{repo}.]{owner}.codeberg.page
(repo defaults to "pages", "branch" defaults to the default branch if "repo" is "pages", or to "pages" if "repo" is something else. If the branch name contains slash characters, you need to replace "/" in the branch name to "~"):www.example.org. IN CNAME main.pages.example.codeberg.page.
-
if a CNAME is set for "www.example.org", you can redirect there from the naked domain by adding an ALIAS record for "example.org" (if your provider allows ALIAS or similar records, otherwise use A/AAAA), together with a TXT record that points to your repo (just like the CNAME record):
example.org IN ALIAS codeberg.page.
example.org IN TXT main.pages.example.codeberg.page.
Certificates are generated, updated and cleaned up automatically via Let's Encrypt through a TLS challenge.
Chat for admins & devs
matrix: #gitea-pages-server:matrix.org
Deployment
Warning: Some Caveats Apply
Currently, the deployment requires you to have some knowledge of system administration as well as understanding and building code, so you can eventually edit non-configurable and codeberg-specific settings. In the future, we'll try to reduce these and make hosting Codeberg Pages as easy as setting up Gitea. If you consider using Pages in practice, please consider contacting us first, we'll then try to share some basic steps and document the current usage for admins (might be changing in the current state).
Deploying the software itself is very easy. You can grab a current release binary or build yourself, configure the environment as described below, and you are done.
The hard part is about adding custom domain support if you intend to use it. SSL certificates (request + renewal) is automatically handled by the Pages Server, but if you want to run it on a shared IP address (and not a standalone), you'll need to configure your reverse proxy not to terminate the TLS connections, but forward the requests on the IP level to the Pages Server.
You can check out a proof of concept in the examples/haproxy-sni
folder,
and especially have a look at this section of the haproxy.cfg.
If you want to test a change, you can open a PR and ask for the label build_pr_image
to be added.
This will trigger a build of the PR which will build a docker image to be used for testing.
Environment Variables
ACME_ACCEPT_TERMS
(default: use self-signed certificate): Set this to "true" to accept the Terms of Service of your ACME provider.ACME_API
(default: https://acme-v02.api.letsencrypt.org/directory): set this to https://acme.mock.directory to use invalid certificates without any verification (great for debugging). ZeroSSL might be better in the future as it doesn't have rate limits and doesn't clash with the official Codeberg certificates (which are using Let's Encrypt), but I couldn't get it to work yet.ACME_EAB_KID
&ACME_EAB_HMAC
(default: don't use EAB): EAB credentials, for example for ZeroSSL.ACME_EMAIL
(default:noreply@example.email
): Set the email sent to the ACME API server to receive, for example, renewal reminders.ACME_USE_RATE_LIMITS
(default: true): Set this to false to disable rate limits, e.g. with ZeroSSL.DNS_PROVIDER
(default: use self-signed certificate): Code of the ACME DNS provider for the main domain wildcard. See https://go-acme.github.io/lego/dns/ for available values & additional environment variables.ENABLE_HTTP_SERVER
(default: false): Set this to true to enable the HTTP-01 challenge and redirect all other HTTP requests to HTTPS. Currently only works with port 80.GITEA_API_TOKEN
(default: empty): API token for the Gitea instance to access non-public (e.g. limited) repos.GITEA_ROOT
(default:https://codeberg.org
): root of the upstream Gitea instance.HOST
&PORT
(default:[::]
&443
): listen address.LOG_LEVEL
(default: warn): Set this to specify the level of logging.NO_DNS_01
(default:false
): Disable the use of ACME DNS. This means that the wildcard certificate is self-signed and all domains and subdomains will have a distinct certificate. Because this may lead to a rate limit from the ACME provider, this option is not recommended for Gitea/Forgejo instances with open registrations or a great number of users/orgs.PAGES_DOMAIN
(default:codeberg.page
): main domain for pages.RAW_DOMAIN
(default:raw.codeberg.page
): domain for raw resources (must be subdomain ofPAGES_DOMAIN
).
Custom Error Page
A custom error page template can be served by creating custom/error.html
.
Data available to the template includes:
{{ .StatusCode }}
: The HTTP status code (e.g. 404){{ .StatusText }}
: The textual name associated with the status code (e.g. Not Found){{ .Message }}
: The reason for the error
Contributing to the development
The Codeberg team is very open to your contribution. Since we are working nicely in a team, it might be hard at times to get started (still check out the issues, we always aim to have some things to get you started).
If you have any questions, want to work on a feature or could imagine collaborating with us for some time, feel free to ping us in an issue or in a general Matrix chat room.
You can also contact the maintainer(s) of this project:
Previous maintainers:
First steps
The code of this repository is split in several modules. The Architecture is explained in the wiki.
The cmd
folder holds the data necessary for interacting with the service via the cli.
The heart of the software lives in the server
folder and is split in several modules.
Again: Feel free to get in touch with us for any questions that might arise. Thank you very much.
Test Server
Make sure you have golang v1.21 or newer and just installed.
run just dev
now these pages should work:
- https://cb_pages_tests.localhost.mock.directory:4430/images/827679288a.jpg
- https://momar.localhost.mock.directory:4430/ci-testing/
- https://momar.localhost.mock.directory:4430/pag/@master/
- https://mock-pages.codeberg-test.org:4430/README.md
Profiling
This section is just a collection of commands for quick reference. If you want to learn more about profiling read this article or google
golang profiling
.
First enable profiling by supplying the cli arg --enable-profiling
or using the environment variable EENABLE_PROFILING
.
Get cpu and mem stats:
go tool pprof -raw -output=cpu.txt 'http://localhost:9999/debug/pprof/profile?seconds=60' &
curl -so mem.txt 'http://localhost:9999/debug/pprof/heap?seconds=60'
More endpoints are documented here: https://pkg.go.dev/net/http/pprof