From ea0e78d62774d9942a10b554363840e206f27d3e Mon Sep 17 00:00:00 2001 From: Adan Amarillas Date: Fri, 25 May 2018 00:41:19 -0700 Subject: [PATCH 1/3] Begin preparing native setup instructions --- README.md | 2 +- config/native_setup_database.yml | 42 +++++++++++++++++++++ docs/setup/native_setup.md | 65 ++++++++++++++++++++++++++++++++ 3 files changed, 108 insertions(+), 1 deletion(-) create mode 100644 config/native_setup_database.yml create mode 100644 docs/setup/native_setup.md diff --git a/README.md b/README.md index d3e9a2f8..bd74a1e3 100644 --- a/README.md +++ b/README.md @@ -66,7 +66,7 @@ In order to work on the backend of the **Operation Code** site, you will need to There are three options for local setup: - [Docker](/docs/setup/docker_setup.md) (recommended) -- Native (coming soon) +- [Native](/docs/setup/native_setup.md) - [AWS Virtual Machine](/docs/setup/aws_vm_setup.md) ## Finding An Issue diff --git a/config/native_setup_database.yml b/config/native_setup_database.yml new file mode 100644 index 00000000..1976cdd8 --- /dev/null +++ b/config/native_setup_database.yml @@ -0,0 +1,42 @@ +# PostgreSQL. Versions 9.1 and up are supported. +# +# Install the pg driver: +# gem install pg +# On OS X with Homebrew: +# gem install pg -- --with-pg-config=/usr/local/bin/pg_config +# On OS X with MacPorts: +# gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config +# On Windows: +# gem install pg +# Choose the win32 build. +# Install PostgreSQL and put its /bin directory on your path. +# +# Configure Using Gemfile +# gem 'pg' +# +default: &default + adapter: postgresql + encoding: unicode + # For details on connection pooling, see rails configuration guide + # http://guides.rubyonrails.org/configuring.html#database-pooling + pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> + password: <%= OperationCode.fetch_secret_with name: :postgres_password %> + # user: postgres + # host: <%= ENV['POSTGRES_HOST'].present? ? ENV['POSTGRES_HOST'] : 'operationcode-psql' %> + +development: + <<: *default + database: operationcode_development + username: operationcode_backend + host: localhost + +test: + <<: *default + database: operationcode_test + username: operationcode_backend + +production: + <<: *default + host: <%= ENV['POSTGRES_HOST'].present? ? ENV['POSTGRES_HOST'] : 'operationcode-psql-postgresql' %> + database: operationcode_production + user: opcode_superuser diff --git a/docs/setup/native_setup.md b/docs/setup/native_setup.md new file mode 100644 index 00000000..8c2e2de7 --- /dev/null +++ b/docs/setup/native_setup.md @@ -0,0 +1,65 @@ +# Native Setup + +### Git +Git is a distributed version control system. This is how our code is stored and managed. Git can be frustrating, but it is an essential tool. If you want to learn more about Git, a great resource is [Think Like a Git](http://think-like-a-git.net/). If you find yourself in a real git pickle, see ["Oh, shit, git!"](http://ohshitgit.com/). If you have already installed Git as a part of the Docker Toolbox, you don't need to install it again using the following link. + +* [Install Git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) + +### Not needed right? (I am gonna use "Rakefile") +```markdown +### Make (for Windows only) +Make is a tool which controls the generation of executables and other non-source files of a program from the program's source files. It is a standard part of the GNU library and is included in most distributions of Linux, as well as OSX. Unfortunately, Windows does not have a native make program, so it will need to be installed and added to PATH in order for the command line commands to work. You can use the [GNUWin general installation guide](http://gnuwin32.sourceforge.net/install.html) as a general guide on how to install a GNU package and add it to PATH. + +* [Install Make](http://gnuwin32.sourceforge.net/packages/make.htm) +``` + +### Code Base +You are now ready for the actual **OperationCode Backend** code base. + +* The common practice is to make a copy of the GitHub repository you want to work on (known as `forking` the repo), make your changes, and then request to merge those changes back into the project (known as a `pull request`). +* Forking a repo is done through GitHub's web UI. It can be found in the top right corner of the **OperationCode Backend**'s [GitHub](https://github.com/OperationCode/operationcode_backend) page. + +* The following commands will pull down the source code from your forked repo. +* Make sure to replace `[YOUR-GITHUB-NAME]` with your GitHub name. (example: https://github.com/iserbit/operationcode_backend.git) + +#### Local Development Environment +_Fork the repo first._ +```bash +git clone https://github.com/[YOUR-GITHUB-NAME]/operationcode_backend.git operationcode-upstream +cd operationcode-upstream +git remote add upstream https://github.com/OperationCode/operationcode_backend.git +``` + +1. If **Bundler** is not installed run `gem install bundler` +2. Run `cp native_setup_Gemfile Gemfile` --> All this really does is uncomment the "bcrypt" gem. +3. Run `bundle install` to install all gem dependencies. + +#### Database Setup: +_Install PostgreSQL if needed first._ + +1. Run `cp config/database.yml db/native_setup_database.yml` --> Modify database.yml file for native setup. Is this ok? +2. Run `rake db:create` --> need to create rake task +3. Run `rake db:migrate` --> Need rake task for this. After migrating I can get successful Rails welcome page on localhost:3000 :raised_hands:. +4. Run `rake db:seed` --> **This is where I am getting errors** :sweat_smile: +5. Testing: need to figure out a way to do all of this (stole from docker_setup): `export RAILS_ENV=test && rake db:test:prepare && rake test && rubocop` + +If you run into any `bundle install` issues, run `bundle`. + + +#### Running OperationCode Backend: +The OperationCode Backend has some handy shortcuts built in to make common tasks simple. You can check out the [Makefile](https://github.com/operationcode/operationcode_backend/blob/master/Makefile) to see a full listing of what these shortcuts are and what they do. + +To run the OperationCode Backend simply type: +```bash +rails s +``` + +You can now visit http://localhost:3000 (or run `rake open` (need rake task for this)) and you should see a Rails welcome message! + + +**Not sure what this means... but may be needed to fix seeding issues** +```markdown +In case you used the Docker Toolbox, you might have also installed VirtualBox, which creates its own virtual network adapters. +In that case, the server might be running on that IP address and may not be reachable via localhost, 127.0.0.1 or even 0.0.0.0. +So, you will need to use `netstat` on the command line to figure out the IP address on which the server is bound. +``` From ce2f704b79c7a5698e8f83612755bb3b52703271 Mon Sep 17 00:00:00 2001 From: Adan Amarillas Date: Fri, 25 May 2018 13:39:08 -0700 Subject: [PATCH 2/3] Improve instructions. --- config/native_setup_database.yml | 8 ++----- docs/setup/native_setup.md | 40 +++++++++----------------------- 2 files changed, 13 insertions(+), 35 deletions(-) diff --git a/config/native_setup_database.yml b/config/native_setup_database.yml index 1976cdd8..e97c4a47 100644 --- a/config/native_setup_database.yml +++ b/config/native_setup_database.yml @@ -20,23 +20,19 @@ default: &default # For details on connection pooling, see rails configuration guide # http://guides.rubyonrails.org/configuring.html#database-pooling pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> - password: <%= OperationCode.fetch_secret_with name: :postgres_password %> - # user: postgres - # host: <%= ENV['POSTGRES_HOST'].present? ? ENV['POSTGRES_HOST'] : 'operationcode-psql' %> + host: localhost development: <<: *default database: operationcode_development - username: operationcode_backend - host: localhost test: <<: *default database: operationcode_test - username: operationcode_backend production: <<: *default host: <%= ENV['POSTGRES_HOST'].present? ? ENV['POSTGRES_HOST'] : 'operationcode-psql-postgresql' %> database: operationcode_production user: opcode_superuser + password: <%= OperationCode.fetch_secret_with name: :postgres_password %> diff --git a/docs/setup/native_setup.md b/docs/setup/native_setup.md index 8c2e2de7..f5e81243 100644 --- a/docs/setup/native_setup.md +++ b/docs/setup/native_setup.md @@ -5,14 +5,6 @@ Git is a distributed version control system. This is how our code is stored and * [Install Git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) -### Not needed right? (I am gonna use "Rakefile") -```markdown -### Make (for Windows only) -Make is a tool which controls the generation of executables and other non-source files of a program from the program's source files. It is a standard part of the GNU library and is included in most distributions of Linux, as well as OSX. Unfortunately, Windows does not have a native make program, so it will need to be installed and added to PATH in order for the command line commands to work. You can use the [GNUWin general installation guide](http://gnuwin32.sourceforge.net/install.html) as a general guide on how to install a GNU package and add it to PATH. - -* [Install Make](http://gnuwin32.sourceforge.net/packages/make.htm) -``` - ### Code Base You are now ready for the actual **OperationCode Backend** code base. @@ -30,36 +22,26 @@ cd operationcode-upstream git remote add upstream https://github.com/OperationCode/operationcode_backend.git ``` -1. If **Bundler** is not installed run `gem install bundler` -2. Run `cp native_setup_Gemfile Gemfile` --> All this really does is uncomment the "bcrypt" gem. -3. Run `bundle install` to install all gem dependencies. +1. If [Bundler](https://bundler.io/) is not installed run `gem install bundler`. +2. Run `bundle install` to install all of the gems in your [Gemfile](Gemfile). +3. Download and install [PostgreSQL](https://www.postgresql.org/download/) if you don't have it already. #### Database Setup: -_Install PostgreSQL if needed first._ -1. Run `cp config/database.yml db/native_setup_database.yml` --> Modify database.yml file for native setup. Is this ok? -2. Run `rake db:create` --> need to create rake task -3. Run `rake db:migrate` --> Need rake task for this. After migrating I can get successful Rails welcome page on localhost:3000 :raised_hands:. -4. Run `rake db:seed` --> **This is where I am getting errors** :sweat_smile: -5. Testing: need to figure out a way to do all of this (stole from docker_setup): `export RAILS_ENV=test && rake db:test:prepare && rake test && rubocop` -If you run into any `bundle install` issues, run `bundle`. +1. Run `cp config/database.yml. config/native_setup_database.yml`. +2. Run `bin/rake db:create`. +3. Run `bin/rake db:migrate`. +4. Run `bin/rake db:seed` --> **This is where I am getting errors** :sweat_smile:. +### Testing +1. Run `RAILS_ENV=test rake db:test:prepare`. +2. Run `bin/rake test & rubocop`. #### Running OperationCode Backend: -The OperationCode Backend has some handy shortcuts built in to make common tasks simple. You can check out the [Makefile](https://github.com/operationcode/operationcode_backend/blob/master/Makefile) to see a full listing of what these shortcuts are and what they do. - To run the OperationCode Backend simply type: ```bash rails s ``` -You can now visit http://localhost:3000 (or run `rake open` (need rake task for this)) and you should see a Rails welcome message! - - -**Not sure what this means... but may be needed to fix seeding issues** -```markdown -In case you used the Docker Toolbox, you might have also installed VirtualBox, which creates its own virtual network adapters. -In that case, the server might be running on that IP address and may not be reachable via localhost, 127.0.0.1 or even 0.0.0.0. -So, you will need to use `netstat` on the command line to figure out the IP address on which the server is bound. -``` +You can now visit http://localhost:3000 and you should see the "Yay! You're on Rails!" welcome message. From d25b02b9bcb3babc2f6cb0aeb1b31ab120b90e9f Mon Sep 17 00:00:00 2001 From: William Montgomery <10781353+wimo7083@users.noreply.github.com> Date: Fri, 5 Oct 2018 15:27:33 -0600 Subject: [PATCH 3/3] Update README.md --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 39172b72..930ac272 100644 --- a/README.md +++ b/README.md @@ -66,7 +66,6 @@ Recommended versions of tools used within the repo: - ## Wiki We also have a [wiki](https://github.com/OperationCode/operationcode_backend/wiki) that contains common tutorials, tips, workflows and documentation around how to successfully contribute to, and work within, the operationcode_backend repository.