From 437662946d27e4bda2cbc878f4e0a5ad943d0d1c Mon Sep 17 00:00:00 2001 From: Dmitry L Rocha Date: Sun, 29 Sep 2024 10:44:56 -0400 Subject: [PATCH] Update README.md and fix setup to work with or without docker --- README.md | 53 +++++++++++++++++++++++++++++++++++---- bin/setup | 5 ---- docker-compose.yml.sample | 6 ++++- 3 files changed, 53 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 1bcf951..39d5cf4 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,8 @@ Keeps track of membership to a society. ## Getting started +(Docker version follows). + ### Prerequisites * Ruby (See `.ruby-version` for the version you have to install) @@ -12,7 +14,15 @@ Keeps track of membership to a society. ### Set-up -Clone this repository and run the following from the working directory: +Install dependencies, copy `config/database.yml.sample` to `config/database.yml`: + +``` +cp config/database.yml.sample config/database.yml +``` + +Edit `config/database.yml` according to your setup. + +Then run: bin/setup yarn install @@ -31,14 +41,47 @@ And yarn build --watch -## Testing - -This codebase started out without tests. Some are being introduced over time. - To run tests: bundle exec rspec +## Getting started (using docker) + +Install [docker](https://docs.docker.com/engine/install/) and +[docker compose](https://docs.docker.com/compose/install/). + +Copy files: + +``` +cp docker-compose.yml.sample docker-compose.yml +cp config/database.yml.docker config/database.yml +``` + +Edit them according to your setup. + +NOTE: leave `RAILS_ENV: test` or change it to `RAILS_ENV: development` in +`docker-compose.yml`. Either value does the same. + +Then run: + +``` +docker compose pull +docker compose build +docker compose run --rm app ./bin/setup +``` + +To start: + +``` +docker compose up app assets +``` + +To run the tests: + +``` +docker compose run --rm app bundle exec rspec +``` + ## Voting Voting can be enabled by setting a `VOTE_URL_TEMPLATE` environment variable. diff --git a/bin/setup b/bin/setup index 027dd23..c246fda 100755 --- a/bin/setup +++ b/bin/setup @@ -17,11 +17,6 @@ FileUtils.chdir APP_ROOT do system! "gem install bundler --conservative" system("bundle check") || system!("bundle install") - puts "\n== Copying sample files ==" - unless File.exist?("config/database.yml") - FileUtils.cp "config/database.yml.sample", "config/database.yml" - end - puts "\n== Preparing database ==" system! "bin/rails db:prepare" diff --git a/docker-compose.yml.sample b/docker-compose.yml.sample index 2b2f01a..3e17318 100644 --- a/docker-compose.yml.sample +++ b/docker-compose.yml.sample @@ -10,7 +10,7 @@ services: expose: - "5432" - app: + assets: &ruby build: context: . args: @@ -23,6 +23,10 @@ services: - AUTH_NAME=secretary - AUTH_PASSWORD=password working_dir: /app + command: yarn build --watch + + app: + <<: *ruby command: bundle exec falcon serve -n 2 -b 'http://0.0.0.0:3000' ports: - "3000:3000"