Skip to content

Commit

Permalink
Update docs for open sourcing the app (#611)
Browse files Browse the repository at this point in the history
  • Loading branch information
aliciapaz authored Oct 11, 2024
1 parent e53dc82 commit 47beab4
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 100 deletions.
31 changes: 19 additions & 12 deletions .dockerdev/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Docker for Development
# Docker for Development 🐳

Source: [Ruby on Whales: Dockerizing Ruby and Rails development](https://evilmartians.com/chronicles/ruby-on-whales-docker-for-ruby-rails-development).

Expand All @@ -16,18 +16,25 @@ You can install `dip` as Ruby gem:
gem install dip
```

## Provisioning
## Setup

1. Build image: `dip build`
2. Install yarn packages: `dip yarn install --ignore-engines`
3. Install gems: `dip bundle install`
4. Create databases: `dip rails db:create` and then `dip rails db:create RAILS_ENV=test`
5. Enable postgis extensions
`dip psql`
When prompted for a password, enter: `postgres`
Once inside the psql console, run
`CREATE EXTENSION postgis;`
`exit`
7. Run `dip rake db:gis:setup`
8. Run migrations: `dip rails db:migrate`
9. Seed db: `dip rails db:seed`
10. Finally, start the container with `dip up`

11. Wait until everything is up and then open a browser in port 3000

When using Dip it could be done with a single command:

```sh
dip provision
```

## Running

dip rails s
```

## Developing with Dip

Expand Down
23 changes: 0 additions & 23 deletions .dockerdev/compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,13 @@ x-backend: &backend
- rails_cache:/app/tmp/cache
- assets:/app/public/assets
- node_modules:/app/node_modules
- packs:/app/public/packs
- packs-test:/app/public/packs-test
- history:/usr/local/hist
- ./.psqlrc:/root/.psqlrc:ro
- ./.bashrc:/root/.bashrc:ro
environment: &backend_environment
<<: *env
REDIS_URL: redis://redis:6379/
DATABASE_URL: postgis://postgres:postgres@postgres:5432
WEBPACKER_DEV_SERVER_HOST: webpacker
MALLOC_ARENA_MAX: 2
WEB_CONCURRENCY: ${WEB_CONCURRENCY:-1}
BOOTSNAP_CACHE_DIR: /usr/local/bundle/_bootsnap
Expand All @@ -59,8 +56,6 @@ services:
ports:
- '3000:3000'
depends_on:
webpacker:
condition: service_started
sidekiq:
condition: service_started

Expand Down Expand Up @@ -95,22 +90,6 @@ services:
timeout: 3s
retries: 30

webpacker:
<<: *app
command: bundle exec ./bin/webpack-dev-server
ports:
- '3035:3035'
volumes:
- ..:/app:cached
- bundle:/usr/local/bundle
- node_modules:/app/node_modules
- packs:/app/public/packs
- packs-test:/app/public/packs-test
environment:
<<: *env
WEBPACKER_DEV_SERVER_HOST: 0.0.0.0
YARN_CACHE_FOLDER: /app/node_modules/.yarn-cache

volumes:
bundle:
node_modules:
Expand All @@ -119,6 +98,4 @@ volumes:
postgres:
redis:
assets:
packs:
packs-test:

4 changes: 4 additions & 0 deletions .env.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
OVERMIND_PROCFILE=Procfile.dev
HIVEMIND_PROCFILE=Procfile.dev
APP_HOST=http://localhost
PORT=3000
3 changes: 3 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,8 @@ GEM
net-smtp (0.5.0)
net-protocol
nio4r (2.7.3)
nokogiri (1.16.5-aarch64-linux)
racc (~> 1.4)
nokogiri (1.16.5-arm64-darwin)
racc (~> 1.4)
nokogiri (1.16.5-x86_64-darwin)
Expand Down Expand Up @@ -585,6 +587,7 @@ GEM
zeitwerk (2.6.16)

PLATFORMS
aarch64-linux
arm64-darwin-20
arm64-darwin-21
arm64-darwin-23
Expand Down
112 changes: 47 additions & 65 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,80 +1,62 @@
# GIVING CONNECTION
# Giving Connection

### Installation

To run this project firstly you will need to install the following,
considering you already have Ruby 3.0.2 and Homebrew installed:

Install postgres
> brew install postgres
Install postgis
> brew install postgis
Install cmake
> brew install cmake
Install hivemind
> brew install hivemind
Install redis
> brew install redis
Install gem bundle
> bundle install
Install webpack
> npm install webpack-dev-server -g
> yarn install
Connecting nonprofits with communities in Nashville and Atlantic City (for now!).

### Credentials
### Stack
- Ruby on Rails 6.1.x
- Ruby 3.1.x
- Postgres and Postgis
- Hotwire
- Tailwind CSS
- jsbundling and cssbundling

To have access to the credentials you must:
- Add master.key file inside config folder
- Add secret key to the file

### Set-up

To set the project you will need the following commands:

Bundle required gems
> bundle install
Create database
> rails db:create
Migrate database
> rails db:migrate
If your migration fails due to 'type "geography" does not exist' do the following:

Associate postgres database with postgis:

Run postgres:
> psql postgres
### Installation

Inside of postgres command line:
> \c giving_connection_development;
1. Requirements
- Bundler (`gem install bundler`)
- Redis
- cmake

> CREATE EXTENSION Postgis;
2. Clone the repository: `git clone xxxx`
3. Install dependencies: `bundle install` and `yarn install`

> exit
### Setup
1. Create database: `rails db:create`
2. Associate postgres database with postgis:
- Run postgres: `psql -d giving_connection_development`
- Inside of postgres command line, run
```
CREATE EXTENSION IF NOT EXISTS postgis;
exit
```
- Run `rake db:gis:setup`
3. Start redis with `redis-server`
4. Run `rails db:migrate` and `rails db:seed`
5. Run `bin/dev` to start the server
6. Visit `localhost:3000` in your browser

### Populate database
For running the app with Docker, check out the [Docker README](.dockerdev/README.md)

> rails db:seed
### Contributing

### Run server
1. Fork the repository
2. Create a new branch
3. Make your changes
4. Push your changes to your fork
5. Create a pull request

> redis-server
#### Linting and Formatting

> rails s or hivemind
We use Standard Ruby for linting and formatting.

### Troubleshooting
Run `bundle exec rubocop` to check all ruby files
Run `bundle exec rubocop -a` to auto-correct offenses

If you get the following error on local
### Testing
Run tests with `bundle exec rspec`

>PG::UndefinedFunction: ERROR: function pg_search_dmetaphone(text) does not exist
#### System specs

Try performing a database reset. Do not use ´rails db:reset´ but run ´rails db:drop´ ´rails db:create´, ´rails db:migrate´ and ´rails db:seed´ instead.
- Headless is the default config. If you want to see the browser you can run the following command: `HEADLESS=false bundle exec rspec`
- If you want to pause the execution you can use `pause` inside an `it` statement.
- If you want to see the logs you can use `:log`, e.g. `it "xxx", :log do`

0 comments on commit 47beab4

Please sign in to comment.