95 lines
1.4 KiB
Markdown
95 lines
1.4 KiB
Markdown
# Docker Setup (Backend + Frontend + PostgreSQL)
|
|
|
|
This project provides a complete development environment using **Docker Compose** for:
|
|
|
|
- Backend (Node.js / Express / Prisma)
|
|
- Frontend (Vite / React)
|
|
- PostgreSQL Database
|
|
|
|
---
|
|
|
|
## Project Structure
|
|
|
|
```
|
|
.
|
|
├── backend/
|
|
├── frontend/
|
|
├── docker/
|
|
│ └── dev/
|
|
│ ├── Dockerfile.main
|
|
│ └── Dockerfile.frontend
|
|
├── docker-compose.dev.yml
|
|
```
|
|
|
|
---
|
|
|
|
## Prerequisites
|
|
|
|
Make sure you have installed:
|
|
|
|
- Docker
|
|
- Docker Compose
|
|
|
|
---
|
|
|
|
## Environment Variables
|
|
|
|
### Backend (`backend/.env`)
|
|
|
|
```env
|
|
DATABASE_URL=postgresql://user:password@db:5432/mydb
|
|
PORT=5008
|
|
JWT_SECRET=your_secret_here
|
|
|
|
CORS_ALLOWED_ORIGINS=http://localhost:5173
|
|
|
|
BYTESCALE_SECRET_API_KEY=your_key
|
|
POSTMARK_API_KEY=your_key
|
|
EMAIL_FROM=admin@example.com
|
|
```
|
|
|
|
### Frontend (`frontend/.env`)
|
|
|
|
```env
|
|
VITE_API_URL=http://localhost:5008/api
|
|
```
|
|
|
|
---
|
|
|
|
## Running the Project
|
|
|
|
### Start containers
|
|
|
|
```bash
|
|
docker compose -f docker-compose.dev.yml up --build
|
|
```
|
|
|
|
## Create User
|
|
|
|
```bash
|
|
docker exec -it gg-backend-api-backend-1 node src/utils/createUser.js <name> <password> <role>
|
|
|
|
```
|
|
|
|
---
|
|
|
|
### Stop containers
|
|
|
|
```bash
|
|
docker compose -f docker-compose.dev.yml down
|
|
```
|
|
|
|
---
|
|
|
|
## Database (PostgreSQL)
|
|
|
|
- User: `user`
|
|
- Password: `password`
|
|
- DB: `mydb`
|
|
|
|
Data is persisted using Docker volume:
|
|
|
|
```
|
|
postgres_data
|
|
```
|