Skip to content

reboot-dev/reboot-examples

Repository files navigation

Reboot Monorepo Example

For the impatient:

  1. Prepare an environment by either:
  2. Run the application

Overview

This repository contains example applications written using Reboot. The examples are structured in the style of a monorepo: all proto files can be found in the api/ directory, grouped into subdirectories by proto package, while application code is broken into top-level directories by application name.

The Reboot '.proto' definition can be found in the api/ directory, grouped into subdirectories by proto package, while backend specific code can be found in top-level directories by application name.

For more information on all of the Reboot examples, please see the docs.

Prepare an environment by...

Using VSCode connected to a GitHub Codespace

This method requires running VSCode on your machine: if that isn't your bag, see the other environment option below.

This repository includes a Dev Container config (more about Dev Containers) that declares all of the dependencies that you need to build and run the example. Dev Containers can be started locally with VSCode, but we recommend using GitHub's Codespaces to quickly launch the Dev Container:

  1. Right-click to create a Codespace in a new tab or window:
    • Open in GitHub Codespaces
  2. Go to https://github.com/codespaces and click the three dots next to the codespace you just created and then click Open in Visual Studio Code.

Now you're ready to run the application!

Installing prerequisites directly

Running directly on a host requires:

  • A platform of either:
    • x86_64 Linux with glibc>=2.31 (Ubuntu Focal and other equivalent-generation Linux distributions)
    • arm64 or x86_64 MacOS with MacOS>=13.0 and Xcode>=14.3
  • Rye - A tool to manage python, pip, and venv.
  • Docker
    • Note: the example does not run "inside of" Docker, but Docker is used to host a native support service for local development.

If you are unable to meet any of these requirements, we suggest using the VSCode and Dev Container environment discussed above.

Now you're ready to run the application!

Run the application

Backend

Our backend is implemented in Python and we must install its dependencies before running it. The most notable of those dependencies is the reboot PyPI distribution, which contains both the Reboot CLI (rbt) and the reboot Python package.

Using rye, we can create and activate a virtualenv containing this project's dependencies (as well as fetch an appropriate Python version) using:

rye sync --no-lock
source .venv/bin/activate

Pick your application directory

The rbt tool can load its flags from an .rbtrc file, which is a convenient way of keeping the options you have to type (and remember!) to a minimum. We provide a different .rbtrc for every application in this repository, and by selecting an application directory you select the .rbtrc that will be used:

cd hello-constructors

Run the backend

Then, to run the application, you can use the Reboot CLI rbt (present in the active virtualenv):

rbt dev run

Running rbt dev run will watch for file modifications and restart the application if necessary. See the .rbtrc file for flags and arguments that get expanded when running rbt dev run.

Tests

The application comes with backend tests.

Before you run the tests, you'll need to ensure you've run rbt protoc. If you've already run rbt dev run without modifying .rbtrc, rbt protoc will have been run for you as part of that command. Otherwise, you can do it manually.

rbt protoc

rbt protoc will automatically make required Reboot '.proto' dependencies like rbt/v1alpha1/options.proto available on the import path without you having to check them into your own repository.

Now you can run the tests using pytest:

pytest backend/