Skip to content

Running an app store ​

An app repository can be a plain Git repository. When several developers publish apps, when apps should be reviewed before servers see them, or when you want a website where people browse apps, run the n5i App Store instead. It is the reference implementation of an app store server for n5i and the distributions built on it.

Its source is at gitlab.com/n5i/app-store. n5i doesn't publish prebuilt images or binaries: you build it from source, and distributions build their own images.

What it does ​

  • Hosts any number of repositories. Each one is served in the HTTP repository protocol, so a server adds it by its URL, as an app store of type HTTP App Repository.
  • Developers work in organizations: they upload versions of their apps and submit them to repositories, from the web interface or from CI.
  • Repository staff review submissions and store listings (description, icon, screenshots, release notes), can yank versions and deprecate apps. Deprecated apps keep receiving updates on servers that have them, but aren't offered for new installs.
  • Upstream releases on GitHub are checked regularly, so developers see when an update is due.
  • Everything is also available through a REST API, documented on the store itself at /api/docs.

Quick start ​

You need Docker or Podman with Compose:

sh
git clone https://gitlab.com/n5i/app-store.git
cd app-store
docker compose up -d --build
docker compose exec -e APP_STORE_PASSWORD='change-me-please' app-store \
  n5i-app-store user create --username admin --email admin@example.com --role admin

Open http://localhost:8080 and log in as admin to reach the console. There you create repositories, approve account requests and change the site name.

The default repository, Main repository, is also served at the site root: add http://localhost:8080 (or your public URL) to an n5i server as an HTTP App Repository and its approved apps show up there.

For a public instance:

  • Set PUBLIC_URL to the address users reach the store at. Passkeys, cookies and CSRF protection depend on it.
  • Put it behind a reverse proxy that terminates TLS and rate-limits logins.
  • Consider S3-compatible storage (STORAGE_URL=s3://bucket) and a CDN (CDN_URL): the repositories are then published there as static files, so servers download apps from the CDN instead of the app store.

Settings go into app-store.env next to compose.yaml. The README lists all of them.

Your own branding ​

The store presents itself as an n5i app store by default. A distribution that runs it for its users changes that with configuration, without changing the code:

sh
# app-store.env
BRAND_PLATFORM_NAME=Example OS          # "Add this repository to Example OS"
BRAND_WEBSITE_URL=https://example.com   # footer link
BRAND_DIR=/brand                        # served at /brand/
BRAND_LOGO=/brand/logo.svg
BRAND_LOGO_DARK=/brand/logo-dark.svg    # dark mode and the console's sidebar
BRAND_ICON=/brand/icon.svg              # favicon and default repository icon
BRAND_COLOR=#5b3cc4                     # or a full palette in BRAND_CSS=/brand/theme.css
BRAND_IMPRINT_URL=https://example.com/imprint
BRAND_PRIVACY_URL=https://example.com/privacy

Mount the directory into the container (./brand:/brand:ro in compose.yaml). The site name is changed by an admin in the console.

If your distribution offers more template features than n5i, list them in TEMPLATE_FEATURES, so that the store renders metadata.yml.jinja files like your servers do.

Publishing from CI ​

The most convenient way to publish is to keep your apps in a Git app store (an app-store.yml and one directory per app) and push it to the app store from CI. Every app in it becomes a version of your organization's app and is submitted to a repository; apps you delete can be deprecated automatically.

  1. Create an organization in the console and, under Account, an API token for an account that is an admin of the organization. To publish without waiting for a review, the account has to be a reviewer of the target repository.
  2. Add the token to your CI variables as APP_STORE_TOKEN (masked, protected), and optionally a second token for merge requests as APP_STORE_CHECK_TOKEN.
  3. Add a job like this one:
yaml
variables:
  APP_STORE_URL: https://apps.example.com
  APP_STORE_ORG: my-org
  APP_STORE_REPOSITORY: main

.push:
  image: docker.io/library/alpine:3.22
  before_script: [apk add --no-cache curl git jq]
  script:
    - git archive --format=tar.gz -o repository.tgz HEAD
    - >
      curl -sS --fail-with-body -o report.json -X POST
      -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/gzip"
      --data-binary @repository.tgz
      "$APP_STORE_URL/api/v1/orgs/$APP_STORE_ORG/push?repository=$APP_STORE_REPOSITORY&approve=true&deprecate_missing=true&dry_run=$DRY_RUN"
    - jq -r '.apps[] | [.outcome, .app, (.version // "-"), (.message // "")] | @tsv' report.json
    - "! jq -e '.apps[] | select(.outcome == \"failed\")' report.json > /dev/null"

check:
  extends: .push
  variables: {TOKEN: $APP_STORE_CHECK_TOKEN, DRY_RUN: "true"}
  rules: [{if: $CI_PIPELINE_SOURCE == "merge_request_event"}]

publish:
  extends: .push
  variables: {TOKEN: $APP_STORE_TOKEN, DRY_RUN: "false"}
  resource_group: app-store
  rules: [{if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH}]

Merge requests get a dry run that reports what would happen; the default branch publishes. The report lists one line per app with its outcome: created, updated, unchanged, skipped (the app belongs to another organization), removed (deprecated) or failed.

Existing versions are never changed, so bump the version of an app to publish it again. Changes of an app's store-metadata.yml (description, screenshots, release notes) are picked up without a new version and reviewed like one.

Operating it ​

Backups

Back up the Postgres database and the storage (the STORAGE_URL directory or bucket) together. Repositories published to a CDN can be regenerated from both.

  • Upgrades: back up, then start the new version. Database migrations run automatically before the server accepts requests (or explicitly with n5i-app-store migrate). Downgrades aren't supported after a migration.
  • Users: people request accounts on the site and an admin approves them. Admins can also create accounts with n5i-app-store user create and change roles with n5i-app-store user set-role.
  • Template rendering: version 1 apps with a metadata.yml.jinja are rendered in an isolated process with placeholder values, only to read their name and version. Version 2 apps keep that information in store-metadata.yml and aren't rendered at all.

Free and open-source software under the GNU AGPL 3.0 or later.