Skip to content

Commit

Permalink
Added dev docker compose for dev database (#66)
Browse files Browse the repository at this point in the history
feat: Added docker compose file for local development
  • Loading branch information
Bikram-ghuku committed Jun 3, 2024
1 parent e5ff722 commit acf02fb
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,12 @@ IQPS was originally created by [Shubham Mishra](https://github.com/grapheo12) in
## Development
1. Clone this repository.
2. Start the backend by running `go run .` in the `backend/` directory.
2. For starting the backend:
- Change directory to backend `cd backend`
- Make the env file by copying the template: `cp .env.template .env`
- Fill the env variable and set `DB_HOST=localhost` for running locally for development
- Start the DB by running `docker compose -f docker-compose.dev.yaml up -d`
- Start the Go backend by running `go run .`
3. Set up the frontend by running `pnpm install` and then `pnpm start` in the `frontend/` directory.
4. Profit.

Expand All @@ -74,6 +79,11 @@ Environment variables can be set using a `.env` file. Use the `.env.template` fi
- `DB_PATH`: Path to the database file to use.
- `STATIC_FILES_URL`: The base URL for the static files (PDFs).
- `QPS_PATH`: The local path on the server to store question paper PDFs.
- `DB_NAME`: The name for your database.
- `DB_HOST`: `localhost` if using local postgres server or set your **own** database host address.
- `DB_PORT`: `5432` if using local postgres server, or set to your **own** database port.
- `DB_USER`: The access username for database.
- `DB_PASSWORD`: The access password corressponding to the user.

#### Frontend
- `VITE_BACKEND_URL`: The IQPS backend URL. Use `http://localhost:5000` in development.
Expand Down
17 changes: 17 additions & 0 deletions backend/docker-compose.dev.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
services:
database-dev:
image: postgres
restart: always
environment:
- POSTGRES_USER=${DB_USER}
- POSTGRES_PASSWORD=${DB_PASSWORD}
- POSTGRES_DB=${DB_NAME}
- PGPORT=${DB_PORT}
- PGHOST=${DB_HOST}
healthcheck:
test: ["CMD", "pg_isready", "-U", "postgres"]
interval: 5s
timeout: 3s
retries: 20
ports:
- "${DB_PORT}:${DB_PORT}"

0 comments on commit acf02fb

Please sign in to comment.