Skip to content

Commit

Permalink
docs: add documentation for standing up server with pg to README
Browse files Browse the repository at this point in the history
  • Loading branch information
Connor-Bernard committed Feb 20, 2024
1 parent a1ef43c commit e169d51
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 2 deletions.
25 changes: 24 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,2 +1,25 @@
dev:
# These targets were made with unix in mind. If you are not on unix, feel free to update for support.
-include .env
.DEFAULT_GOAL = dev

env:
@export DB_PORT=${DB_PORT}
@export DB_USER=${DB_USER}
@export DB_PASSWORD=${DB_PASSWORD}
@export DB_NAME=${DB_NAME}
@echo 'db environment updated'

dev: env
@yarn run dev

db-migrate: env
bin/rails db:migrate

db-seed: env
bin/rails db:seed

init: env
@command -v yarn > /dev/null 2>&1 || { echo >&2 "please install yarn first"; exit 1; }
bin/rails db:setup
bin/rails db:migrate
bin/rails db:seed
42 changes: 41 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,44 @@
# flextensions
Back end/API for UC Berkeley EECS "Flextensions" software

[![Maintainability](https://api.codeclimate.com/v1/badges/8d99ec9a1784ddba34ac/maintainability)](https://codeclimate.com/github/cs169/flextensions/maintainability) [![Test Coverage](https://api.codeclimate.com/v1/badges/8d99ec9a1784ddba34ac/test_coverage)](https://codeclimate.com/github/cs169/flextensions/test_coverage)
[![Maintainability](https://api.codeclimate.com/v1/badges/8d99ec9a1784ddba34ac/maintainability)](https://codeclimate.com/github/cs169/flextensions/maintainability) [![Test Coverage](https://api.codeclimate.com/v1/badges/8d99ec9a1784ddba34ac/test_coverage)](https://codeclimate.com/github/cs169/flextensions/test_coverage)

## Installation

### Environment Variables

For the environment variables, you will need to configure on your local system (and any deployment machines) the following environment variables:

- DB_PORT (default: 5432)
- DB_USER (default: postgres)
- DB_PASSWORD (default: password)
- DB_NAME (default: postgres)

Changing only the user and password then running `$make env` should be sufficient.

### Postgres Installation

#### MacOS

- `brew install postgresql chromedriver`
- Start postgres if necessary. `brew services start postgresql`

#### Linux/WSL

- `sudo apt install postgresql`
- Create a postgres user.
- `sudo su - postgres` (to get into postgres shell)
- `createuser --interactive --pwprompt` (in postgres shell)
- Save `DB_USER` and `DB_PASSWORD` fields in the `.env` file.
- Start postgres if necessary. `pg_ctlcluster 12 main start`
- Note: if you are using WSL2 on windows, the command to start postgres is `sudo service postgresql start`

### Stand Up Server

In order to stand up the server with [Overmind](https://github.com/DarthSim/overmind) in dev, run:

```bash
make dev
```

*NOTE:* The Overmind binary is stored in `bin/overmind` and needs to be maintained manually.

0 comments on commit e169d51

Please sign in to comment.