Skip to content

Commit

Permalink
Add seed data to local build database (#55)
Browse files Browse the repository at this point in the history
* Setup Docker to run local database and server

* Add seed data

* Add script to load seed data

* Update README with seed data loading instructions and remove automatic seed data loading from entrypoint

* Add proper line endings and update docs

* Add login credentials for local DB

* Change seed docker command to docker compose

---------

Co-authored-by: Jonathan Loh <[email protected]>
  • Loading branch information
Johnwz123 and jloh02 authored Feb 8, 2025
1 parent 636cffb commit a4000a6
Show file tree
Hide file tree
Showing 4 changed files with 2,340 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.sh text eol=lf
32 changes: 31 additions & 1 deletion backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

Ensure you have Docker installed on your local machine.

Navigate to the root of the project directory where the `docker-compose.yml` file is located.
### Setup

Navigate to the root of the `backend` directory where the `docker-compose.yml` file is located.

Build and run the Docker containers:

Expand All @@ -12,6 +14,34 @@ docker-compose up --build

The backend should be running and accessible at `http://localhost:8000`

> Backend admin page is accessible at http://localhost:8000/administration
> Username: dev
> Password: dev
### Seeding the database

To load seed data into the database, run the following command:

```
docker-compose exec backend python treeckle/manage.py loaddata treeckle/treeckle/fixtures/seed_data.json
```

This creates the following user accounts for the frontend:

**Admin**

Email: [email protected]

Password: [email protected]

**Resident**

Email: resident#@capt.com

Password: resident#

where # is any integer between 1-5, i.e. resident1, resident2, resident3...

## Using External PostgreSQL Database

Update the `.env.backend.dev` file with the database credentials.
Expand Down
2 changes: 1 addition & 1 deletion backend/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh

# Keep the line endings for this file as LF.
# Keep the line endings for this file as LF.
# https://stackoverflow.com/questions/44460825/entrypoint-file-not-found

if [ "$DATABASE" = "postgres" ]
Expand Down
Loading

0 comments on commit a4000a6

Please sign in to comment.