From 8b6b30b93b13a9a6bbcb3ac35261ea1b8f055325 Mon Sep 17 00:00:00 2001 From: Kev Wang Date: Fri, 14 Oct 2022 18:53:49 -0700 Subject: [PATCH] Add instructions to setup.md and move db data to docker volume --- build/docker-compose.yml | 6 +++++- setup.md | 13 ++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/build/docker-compose.yml b/build/docker-compose.yml index 5ea0dab8d..ab9dbdffb 100644 --- a/build/docker-compose.yml +++ b/build/docker-compose.yml @@ -41,7 +41,7 @@ services: image: postgres:12.6 volumes: - ./bt_main.dump:/bt_main.dump - - ./postgres-data:/var/lib/postgresql/data + - postgres-data:/var/lib/postgresql/data ports: - "5432:5432" environment: @@ -49,3 +49,7 @@ services: - "POSTGRES_USER=bt" - "POSTGRES_PASSWORD=bt" +volumes: + postgres-data: + + # docker-compose up --build backend \ No newline at end of file diff --git a/setup.md b/setup.md index cbef7b5f2..0a253ab96 100644 --- a/setup.md +++ b/setup.md @@ -8,10 +8,17 @@ Docker is a container platform and Docker Compose is a a tool for defining and r Docker applications. Make sure you have both install on your computer before you start. Docker Compose comes with Docker in most cases (such as MacOS). -To run Berkeleytime, make sure this repo is clone. From the top level, first download the development -Postgres data with `make init`. This will create a folder `build/postgres-data`. Don't try to push it to Github - -its a local copy of the production data. Note: If you recieve the error `make: wget: No such file or directory`, make sure you have `wget` installed. +### Seeding the Local Database +To run Berkeleytime, make sure this repo is cloned. From the top level, first download the development +Postgres data: +1. `make postgres` - start up the postgres container +2. `curl -O https://storage.googleapis.com/berkeleytime/public/bt_seed.sql.gz` - download the database as a GZip file +3. `gzip -d bt_seed.sql.gz` - unzip this file +4. `cat bt_seed.sql | docker exec -i bt_postgres psql -U bt -d bt_main` - see Postgres container with the data. +Before starting the server, make sure the `DATABASE_URL` entry in your `.env.dev` is `postgres://bt:bt@postgres:5432/bt_main` so that the backend connects to the local DB. + +### Starting the local server To boot the services, run `make up`. This will boot 6 containers (redis, postgres, nginx, Django, Node.js). Wait for both Postgres and Django to be running before you proceed. Django will say