Forgejo¶
perfshop-forgejo is the self-hosted Git server embedded in PerfShop. It plays three roles:
- Single source of test scripts — the Robot Framework and pytest scripts used by the QA stack are versioned in a Forgejo repository (
perfshop-tests), not hard-copied into Docker images. - SCM for Squash TM — Squash TM points to Forgejo to retrieve scripts at execution time through its Git SCM plugin.
- Backend for the Scripts UI editor — all file editing operations from
perfshop-scripts-uiare calls to the Forgejo REST API.
Forgejo is a community fork of Gitea, driven by an independent community since 2022. PerfShop uses version 14, configured in single-node mode with a SQLite database — sufficient for pedagogical use and significantly lighter than a full PostgreSQL installation.
Source of truth
This page is drawn from the perfshop-forgejo (and perfshop-forgejo-seed) blocks of the docker-compose.desktop.yml / docker-compose.build.yml files, and from the seed.py script in the forgejo-seed/ folder (and its test_seed.py tests).
Docker Compose configuration¶
perfshop-forgejo — Git server¶
| Key | Value |
|---|---|
| Image | codeberg.org/forgejo/forgejo:14 |
container_name |
perfshop-forgejo |
| Exposed port | 3009 (host) → 3000 (container), variable FORGEJO_HTTP_PORT |
| Volume | forgejo-data:/data (named volume, holds the SQLite DB and Git storage) |
| Network | perfshop-network |
Environment variables¶
The Forgejo configuration uses the FORGEJO__<section>__<key> convention which is internally translated into the [section] sections of the official app.ini file.
| Variable | Value | Role |
|---|---|---|
FORGEJO__server__DOMAIN |
${FORGEJO_DOMAIN:-localhost} |
Git domain (appears in clone URLs) |
FORGEJO__server__ROOT_URL |
${PUBLIC_FORGEJO_URL:-http://localhost:3009} |
Full public URL (used for UI links) |
FORGEJO__server__HTTP_PORT |
3000 |
Internal listening port |
FORGEJO__database__DB_TYPE |
sqlite3 |
SQLite database (no dedicated DB service) |
FORGEJO__database__PATH |
/data/gitea/forgejo.db |
SQLite file persisted in the volume |
FORGEJO__security__INSTALL_LOCK |
true |
Locks the initial install screen (no web wizard) |
FORGEJO__service__DISABLE_REGISTRATION |
false |
Allows account creation from the UI (pedagogical use) |
FORGEJO__security__PASSWORD_CHECK_PWN |
false |
Disables HaveIBeenPwned check (avoids outbound calls) |
FORGEJO__oauth2__ENABLE |
false |
No OAuth2 — only local auth and tokens |
FORGEJO__api__ENABLE_SWAGGER |
true |
Exposes Swagger documentation at /api/swagger |
FORGEJO__api__MAX_RESPONSE_ITEMS |
50 |
Pagination cap for the REST API |
FORGEJO__http__ENABLE_PPROF |
false |
Disables the Go profiling endpoint (reduced attack surface) |
FORGEJO__security__DISABLE_GIT_HOOKS |
true |
Forbids server-side Git hooks (Forgejo's default, written explicitly): an account granted the right would make the server run code on every push, on an instance open to registration. No lab uses them, nor does Squash TM (it pushes and clones over HTTP). Until 2026-10-15, false allowed them. |
FORGEJO__git__DISABLE_DIFF_HIGHLIGHT |
false |
Enables syntax highlighting in diffs |
FORGEJO__admin__DEFAULT_EMAIL_NOTIFICATIONS |
disabled |
No email sending (no SMTP configured) |
Healthcheck¶
| Parameter | Value |
|---|---|
| Test | curl -f http://localhost:3000/api/v1/version |
interval |
10s |
timeout |
5s |
retries |
10 |
start_period |
30s |
The 30-second start_period gives Forgejo time to initialize its SQLite database and load its Go modules on first startup.
perfshop-forgejo-seed — initialization at every startup¶
| Key | Value |
|---|---|
| Image | python:3.11-slim (no build; standard library only, nothing is downloaded at startup) |
| Command | python -u /app/seed.py |
container_name |
perfshop-forgejo-seed |
| Volumes | ./forgejo-seed/seed.py:/app/seed.py:ro, ./test-runner/scripts:/scripts:ro (scripts to push), forgejo-token-data:/token (tokens), docker-relay-forgejo-seed:/run/docker-relay:ro (Docker relay socket: admin creation, see below) |
depends_on |
perfshop-forgejo and perfshop-docker-relay, with condition: service_healthy |
restart |
"no": runs at every docker compose up, then stops |
Environment variables:
| Variable | Default | Role |
|---|---|---|
FORGEJO_URL |
http://perfshop-forgejo:3000 |
Internal URL for API calls |
FORGEJO_ADMIN_USER |
forgejo-admin |
Administrator account created by the seed |
FORGEJO_ADMIN_PASSWORD |
perfshop |
Administrator password (to change in an exposed deployment) |
FORGEJO_CI_USER |
perfshop-ci |
CI account (repositories, tokens) used by Scripts UI and Squash TM |
FORGEJO_CI_PASSWORD |
perfshop |
CI password |
FORGEJO_CI_EMAIL |
ci@perfshop.fr |
CI email |
FORGEJO_REPO |
perfshop-tests |
Name of the scripts repository |
FORGEJO_CONTAINER |
perfshop-forgejo |
Forgejo container in which the CLI creates the administrator |
DOCKER_HOST |
unix:///run/docker-relay/docker.sock |
Docker API socket: the one of the perfshop-docker-relay relay, never the daemon's |
Paths that can be overridden, not set in the compose: FORGEJO_TOKEN_FILE (default /token/forgejo_token, same variable as Scripts UI), SQUASH_TOKEN_FILE (/token/squash_tm_token), FORGEJO_SCRIPTS_DIR (/scripts). Without DOCKER_HOST, seed.py falls back to unix:///var/run/docker.sock, which the compose files no longer mount in the seed.
The seed.py script¶
The forgejo-seed/seed.py script is idempotent: each step reads the current state before acting, nothing is duplicated or rewritten identically. Exit code: 0 if everything is in place, 1 otherwise — a failure shows in docker compose ps -a (Exited (1)) and in the summary of docker logs perfshop-forgejo-seed; perfshop-squash-seed only starts after its success.
| Step | Function | What is done | Rerun |
|---|---|---|---|
| 1 | wait_for_forgejo() |
Waits for GET /api/v1/version = 200 (40 × 10 s) |
— |
| 2 | ensure_admin() |
Forgejo CLI forgejo admin user create --admin run inside perfshop-forgejo, as user git, through the Docker API (see below); then the API decides: the account must authenticate (30 × 5 s) |
CLI: "user already exists" |
| 3 | ensure_ci_user() |
Creates perfshop-ci if missing (admin API) |
never modified |
| 4 | ensure_repo() |
Creates perfshop-tests (initialized, main branch) and perfshop (empty) |
already there |
| 5 | ensure_token() |
CI account tokens written in /token (see below) |
reused if they open the repository |
| 6 | push_scripts() |
Pushes the scripts of /scripts into perfshop-tests |
identical → nothing |
| 7 | push_plans() |
Pushes the shipped JMeter plans of /plans (jmeter/scenarios) into perfshop-tests, under jmeter/scenarios/; a failure does not change the exit code (Squash does not need them) |
identical → nothing |
Full seed flow¶
sequenceDiagram
autonumber
participant SD as perfshop-forgejo-seed
participant DK as perfshop-docker-relay<br/>(then Docker daemon)
participant FG as perfshop-forgejo
participant FTD as forgejo-token-data volume
SD->>FG: GET /api/v1/version
FG-->>SD: 200 {version: "14.x"}
SD->>DK: POST /containers/perfshop-forgejo/exec (User git)<br/>forgejo admin user create --admin
DK->>FG: CLI run inside the container
DK-->>SD: "successfully created" (0) or "user already exists" (1)
SD->>FG: GET /api/v1/users/forgejo-admin (Basic)
FG-->>SD: 200 — otherwise exit 1
SD->>FG: GET /api/v1/users/perfshop-ci → 404 ⇒ POST /api/v1/admin/users
SD->>FG: GET /api/v1/repos/perfshop-ci/{perfshop-tests, perfshop} → 404 ⇒ POST /api/v1/user/repos
SD->>FTD: reads /token/forgejo_token
SD->>FG: GET /api/v1/repos/perfshop-ci/perfshop-tests (token)
alt 200: valid token
SD->>SD: reused
else missing or refused
SD->>FG: DELETE the old token with the same name, POST /api/v1/users/perfshop-ci/tokens
SD->>FTD: writes /token/forgejo_token (same for squash_tm_token)
end
loop for each script of /scripts
SD->>FG: GET .../contents/{path}
alt missing
SD->>FG: POST .../contents/{path} (feat: ajout …)
else different blob sha
SD->>FG: PUT .../contents/{path} + sha (chore: maj …)
else identical
SD->>SD: nothing (no commit)
end
end
loop for each shipped plan of /plans
SD->>FG: same rule, under jmeter/scenarios/{path}
end
SD-->>SD: summary, exit 0 (or 1)
Administrator account creation¶
Forgejo is started with INSTALL_LOCK=true: no installation wizard, and the API cannot create the first account without administrator credentials. The seed therefore runs the Forgejo CLI inside the perfshop-forgejo container, the equivalent of:
docker exec --user git perfshop-forgejo \
forgejo admin user create --admin --must-change-password=false \
--username <user> --password <pass> --email <user>@perfshop.fr
The seed does not ship the docker binary: it calls the Docker Engine API (POST /containers/{name}/exec, POST /exec/{id}/start, GET /exec/{id}/json) with the Python standard library. It does not mount the daemon socket: it talks to the perfshop-docker-relay relay (DOCKER_HOST=unix:///run/docker-relay/docker.sock, named volume docker-relay-forgejo-seed, read-only), which grants it these three calls only, on perfshop-forgejo only — see Docker socket: the relay. The CLI refuses to run as root: the exec runs as user git, and the relay pins it whatever the seed asks.
Without FORGEJO_CONTAINER (or without the relay socket), the administrator account must already exist. The GITEA_ADMIN_USERNAME / GITEA_ADMIN_PASSWORD / GITEA_ADMIN_EMAIL variables, present in the perfshop-forgejo block, create no account: measured on 2026-09-28 on a fresh Forgejo 14.0.3, the API answers 401 for the account after 20 s. In every case the API decides: if the account does not authenticate (password changed in Forgejo, for example), the seed exits with 1.
The two tokens¶
File (forgejo-token-data volume) |
Name in Forgejo | Reader |
|---|---|---|
/token/forgejo_token |
perfshop-scripts-ui |
perfshop-scripts-ui (mounted read-only, read again when the file changes) |
/token/squash_tm_token |
squash-tm-scm |
no service: value not shown (the seed summary only gives the file); read it with docker exec perfshop-scripts-ui cat /token/squash_tm_token, then enter it in Squash TM (Administration > SCM servers) if a token is preferred to the perfshop-ci / password pair of the guide |
Scopes: write:repository (which includes reading). A token is reused as long as it opens the perfshop-tests repository; validity is not tested on /api/v1/user, which answers 403 to a repository-scoped token (measured). Otherwise (volume recreated, token revoked in Forgejo), the old token with the same name is deleted — Forgejo refuses a name already taken (400) — then a new one is created and written (write then rename: Scripts UI never reads a partial file).
The two created repositories¶
perfshop-tests¶
The test scripts repository, edited from Scripts UI and consumed by Squash TM. The seed pushes the .robot, .py and .json files of test-runner/scripts/ (subfolders included, hidden folders and __pycache__ excluded), at the same paths. As of 2026-09-28: 14 files — CT-002-prix-coherence.robot, CT-003-prix-panier.robot, CT-010-parcours-metier.robot, CT-011-parcours-metier-ui.robot, CT-020-pages-hors-parcours.robot, CT-021-mes-commandes.robot, CT-022-catalogue.robot, CT-023-checkout.robot, run-pytest.robot, smoke-test.robot, test_prix_panier.py, lib/PerfShopSelectors.py, lib/i18n/fr.json, lib/i18n/en.json, plus the initialization README.md. Both language files are pushed: PerfShopSelectors.py chooses at run time (PERFSHOP_LANG, fallback to fr.json).
The folder is mounted, not copied into an image: an added or modified script is pushed at the next docker compose up (added or updated), an identical script produces no commit. A file deleted from the folder is not deleted from the repository.
Shipped JMeter plans (since 2026-10-19, PO decision: students read them in Forgejo, without an account): the seed
also pushes the 8 plans shipped with PerfShop, at the same path as in the repository (jmeter/scenarios/, mounted
read-only on /plans) — http://<platform address>:3009/perfshop-ci/perfshop-tests/src/branch/main/jmeter/scenarios/. Only the plans of the PLANS_LIVRES list are pushed, the same as JMeter UI's
read-only list (guard: jmeter-ui/test/forgejo-seed-plans.test.js): the plans the class saves in JMeter UI are never
published. The plans carry no account: they read users.csv, which stays on the platform. A missing or refused plan
does not change the exit code, as Squash does not need them: the summary says so ("plans JMeter livrés: ⚠ NON PUBLIÉS
(sans effet sur Squash)").
perfshop¶
A second, empty repository that can host a copy of PerfShop's application source code. It lets a trainer make a pedagogical commit (e.g. "add this line to fix the postal code validation bug") without touching the actually deployed code.
Measurements of 2026-09-28 (first startup without Internet)¶
First startup simulated on an internal Docker network (no way out), fresh Forgejo, compose replayed as is: seed exit code 0 (14 s); read back in Forgejo: forgejo-admin (admin) and perfshop-ci, 2 repositories, 15 commits (initialization + 14 scripts), 2 valid tokens. Rerun: exit code 0, no commit, same tokens. The former definition (image built FROM docker:27-cli + apk add python3 py3-requests) does not start without a build, and its apk add fails without network; replayed on the same platform, the former image replaced both tokens (403 on /api/v1/user taken for an invalid token), added 10 commits and put back in Forgejo the April version of lib/PerfShopSelectors.py, frozen in the image at build time.
Tests: forgejo-seed/test_seed.py (fake Forgejo over HTTP and fake Docker daemon on a Unix socket, standard library; run under Linux):
docker run --rm --pull never -v "$PWD/forgejo-seed:/t:ro" -w /t python:3.11-slim python -B -m unittest -v test_seed
From the repository root; under Git Bash (Windows), prefix with MSYS_NO_PATHCONV=1.
Usage by consumers¶
flowchart TB
subgraph seed["perfshop-forgejo-seed (at every up)"]
S1["1. Admin account<br/>(CLI through Docker API)"]
S2["2. perfshop-ci account"]
S3["3. Repositories"]
S4["4. Tokens (reused)"]
S5["5. Scripts (add / update)"]
S1 --> S2 --> S3 --> S4 --> S5
end
subgraph fg["perfshop-forgejo (permanent service)"]
GIT["perfshop-tests repository<br/>+ perfshop repository"]
end
subgraph vol["forgejo-token-data (named volume)"]
T1["forgejo_token"]
T2["squash_tm_token"]
end
subgraph consumers["Consumers"]
SUI["perfshop-scripts-ui<br/>(interactive editing)"]
STM["perfshop-testmgmt<br/>(SCM Git plugin)"]
TR["perfshop-test-runner<br/>(git pull when a run<br/>starts)"]
end
seed --> fg
seed --> vol
SUI -->|HTTP API + token| fg
STM -->|git clone: perfshop-ci / password<br/>or token entered by hand| fg
TR -->|git clone / git pull| fg
SUI -.->|reads| T1
T2 -.->|read from the volume, entered by hand| STM
Security and exposure¶
Pedagogical use¶
By default, the shipped configuration is demo-oriented:
- Default admin password
perfshop(must be changed for any exposed deployment) FORGEJO__service__DISABLE_REGISTRATION=false— anyone can create an account from the UI (useful in training to give every student their own access)FORGEJO__security__PASSWORD_CHECK_PWN=false— no HaveIBeenPwned check- No SMTP configured — no verification or notification emails
Recommendations for public exposure¶
Before exposing on the internet
- Change
FORGEJO_ADMIN_PASSWORDandFORGEJO_CI_PASSWORD - Set
FORGEJO__service__DISABLE_REGISTRATION=trueto block open sign-ups - Add a reverse proxy with HTTPS and rate limiting
- Enable
FORGEJO__security__PASSWORD_CHECK_PWN=true(requires outbound connectivity to api.pwnedpasswords.com) - Configure SMTP for verification and password reset emails
- Switch to a dedicated PostgreSQL database if the repositories grow beyond a few GB (SQLite stays performant below that)
Going further¶
- QA Overview
- Scripts UI — main Forgejo API consumer
- Squash TM — also consumes Forgejo through its Git SCM plugin
- Test Runner — clones the
perfshop-testsrepository at the start of a run - Docker Compose — QA group — overview of all QA services