- Shell 100%
| custom | ||
| .gitattributes | ||
| forgejo.env | ||
| LICENSE | ||
| README.md | ||
OpenAQW Code
This is how code.openaqw.com is set up and run. It is Forgejo, a self-hosted forge, running from Forgejo's official container image on Railway.
There isn't much custom here. If you want your own Forgejo on Railway, this is a reasonable place to start.
What runs
- One Railway service using the image
codeberg.org/forgejo/forgejo:15.0.9, limited to 0.5 vCPU and 0.5 GB of memory. - A Railway volume mounted at
/data. It holds the repositories, the SQLite database, avatars and Forgejo's ownapp.ini. - Railway serves HTTPS and forwards to Forgejo on plain HTTP, port 3000.
code.openaqw.comis a CNAME to Railway.- There is no SSH. Clone and push over HTTPS, signing in with an access token.
- Sign-ups are closed. Actions are off for now.
Settings
When the container starts, Forgejo's image writes every variable named
FORGEJO__section__KEY into app.ini. forgejo.env lists the
ones set on the Railway service. When one changes, change it in Railway and
here together.
The secret keys and the admin account were made by Forgejo's installer on
first start. They live only in app.ini and the database on the volume, so
they are not in this repository.
Custom style
Forgejo adds templates/custom/header.tmpl from its custom folder to every
page's <head>. Railway can't place a file in the image, so the service's
start command writes it from the CUSTOM_HEAD_HTML variable, starts the
refresher described below, and hands over to the image's own entrypoint:
/bin/sh -c "mkdir -p /data/gitea/templates/custom; printenv CUSTOM_HEAD_HTML > /data/gitea/templates/custom/header.tmpl; printenv EXTERNAL_REPOS_SH > /tmp/external-repos.sh; sh /tmp/external-repos.sh & exec /usr/bin/entrypoint"
CUSTOM_HEAD_HTML holds the contents of custom/header.tmpl.
It hides the topic tags under each repository on the organization page, and
adds a card for each repository that is listed here but hosted on GitHub
(today aqw-lodestar). Forgejo reads the file as a template, so it must not
contain {{.
EXTERNAL_REPOS_SH holds custom/external-repos.sh.
Every six hours it copies each of those repositories' description, language,
stars, forks and last push from GitHub's API into
/data/gitea/public/assets/external-repos.json, which Forgejo serves at
/assets/external-repos.json. The cards read that file, so visitors' browsers
never contact GitHub. A failed read keeps the last copy and is tried again
an hour later. GitHub answers 60 anonymous calls an hour per address; if the
deploy log shows it refusing, set GITHUB_TOKEN to a fine-grained token with
no permissions.
To list another GitHub repository, add an entry to the external list in
custom/header.tmpl (its repo is github: and then the owner and name), put
an icon in custom/ if it has one, and paste the whole file into
CUSTOM_HEAD_HTML. To undo all of this, clear both variables, or set the start
command back to /usr/bin/entrypoint.
Upgrading
- Read Forgejo's release notes for every version between ours and the new one.
- Back up the volume in Railway.
- Change the image tag on the Railway service, and in this README.
- Deploy, then check the site and a
git clone.
License
MIT, see LICENSE.