diff --git a/.gitignore b/.gitignore index efcb4365403..18d6f95f197 100644 --- a/.gitignore +++ b/.gitignore @@ -75,6 +75,7 @@ Vagrantfile package-lock.json browsers.json +Brewfile.lock.json saml_*.txt saml_*.shr diff --git a/Brewfile b/Brewfile new file mode 100644 index 00000000000..fae834dac18 --- /dev/null +++ b/Brewfile @@ -0,0 +1,6 @@ +brew 'postgresql@13' +brew 'redis' +brew 'node@16' +brew 'yarn' +brew 'openssl@1.1' +cask 'chromedriver' diff --git a/bin/setup b/bin/setup index 0b637303757..e8431e847b2 100755 --- a/bin/setup +++ b/bin/setup @@ -50,11 +50,20 @@ Dir.chdir APP_ROOT do run "cp pwned_passwords/pwned_passwords.txt.sample pwned_passwords/pwned_passwords.txt" puts "\n== Installing dependencies ==" + brew_installed = system "brew -v 2>&1" + run "brew bundle" if brew_installed run "gem install bundler --conservative" run 'gem install foreman --conservative && gem update foreman' run "bundle check || bundle install --without deploy production" run "yarn install" + puts "\n== Stopping running services to ensure clean start ==" + run "brew services stop --all" if brew_installed + + puts "\n== Starting services ==" + run "brew services start redis" if brew_installed + run "brew services start postgresql@13" if brew_installed + puts "\n== Preparing database ==" run 'make clobber_db' diff --git a/docs/local-development.md b/docs/local-development.md index e3acf25b0d6..175d0bd6a86 100644 --- a/docs/local-development.md +++ b/docs/local-development.md @@ -7,51 +7,52 @@ This installation method is meant for those who are familiar with setting up loc We recommend using [Homebrew](https://brew.sh/), [rbenv](https://github.com/rbenv/rbenv), [nvm](https://github.com/nvm-sh/nvm) or other version management tooling to install the below dependencies; while we don't anticipate changing these frequently, this will ensure that you will be able to easily switch to different versions as needed. ### Dependencies -1. To start, make sure you have the following dependencies installed and a working development environment: -- Ruby ~> 3.2.0 -- [PostgreSQL](http://www.postgresql.org/download/) -- [Redis 7+](http://redis.io/) -- [Node.js v16](https://nodejs.org) -- [Yarn](https://yarnpkg.com/en/) -- [chromedriver](https://formulae.brew.sh/cask/chromedriver) +Installing the packages differs slightly if you're on a macOS or a different OS. -2. You will need to install openssl version 1.1: +If using macOS: -- Run `brew install openssl@1.1` +1. Install [rbenv](https://github.com/rbenv/rbenv) (lets you install and switch between different versions of Ruby) +1. Install Ruby. Choose the version [in the `.ruby-version` file](../.ruby-version) +1. Skip to the [set up local environment section](#set-up-local-environment). Your other dependencies will be installed in that step. -3. Test that you have Postgres and Redis running. +If not using macOS: - For example, if you've installed with Homebrew, you can start the services like this: +1. To start, make sure you have the following dependencies installed and a working development environment: - ``` - $ brew services start redis - $ brew services start postgresql - ``` + - [rbenv](https://github.com/rbenv/rbenv) (lets you install and switch between different versions of Ruby) + - Ruby. Choose the version [in the `.ruby-version` file](../.ruby-version) + - [PostgreSQL](http://www.postgresql.org/download/) + - [Redis 7+](http://redis.io/) + - [Node.js v16](https://nodejs.org) + - [Yarn](https://yarnpkg.com/en/) + - [chromedriver](https://formulae.brew.sh/cask/chromedriver) - To confirm the services are running properly, run: - ``` - $ brew services list - ``` +1. You will need to install openssl version 1.1: -4. Run the following command to set up your local environment: + - Run `brew install openssl@1.1` - ``` - $ make setup - ``` +1. Test that you have Postgres and Redis running. - This command copies sample configuration files, installs required gems - and sets up the database. Check out our Makefile commands to learn more about what this command does: https://github.com/18F/identity-idp/blob/main/Makefile +1. Continue to the [set up local environment section](#set-up-local-environment). - Note: If you didn't explicitly install `openssl@1.1` in Step 2 above and you use a M1 Mac, you may see an error on this step. Homebrew works differently on a M1 Mac, so specifying the version is necessary for the make script to work, but may still work on x86. +### Set up local environment -5. Now that you have you have everything installed, you can run the following command to start your local server: +1. Run the following command to set up your local environment: - ``` - $ make run - ``` + ``` + $ make setup + ``` + + This command copies sample configuration files, installs required gems and brew packages (if using macOS), and sets up the database. Check out our [Makefile commands](../Makefile) to learn more about what this command does. + +1. Now that you have you have everything installed, you can run the following command to start your local server: + + ``` + $ make run + ``` - You should now be able to go to open up your favorite browser, go to `localhost:3000` and see your local development environment running. + You should now be able to go to open up your favorite browser, go to `localhost:3000` and see your local development environment running. ### Running tests locally