Skip to content

Commit

Permalink
Updated Makefile and updated README.md instrctns
Browse files Browse the repository at this point in the history
Updated `Makefile` and updated README.md instructions
  • Loading branch information
ericdrosas87 authored and Blake Mason committed Apr 18, 2024
1 parent 6035f65 commit fb78ee9
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 3 deletions.
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ clean:
clean-images:
docker images prune

# Requires argument `dbname` to specify the name of the new DB, usage: `make local-db dbname=my_db`
# Requires argument `dbname` to specify the name of the new DB, usage: `make local-db dbname=my_db dbfile=mydb.sql`
# Requires argument `dbfile` to specify the name of the DB dump file to recreate, usage: `make local-db dbname=my_db dbfile=mydb.sql`
local-db:
cd db && docker exec --workdir / investigations-api-postgres-1 psql -U craft -c "create database $(dbname);"
cd db && docker exec --workdir / investigations-api-postgres-1 psql -U craft -d $(dbname) -f inv_mar.sql
cd db && docker exec --workdir / investigations-api-postgres-1 psql -U craft -d $(dbname) -f $(dbfile)
echo "\n\n\n\nDon't forget to update your docker-compose-local-db.yaml with the DB name: $(dbname)"

db-list:
Expand Down
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,36 @@ This project was created with Docker version 20.10.5.

## Set up and run the project locally

#### Make scripts

---
To list your local DBs:

`make db-list`

---
To list the databases sitting around in the `prod` environment:

`make cloud-db-list`

---
To export a `prod` database to the `gs://release_db_sql_files/investigations/` bucket:

`make cloud-db-export dbname=prod_db`

* The argument `dbname` is required and should be one of the databases listed from `make cloud-db-list`
* Once you download the DB dump file, move it to the `./db/` folder
---
To recreate a local DB from a dump file located within `./db/`:

`make local-db dbname=my_new_local_db dbfile=prod.sql`

* The argument `dbname` is required and will be the name of the newly created database
* The argument `dbfile` is required and should be the name of the DB file to recreate, this file _must_ be in the `./db/` folder
---
#### Deprecated workflow

0. Uncomment the `COPY` line in `./db/Dockerfile`
1. Install [Docker](https://docs.docker.com/get-docker/)
2. Clone this repository
3. Add a .env file (based on .env.sample) and provide values appropriate to your local dev environment
Expand Down
3 changes: 2 additions & 1 deletion db/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
FROM postgres:13-alpine

COPY db.sql /docker-entrypoint-initdb.d/db.sql
# Commented out so that the Makefile DB scripts can do their thing
# COPY db.sql /docker-entrypoint-initdb.d/db.sql

0 comments on commit fb78ee9

Please sign in to comment.