organize-backend is the backend server for the organize-rn client.
- Clone the organize-backend repo from GitHub
git clone [email protected]:High5Apps/organize-backend.git \ && cd organize-backend
- Run the
dev-setup
scriptIf you choose not to install aliases, you'll need to fully type out the following commands wherever they appear later on:# If you don't use ZSH, use your own alias file path (e.g. ~/.bashrc) # If you don't want to add aliases at all, remove the --alias-file option bin/dev-setup --alias-file ~/.zshrc
# Instead of dc docker compose -f compose.yaml -f compose.override.dev.yaml # Instead of drailsa docker compose -f compose.yaml -f compose.override.dev.yaml exec api bin/rails # Instead of drailss docker compose -f compose.yaml -f compose.override.dev.yaml exec site bin/rails
- Download and install the following software, if you don't have it already:
- Start Docker Desktop, navigate to the repository root in your terminal, then start the development server with:
dc up
- Launch VS Code by opening a new terminal tab in the repository root with
code .
. If you just installed VS Code, you'll need to follow these instructions on launching from command line first.
VS Code IntelliSense provides code completion and other helpful hints to improve developer experience, but it must be set up before it will work.
- Follow these instructions to attach to a Docker container
- In the VS Code extensions tab, search for and install
shopify.ruby-extensions-pack
Run Rails tests with the commands below. For more options, see The Rails Test Runner.
# Run all tests for the api service
drailsa test
# Run all tests for the site service
drailss test
A subset of tests can be run with the -n /regex/
flag, which will match against the underscored test name. For example:
# Run model and controller tests relating to ballots
drailsa t -n /Ballot/
# Run User model tests
drailsa t -n /UserTest/
# Run a single test by name
drailsa t -n /OrgTest#test_graph_should_include_blocked_user_ids/
Copy/paste the production environment variables into your .env
file, then:
bin/deploy org
Rails includes many built-in tasks for administering the application service. List them all with drailsa -T
. Commonly used custom tasks are detailed below:
This task randomly simulates an Org at the 10-day mark to simplify development. It's normally used as follows:
- Use your development client to create a new Org
- Run
drailsa org:sim
on your development machine - Share your Org's group secret from the development client's development settings menu into the task's input
- If you're using a simulator or emulator on your development machine, just copy and paste the group secret into the task's input.
- If you're using a physical development device external to your development machine, share the group secret using a secure meassaging service. For example you could share it from an Android phone to a Mac using the Signal app "Note to Self" feature, then open the Signal desktop client on your Mac, then copy/paste it into the task's input.
- Refresh your development client to see the simulated Org
To run organize-backend on a Raspberry Pi, perform the following steps:
- Download the OS image
- Format the SD card (if needed)
- Open Disk Utility
- If the SD card isn’t FAT32 formatted, erase and reformat it to FAT32
- Flash the Raspbian image onto the SD card
bin/flash ~/Downloads/2024-07-04-raspios-bookworm-arm64-lite.img
- Set up the physical Raspberry Pi
- Insert the SD card into the Raspberry Pi
- Connect an Ethernet cable to the Raspberry Pi
- Connect the power cable to the Raspberry Pi
- Turn on the Raspberry Pi
- Bootstrap the Raspberry Pi's software
- If
ping raspberrypi.local
doesn't work after a few minutes, your local network probably doesn't support multicast DNS. In this case, you'll need to add the environment variableIP=<address>
. Your Pi's IP address can usually be found on your router's local configuration page. You should also configure your router to give your Pi a static IP address.
bin/bootstrap org
- If
- On your DNS registrar's website, create a new A record pointing from
@
to your local network's IP address. - Set up port forwarding from router to server on 80/TCP and 443/TCP
curl http://getorganize.app # To test connection
- Verify that cert setup succeeded
ssh org docker compose logs -f
- You can also check that a new entry was added to the certificate transparency log
- Verify that the backend startup succeeded by hitting the new server with the mobile app