Building a Coreapp

For developers: make an app or port an existing one with coreapp-dev, and test it on a Core on your own computer.

coreapp-dev is the kit for making Coreapps. It runs a real Federated Core in a virtual machine on your computer, and its coreapp command builds your app, installs it on that Core, and tests it there: its address and certificate, sign-in with Core SSO, its database, and the mail it sends. When it works, you publish it so any Core can install it.

A Coreapp is any web app that runs in one Docker container and serves HTTP on a port. It can be new, or an existing project: most self-hosted web apps can be ported by adding a coreapp.toml and adjusting their Dockerfile.

Before you start

You need coreapp-dev installed and a development Core running in a VM on your computer, reachable from the internet. Setting up coreapp-dev takes you through it step by step, and ends with a first app deployed.

Make a new app

coreapp new my-app
cd my-app
coreapp deploy
coreapp check

coreapp new makes a folder with a working example: a Dockerfile, a coreapp.toml, an icon, and a README. Add what the app needs from the Core:

OptionGives the app
--postgresIts own PostgreSQL database (with a Python example that uses it)
--mysqlIts own MariaDB database, instead of PostgreSQL
--ssoSign-in with Core SSO (with a Python example of the whole sign-in)
--emailAn account on the Core’s mail server, for sending

coreapp deploy builds the image, copies it to the Core in your VM, and installs it at https://my-app.<your Core's domain>. Run it again after each change: it updates the app and keeps its data. If the new version doesn’t start, the update is rolled back. coreapp check confirms the app answers at its public address with a valid certificate.

Port an existing app

Work in the app’s repository. Add a coreapp.toml (see the reference), and make the Dockerfile fit the Core:

  • Serve plain HTTP on 0.0.0.0 and the port in coreapp.toml. The Core’s proxy adds HTTPS in front.
  • Use the Core’s settings. The app gets its address, a secret, and its database, sign-in, and mail settings as environment variables. Map them onto the app’s own settings, in an entrypoint script if it’s an upstream image.
  • Keep files in /data. That folder is kept across updates; everything else in the container is replaced.
  • Run as a non-root user, if the image allows it.
  • One container. If the project ships a compose file with several services, keep only the app, and use the Core’s database instead of its own. Services the Core doesn’t offer, such as Redis, aren’t available yet.

Test it

CommandChecks
coreapp checkThe app answers at its public address, with a valid certificate
coreapp signinSigns in with Core SSO as a browser would, with the Core’s test account, and shows each step
coreapp inboxThe mail the test account received from your app (invitations, password resets), with its links
coreapp mailWhat the Core’s mail server did with the mail your app sent: accepted, delivered, deferred, or bounced
coreapp logs -fThe app’s log
coreapp shellA shell in the app’s container
coreapp statusIts container, address, and needs

The test account, coreapp.test@<your Core's domain>, is an ordinary Core account in no groups: use it to check what a newcomer sees. Before a release, also sign in once in a browser as the Core’s admin, to check the admin gets the admin role.

Rules for sign-in

Every Coreapp that signs in with Core SSO follows the same two rules, so a Core’s owner knows what to expect from any app:

  • The Core’s admin is the app’s admin. The address in CORE_ADMIN_EMAIL is made an admin each time it signs in with Core SSO, trusted only from the email the Core’s sign-in gives. No setup page, no first person to sign up becomes the owner, and that account has no password of its own in the app.
  • Everyone else gets the lowest role that can look around, usually read-only, without an invitation. In an app where each person only has their own private things, such as a feed reader, that’s a regular user.

Label the sign-in button Core SSO (or Authelia), so it reads the same in every app.