diff --git a/.dockerdev/README.md b/.dockerdev/README.md index f487cf7f5..acb6d5b83 100644 --- a/.dockerdev/README.md +++ b/.dockerdev/README.md @@ -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). @@ -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 diff --git a/.dockerdev/compose.yml b/.dockerdev/compose.yml index ac5af1484..de92576a3 100644 --- a/.dockerdev/compose.yml +++ b/.dockerdev/compose.yml @@ -23,8 +23,6 @@ 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 @@ -32,7 +30,6 @@ x-backend: &backend <<: *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 @@ -59,8 +56,6 @@ services: ports: - '3000:3000' depends_on: - webpacker: - condition: service_started sidekiq: condition: service_started @@ -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: @@ -119,6 +98,4 @@ volumes: postgres: redis: assets: - packs: - packs-test: diff --git a/.env.template b/.env.template new file mode 100644 index 000000000..d526459bb --- /dev/null +++ b/.env.template @@ -0,0 +1,4 @@ +OVERMIND_PROCFILE=Procfile.dev +HIVEMIND_PROCFILE=Procfile.dev +APP_HOST=http://localhost +PORT=3000 diff --git a/Gemfile.lock b/Gemfile.lock index e15545fae..00a3f9e24 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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) @@ -585,6 +587,7 @@ GEM zeitwerk (2.6.16) PLATFORMS + aarch64-linux arm64-darwin-20 arm64-darwin-21 arm64-darwin-23 diff --git a/README.md b/README.md index 32b459e45..507791cd8 100644 --- a/README.md +++ b/README.md @@ -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` \ No newline at end of file