|
1 | 1 | This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app). |
2 | 2 |
|
3 | | -## Getting Started |
| 3 | +# Getting started |
4 | 4 |
|
5 | | -First, prepare the development server: |
| 5 | +Requirements |
| 6 | +- Docker & Docker Compose |
| 7 | +- PowerShell (commands below use PowerShell syntax) |
6 | 8 |
|
7 | | -```bash |
8 | | -npx prisma generate |
| 9 | +Quick start: |
| 10 | + |
| 11 | +```powershell |
| 12 | +# Run all services, install dependencies and apply migrations |
| 13 | +docker compose up --build |
9 | 14 | ``` |
10 | 15 |
|
11 | | -Then run the dev server: |
| 16 | +Open http://localhost:3000 to see the results. |
12 | 17 |
|
13 | | -```bash |
14 | | -npm run dev |
| 18 | + |
| 19 | +Services one by one start: |
| 20 | + |
| 21 | +1) Apply migrations (one-off): |
| 22 | + |
| 23 | +```powershell |
| 24 | +# Run the migrate service: installs dependencies and runs 'npx prisma migrate deploy' |
| 25 | +docker compose -f .\docker-compose.yml run --rm migrate |
| 26 | +``` |
| 27 | + |
| 28 | +2) Start the app and database in the background: |
| 29 | + |
| 30 | +```powershell |
| 31 | +docker compose -f .\docker-compose.yml up -d |
15 | 32 | ``` |
16 | 33 |
|
17 | | -Open [http://localhost:3000](http://localhost:3000) to see the results. |
| 34 | +3) Tail app logs: |
| 35 | + |
| 36 | +```powershell |
| 37 | +docker compose -f .\docker-compose.yml logs --follow --tail 200 app |
| 38 | +``` |
18 | 39 |
|
| 40 | +Useful commands |
19 | 41 |
|
| 42 | +```powershell |
| 43 | +# Check service status |
| 44 | +docker compose -f .\docker-compose.yml ps |
20 | 45 |
|
21 | | -## The project features so far |
| 46 | +# Run migrate manually (one-off / CI) |
| 47 | +docker compose -f .\docker-compose.yml run --rm migrate |
| 48 | +
|
| 49 | +# List tables in the Postgres database |
| 50 | +docker compose -f .\docker-compose.yml exec postgres psql -U admin -d boardsy -c "\dt" |
| 51 | +
|
| 52 | +# Stop and remove containers and volumes (including node_modules volume) |
| 53 | +docker compose -f .\docker-compose.yml down --volumes |
| 54 | +``` |
22 | 55 |
|
23 | | -Below is a directory graph of the actual project structure under `src/`, followed by a breakdown of each route and its Server Actions: |
| 56 | +Why there is a `migrate` service? |
| 57 | + |
| 58 | +- The `migrate` service is a one-off container that installs project dependencies and runs `npx prisma migrate deploy` against the database running in Compose. This avoids running migrations manually on the host. |
| 59 | +- After migrations finish, the `migrate` container exits. This is expected. |
| 60 | + |
| 61 | +About `node_modules` and Windows |
| 62 | + |
| 63 | +- We use a named Docker volume for `node_modules` to avoid common Windows <-> container filesystem issues (for example, `ENOTEMPTY` errors during `npm install`). If something goes wrong, you can remove the volume with `docker compose down --volumes` and restart. |
| 64 | + |
| 65 | +Troubleshooting (common issues) |
| 66 | + |
| 67 | +- Can't reach database (`P1001` / "Can't reach database server at localhost:5432"): make sure services use the internal Compose hostname `postgres`. The compose file in this repo sets `LOCAL_DATABASE_URL` for `app` and `migrate` to use the `postgres` service. |
| 68 | +- `ENOTEMPTY` during `npm install` in the container: handled by using a named `node_modules` volume. If it persists, remove that volume and retry. |
| 69 | + |
| 70 | +Open http://localhost:3000 to see the results. |
| 71 | + |
| 72 | +## Project structure (high level) |
24 | 73 |
|
25 | 74 | ```bash |
26 | 75 | src/ |
|
46 | 95 | └─ types/ |
47 | 96 | └─ global.d.ts # Global type declarations |
48 | 97 | ``` |
49 | | - |
50 | | - |
51 | | - |
52 | | - |
53 | | -## Learn More |
54 | | - |
55 | | -To learn more about Next.js, take a look at the following resources: |
56 | | - |
57 | | -* [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API. |
58 | | -* [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial. |
|
0 commit comments