Skip to content

Commit fe35337

Browse files
committed
Flesh out dev setup documentation
1 parent c746ee8 commit fe35337

File tree

2 files changed

+97
-17
lines changed

2 files changed

+97
-17
lines changed

README.md

Lines changed: 85 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,40 +42,114 @@ If you are interested in getting involved with the project, check out [our page
4242

4343
[library-api](/library-api) contains a library of pre-built benefits and eligibility rules, suitable for including in custom screeners and for standing up a standalone eligibility API.
4444

45-
## Local Development Setup
45+
## Development Setup
46+
47+
### In the Cloud (Github Codespaces)
48+
49+
This is the easiest way to get started with development if you like having a cloud-based development environment. Just click the badge:
50+
51+
[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/CodeForPhilly/benefit-decision-toolkit)
52+
53+
Once you create a new codespace, the included Devcontainer will build and configure the project. This takes several minutes the first time, so be patient!
54+
55+
### On Your Local Machine
4656

4757
Clone this repository:
58+
4859
```bash
4960
git clone https://github.com/CodeForPhilly/benefit-decision-toolkit.git
5061
```
5162

5263
Go to the project's root directory:
64+
5365
```bash
5466
cd benefit-decision-toolkit
5567
```
5668

57-
To setup using the pre-defined [Devbox](https://www.jetify.com/docs/devbox/) configuration:
58-
*Note that this installs Devbox and Nix (if they aren't already installed).
69+
From here, you have 3 options:
70+
- Use [Devbox](https://www.jetify.com/docs/devbox/) (recommended),
71+
- Use [Devcontainer in VS Code](https://code.visualstudio.com/docs/devcontainers/containers), or
72+
- DIY (not recommended)
73+
74+
#### Option 1: Devbox (recommended)
75+
76+
We use [Jetify Devbox](https://www.jetify.com/docs/devbox/) to declare and manage project development dependencies. This makes it easy to setup the project and reduces *"works on my machine"* issues. It uses the Nix Package Manager under the hood, which results in higher performance compared to container-based solutions.
77+
78+
To install devbox (and Nix) and configure your machine for development:
79+
5980
```bash
6081
bin/install-devbox && devbox run setup
6182
```
6283

63-
If you don't want to use devbox/nix, then you can install system dependencies (e.g. JDK, Node, Maven) manually (see devbox.json for the list) and run:
84+
Then, to startup all the services/apps with the default configuration, run:
85+
6486
```bash
65-
bin/setup
87+
# uses process-compose under the hood
88+
devbox services up
6689
```
6790

68-
If using devbox, then run the shell to load dependencies:
91+
You can also run a shell in the context of Devbox with:
92+
6993
```bash
7094
devbox shell
71-
# Consider using direnv and/or the VS Code extensions (Devbox and Direnv) to automate this step.
7295
```
7396

74-
Then start apps as needed, e.g.:
97+
Or run a single command in the context of Devbox with:
98+
99+
```bash
100+
# export data from the firebase emulators (they must be running!)
101+
devbox run -- firebase emulators:export ./dir
102+
```
103+
104+
Tips:
105+
- Use the [Devbox direnv integration](https://www.jetify.com/docs/devbox/ide-configuration/direnv) to automatically start a Devbox shell whenever you navigate to the project directory.
106+
- If you develop in VS Code, then consider installing the [Devbox and Direnv extensions](https://www.jetify.com/docs/devbox/ide-configuration/vscode) to automatically start `devbox shell` in VS Code Terminal and otherwise manage Devbox via the Command Palette.
107+
- Edit the `.devboxrc` file (not in source control) to run custom commands every time you start a devbox environment. You can use this for things like disabling conflicting tools or adding project-specific shell aliases.
108+
109+
#### Option 2: Devcontainer in VS Code
110+
111+
This project comes with a devcontainer configuration that runs the Devbox/Nix environment inside the container itself. This is a good option for those used to a container-based workflow and don't mind the corresponding performance degradation as compared to native Devbox.
112+
113+
To use the provided devcontainer, first open VS Code and install the `Dev Containers` extension.
114+
115+
Then, use the command palette (Cmd+Shift+P or Ctrl+Shift+P) to run *"Dev Containers: Open Folder in Container..."* and select this project. It will take several minutes to build the container the first time.
116+
117+
You should be prompted to install Docker if it isn't already installed.
118+
119+
Once the container builds, startup all the services/apps in the default configuration by opening a Terminal in VS Code and running:
120+
121+
```bash
122+
devbox services up
123+
```
124+
125+
Note: the devcontainer automatically uses the equivalent of `devbox shell` in VS Code Terminal, so there is no need to run it manually.
126+
127+
#### Option 3: DIY (not recommended)
128+
129+
It is recommended to use Devbox, Devcontainer, or Codespaces to develop with this project because each of those methods draw from a single source of truth to build the development environment (devbox.json).
130+
131+
If you insist on going your own way then you can install system dependencies (e.g. JDK, Node, Maven) manually (see devbox.json for the list) and run:
132+
75133
```bash
76-
cd builder-frontend && npm run dev
134+
bin/setup
135+
```
136+
137+
Then to startup all the services/apps in the default configuration, install [process-compose](https://f1bonacc1.github.io/process-compose/) and run:
138+
139+
```bash
140+
process-compose
77141
```
78142

79-
You can find additional instructions to work on each app within the project in their respective directories, which are linked above.
143+
Or to run services manually (without `process-compose`):
80144

81-
Note that for the frontend apps, you will need a .env file from a teammate. Please do not commit this file to the repo.
145+
```bash
146+
# start the firebase emulators
147+
firebase emulators:start --project demo-bdt-dev --only auth,firestore,storage
148+
```
149+
150+
```bash
151+
# then start up services one by one in new shells, e.g.:
152+
bin/load-root-env
153+
cd builder-api
154+
quarkus dev
155+
```

bin/setup

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,14 +114,20 @@ echo ""
114114
print_success "🎉 Developer setup completed successfully!"
115115
echo ""
116116
echo "📋 Next Steps:"
117+
echo ""
117118
echo "1. Environment Configuration:"
118119
echo " a. If you plan to use devbox and develop against local emulators, then you are good to go!"
119120
echo " b. If not using devbox and/or plan to develop against real Firebase services, then you might need help from a teammate to finish setting up your environment."
120-
echo "2. If using devbox, then:"
121-
echo " a. Run 'devbox shell' within the project root directory to load dependencies. (https://www.jetify.com/docs/devbox/cli_reference/devbox_shell/)"
122-
echo " b. Consider using the direnv integration to load dependencies automatically. (https://www.jetify.com/docs/devbox/ide_configuration/direnv/)"
123-
echo " c. If you use VS Code, then consider installing the Devbox and Direnv extensions."
124-
echo "3. Run the web apps locally using 'npm run dev' from within builder-frontend and screener-frontend directories."
125-
echo "4. Run the library-api application using 'quarkus dev' within the library-api directory."
121+
echo "2. Run all main web app services locally in dev mode:"
122+
echo " a. With devbox: 'devbox services up'"
123+
echo " b. Without devbox: install then run 'process-compose'"
124+
echo "3. Other things to try:"
125+
echo " a. Run 'devbox shell' to load the environment without running services."
126+
echo " b. Consider using the direnv integration to load dependencies automatically."
127+
echo " c. Consider installing the Devbox and Direnv extensions for VS Code."
128+
echo " d. Run the library-api:"
129+
echo " i. 'devbox shell'"
130+
echo " ii. 'cd library-api'"
131+
echo " iii. 'quarkus dev'"
126132
echo ""
127133
print_status "Happy coding! 🚀"

0 commit comments

Comments
 (0)