Hubs-Foundation / hubs-compose

Local development setup for Hubs
Mozilla Public License 2.0
45 stars 38 forks source link

Hubs Compose

Hubs Compose is a Docker Compose setup that can be used to orchestrate all the services used by Hubs for local development.

[!IMPORTANT] This is not a production-ready setup. It does not account for security or scalability. Additionally the permissions files were generated for development purposes only.

Prerequisites

[!NOTE] Mac Homebrew Formulae for those wanting to avoid installing the proprietary Docker Desktop on Macs. https://formulae.brew.sh/formula/docker https://formulae.brew.sh/formula/docker-compose

[!IMPORTANT] Ensure that the version of Mutagen Compose you're installing matches the version of Mutagen that you installed. (If you install the latest versions at the same time, they will "match", but for this reason it may be better to install the binaries explicitly and make sure that the versions for each are exactly the same).

Windows Specific Prerequisites

Summary

(Optional) Install WSL2

Docker Desktop runs more quickly when it can use its WSL2-based engine. Docker Desktop can only use its WSL2 engine if WSL2 is installed.

There are also other benefits to installing WSL2, including being able to run scripts and programs that your Unix developer friends share with you.

To install WSL2, follow Microsoft's documentation here: Install Linux on Windows with WSL

⚠️ Potential Conflict

If you plan to run Docker Desktop on Windows, and you want to take advantage of Docker Desktop's faster WSL2 engine, and you already have WSL2 installed, you need to first uninstall any previous versions of Docker Engine and CLI installed directly through WSL2.

You can read more about Docker Desktop + WSL2 on Docker's website.

Use Unix Line Endings

Some scripts used to run hubs-compose rely on those scripts containing Unix line endings. If you're running hubs-compose on Windows, you may need to change your Git line endings setting to ensure your local files include Unix-style line endings.

To change this setting, open a Git Bash shell, then run git config --global core.autocrlf false to ensure that the intended Unix-style line endings are preserved upon Git checkout.

If you've already cloned this hubs-compose repository locally, you may have to delete your local copy of the repository and re-clone it after changing your line endings setting.

Use Git Bash

Some scripts used to run hubs-compose are meant to run in a Unix-like bash shell. The "Git Bash" shell included with Git - also known as MINGW64 - will work to run these scripts; the Windows Terminal will not work to run these scripts.

Initial Setup

  1. Initialize the services with bin/init
  2. Start the containers with bin/up
  3. Self-Sign the certificates (see the Self-Signed Certificates section below)
  4. Sign into Hubs (see the Signing into Hubs section below)
  5. Create an admin user (see the Admin panel access section below)

Usage

Orchestration

[^1]: Requires tmux and watch program files in the user’s path

Self-Signed Certificates

Service communication is encrypted with self-signed Transport Layer Security (TLS) certificates. You will need to accept the proxy certificate and the certificate at each of the Hubs ports mapped in docker-compose.yml. At the time of this writing, that means visiting these links in your web browser and following the prompts:

[!NOTE] Seeing a page with the text "Cannot get /" when visiting Dialog (hubs.local:4443) after self-signing the certificate is normal. Seeing a page with the text "Cannot get /" when visiting Hubs Admin (hubs.local:8989) after self-signing the certificate is normal.

Signing into Hubs

  1. Go to Reticulum and click the sign in/up button.
  2. Enter an email address (it doesn't have to be real) that you'll remember (or write it down somewhere after).
    • Note: this will be the email address used for your admin account.
  3. View the logs for the Reticulum container: docker compose logs reticulum (add -f if you want a live update)
  4. Copy the magic verification link and open it in a new tab on your browser.
    • Note: it must be the same browser as your other Hubs Compose tabs are in.

Example Reticulum log entry for the magic link email:

%Bamboo.Email{from: {nil, "info@hubs-mail.com"}, to: [nil: "<your@email.address>"], cc: [], bcc: [], subject: "Your Sign-In Link", html_body: nil, text_body: "To sign-in to , please visit the link below. If you did not make this request, please ignore this e-mail.\n\n https://hubs.local:4000/?auth_origin=hubs&auth_payload=GPk2GOEbz9AcHROddvD%2F20%2B11FcKH%2FbKTj62gPCyUgjpeogFp94zpQoBh9nrBiY%2F16KYiGka0dseW9mDlN7n&auth_token=ca3ff98f63c4b7709d0b1c01a217f414&auth_topic=auth%3Add0ec69c-bfa2-4994-b183-aca1377b2f11", headers: %{}, attachments: [], assigns: %{}, private: %{}}

Admin panel access

To connect to the admin panel you will need to shell into the reticulum container and manually promote an account to admin.

You can shell into the reticulum container and start an iex console by running services/reticulum/bin/iex -S mix

[!NOTE] You must have signed in/created an account previously in order to promote it to admin. By default, the first account you sign in with/create will end up being the one promoted to be the admin account.

After you have promoted an account to admin, clear your local storage (see the Clearing Local Storage section below) and then sign in again.

Useful Docker commands

[!NOTE] You may see that some of the Hubs scripts use the -f flag in docker compose commands. According to https://docs.docker.com/reference/cli/docker/compose/ "The -f flag is optional. If you don’t provide this flag on the command line, Compose traverses the working directory and its parent directories looking for a compose.yaml or docker-compose.yaml file."

Reticulum Convenience Scripts

Common commands for Reticulum can be easily executed inside its running container from your shell using the scripts inside the Reticulum service’s bin/ directory. For example, calling bin/mix deps.get from ./services/reticulum/ will download the dependencies for Reticulum.

Troubleshooting

Experiencing issues with hubs-compose? Follow these steps to diagnose and resolve common problems:

If problems persist after these steps, consider reaching out for community support or filing an issue in the repository.

Clearing Local Storage

You can clear your local storage by opening the dev tools in your browser (Ctrl+Shift+I, or Cmd+Shift+I on Mac), navigating to the Application tab (Chrome) or the Storage tab (Firefox), expanding the "Local storage" tree item, and then deleting the key/value pairs stored there.

Hard Refreshing A Page

Rather than just refreshing your page, it's probably beneficial to remove the cache as well by performing a hard refresh, just to make sure there isn't any stale data causing problems. To hard refresh a page in Chrome/Firefox you can use the Ctrl+Shift+R hotkey (Cmd+Shift+R on Mac). This will also clear the cache for that page. For other browsers, see this page: https://filecamp.com/support/problem-solving/hard-refresh/

Development

Architectural Decision Records

Records of architectural decisions are stored in the decisions/ directory. If you make a decision that affects “the structure, non-functional characteristics, dependencies, interfaces, or construction techniques” of the project, please document it. If you install ADR Tools, adr new will generate the template for you.