Skip to content

Commit fe4f736

Browse files
authored
Add Makefile & streamline development documentation (#718)
* Remove unused file * Remove unused localtunnel * Add a makefile with useful commands Update the README, it's gotten a bit convoluted over time and some docker docs were missing * Add rails console to make file * Add step to seed DB
1 parent f9063b5 commit fe4f736

File tree

7 files changed

+58
-94
lines changed

7 files changed

+58
-94
lines changed

Makefile

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
start: ## Start the project
2+
docker compose --profile dev up
3+
4+
stop: ## Stop the project
5+
docker compose --profile dev down
6+
7+
startNative: ## Start the react native project
8+
docker compose --profile native up
9+
10+
stopNative: ## Stop the react native project
11+
docker compose --profile native down
12+
13+
build: ## Build the project
14+
docker compose build backend
15+
16+
specs: ## Run the specs
17+
docker compose --profile dev run --rm backend rspec spec spec
18+
19+
console: ## Open a rails console
20+
docker compose --profile dev run --rm backend rails c
21+
22+
seed: ## Seed your database
23+
docker compose --profile dev run --rm backend bundle exec rails app:setup
24+
25+
help:
26+
@sed -n -E "s/(^[^ ]+):.* ## (.*)/`printf "\033[32m"`\1|`printf "\033[0m"` \2/p" $(MAKEFILE_LIST) | sort | column -t -s '|'

README.md

+31-46
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,26 @@
66

77
Flaredown makes it easy for people to track symptoms over time, and learn how to control them. Our goal is to analyze the aggregate data from users of this tool to understand the probable effects of treatments and environmental stressors on chronic illness.
88

9-
Help would be appreciated! Please join us in [slack #flaredown](https://rubyforgood.herokuapp.com/) or raise a github issue, or email the contact@flaredown email which is currently checked every few days.
9+
Help would be appreciated! Please join us in [slack #flaredown](https://rubyforgood.herokuapp.com/), raise a GitHub issue, or email <contact@flaredown>.
1010

1111
## Environment
1212

1313
* PostgreSQL 12.8
14-
* MongoDB 4.4.9 https://docs.mongodb.com/manual/tutorial/install-mongodb-on-os-x/
14+
* MongoDB 4.4.9
1515
* Redis 6.2.3
16-
* Ruby 3.0.6 (see [RVM](https://rvm.io/) also)
16+
* Ruby 3.0.6
1717
* Node 12.22.6
1818

1919
## Installation
2020

21-
All dependencies are dockerized, including the application and can be run using `docker compose` so there's no dependencies to install other than docker.
21+
The application and all dependencies are dockerized and can be run using `docker compose`, so there's no dependencies to install other than Docker.
22+
Alternatively, you can run the app using the `make` commands available: `make help`
2223

2324
If you want to run the application on your own machine see the next sections on dependency installations
2425

25-
### Mac
26+
### Running natively
27+
28+
#### Mac Prerequisites
2629

2730
_If you are running on an M1 mac, run the following command before you start the installation process:_
2831
```bash
@@ -34,9 +37,13 @@ _Remove all gems before you proceed_
3437
gem uninstall -aIx
3538
```
3639

37-
### Backend
40+
#### Backend
41+
42+
You can install the dependencies via [asdf-vm](https://asdf-vm.com/) declared in the `.tool-versions` file, or:
43+
- [Ruby Version Manager](https://rvm.io/)
44+
- [MongoDB installation on OSX](https://docs.mongodb.com/manual/tutorial/install-mongodb-on-os-x/)
3845

39-
On macOS, you can install libpq by running `brew install libpq && brew link --force libpq && bundle config --local build.pg "--with-ldflags=-L$(brew --prefix libpq)/lib --with-pg-include=$(brew --prefix libpq)/include"`, which is required for `bundle install` to succeed.
46+
On macOS, you can install `libpq` by running `brew install libpq && brew link --force libpq && bundle config --local build.pg "--with-ldflags=-L$(brew --prefix libpq)/lib --with-pg-include=$(brew --prefix libpq)/include"`, which is required for `bundle install` to succeed.
4047

4148
```bash
4249
cd backend
@@ -52,70 +59,48 @@ bundle exec rake app:setup
5259
gem install foreman
5360
```
5461

55-
### Frontend
62+
#### Frontend
5663

5764
```bash
5865
cd frontend
5966
npm install
6067
```
6168

62-
### React Native
69+
#### React Native
6370

6471
```bash
6572
cd native
6673
npm install
6774
```
6875

69-
## Running / Development
70-
71-
### General
72-
It is necessary to populate environment parameters. You can take `backend/env-example` and add it to a new file in `backend/.env` and `frontend/.env`. You'll need to create a [Facebook dev app](https://developers.facebook.com/docs/development/create-an-app) and paste your own ID the frontend env file's `FACEBOOK_APP_ID` parameter. This is not necessary in the backend env but we have not yet cleaned up these two files into the necessary components.
73-
74-
### Docker
75-
76-
From the project root:
77-
78-
```bash
79-
docker compose --profile dev up
80-
```
81-
82-
This will build and run all the containers necessary to run the application locally.
83-
84-
Visit your app at [http://localhost:4300](http://localhost:4300)
76+
## Development
8577

78+
### Prerequisites
8679

87-
### Docker (React Native)
80+
- Populate the necessary environment parameters with `cp backend/env-example backend/.env && cp backend/env-example frontend/.env`
81+
- Create a [Facebook dev app](https://developers.facebook.com/docs/development/create-an-app) and paste your own ID into `frontend/.env` file's `FACEBOOK_APP_ID` parameter.
82+
- Note: This is not necessary in `backend/.env` but we have not yet cleaned up these two files into the necessary components.
83+
- Seed your database using `make seed` or `bundle exec rails app:setup`
8884

89-
From the project root:
85+
### Running
9086

91-
```bash
92-
docker compose --profile dev native
93-
```
94-
95-
This will build and run all the containers necessary to run the application locally.
96-
97-
Visit your app at [http://localhost:19006](http://localhost:19006)
98-
99-
### Local Machine Installation
100-
101-
From the project root:
102-
103-
```bash
104-
docker compose up
105-
```
87+
If you are running the application natively, run the following to start your server. If you're using docker, this should be up and running already.
10688

10789
```bash
10890
rake run
10991
```
11092

93+
Visit your app at [http://localhost:4300](http://localhost:4300) for the current ember application, or [http://localhost:19006](http://localhost:19006) for the React Native version.
94+
11195
## Running tests locally
112-
1. Run `docker compose build backend` to ensure the latest backend is being run
113-
2. To run all tests run `script/backend rspec spec spec`, or you can run a specific test suite such as `script/backend rspec spec spec/services/weather_retriever_spec.rb `
96+
97+
1. Run `make build` or `docker compose build backend` to ensure the latest backend is built and being run
98+
2. To run all tests run `make specs` or `script/backend rspec spec spec`, or you can run a specific test suite such as `script/backend rspec spec spec/services/weather_retriever_spec.rb `
11499
3. Debugging tip: in Ruby code you can add a line that says `debugger` and rspec will automatically break on that line and give you an interactive Ruby shell
115100

116101
## CI
117102

118-
Several checks are configured to run on all commits using Github Actions, including lint, build and test steps. Definitions can be found in [./github/workflows](./github/workflows). Those checks which always run are required to be successful for PRs to be mergable.
103+
Several checks are configured to run on all commits using GitHub Actions, including lint, build and test steps. Definitions can be found in [./.github/workflows](./.github/workflows). Those checks which always run are required to be successful for pull requests to be merged.
119104

120105
## Deployment
121106

@@ -136,6 +121,6 @@ Addons are used for Heroku Postgres, Heroku Redis, Heroku Scheduler + Papertrail
136121
* On first load, the app displays a blank beige screen instead of the login screen. Temporary fix is to add `console.log(process.env.FACEBOOK_APP_ID)` right inside of the module.exports at the top of the `frontend/config/environment.js` file. You can then refresh the page (no need to kill Docker) and this should fix it. You can now remove the log.
137122

138123
## License
139-
Copyright 2015-2017 Logan Merriam and contributors.
124+
Copyright 2015-2024 Logan Merriam and contributors.
140125

141126
Flaredown is open source software made available under the GPLv3 License. For details see the LICENSE file.

backend/Procfile.local

-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
web: bundle exec puma -C config/puma.rb
22
worker: bundle exec sidekiq -C config/sidekiq.yml
3-
tunnel: bundle exec bin/localtunnel

backend/bin/localtunnel

-31
This file was deleted.

backend/env-example

-5
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,6 @@ SMTP_USER=
2525
SMTP_PASS=
2626
SMTP_DOMAIN=
2727

28-
# Localtunnel configuration
29-
LOCALTUNNEL_ENABLED=false
30-
LOCALTUNNEL_SUBDOMAIN=safeflaredown
31-
LOCALTUNNEL_PORT=4300
32-
3328
# Facebook
3429
FACEBOOK_APP_ID=
3530
FACEBOOK_APP_SECRET=

docker-compose.yml

+1-10
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,6 @@ services:
3333
profiles:
3434
- dev
3535
- native
36-
tunnel:
37-
build: backend
38-
command: bundle exec bin/localtunnel
39-
depends_on:
40-
- backend
41-
volumes:
42-
- ./backend:/app
43-
profiles:
44-
- tunnel
4536
frontend:
4637
platform: linux/amd64
4738
build: frontend
@@ -55,7 +46,7 @@ services:
5546
command: sh -c "cd /app && rm -rfd ./dist && ./node_modules/.bin/ember serve --port 4300 --proxy http://backend:3000 --live-reload-host frontend --live-reload-port 65535"
5647
profiles:
5748
- dev
58-
native:
49+
native:
5950
build:
6051
context: ./native
6152
args:

noop

-1
This file was deleted.

0 commit comments

Comments
 (0)