Skip to content

Commit 15a3459

Browse files
Updated README.md with instructions on how to use docker local + prod environments.
1 parent 594c756 commit 15a3459

File tree

1 file changed

+60
-28
lines changed

1 file changed

+60
-28
lines changed

README.md

Lines changed: 60 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,89 @@
1-
# Codebuilder Webapp
1+
# Codebuilder Frontend
22

33
[![Deploy Production Docker Container](https://github.com/codebuilderinc/codebuilder-frontend/actions/workflows/deploy-docker.yml/badge.svg)](https://github.com/codebuilderinc/codebuilder-frontend/actions/workflows/deploy-docker.yml)
44

5+
Next.js frontend for Codebuilder.
56

6-
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).
7+
## Environment Files
78

8-
## Getting Started
9+
- `pnpm dev` (Next.js dev server) loads environment variables in this order:
10+
- `.env.local` (preferred for local-only overrides)
11+
- `.env`
12+
- Docker Compose loads `.env` because `docker-compose.yml` explicitly uses `env_file: ./.env`.
913

10-
First, setup your mysql database and edit the .env.example file.
14+
Important: inside Docker, Postgres must be reached via `db:5432` (service name + container port), not `localhost`.
1115

12-
```bash
13-
cp .env.example .env.local
16+
## Commands
17+
18+
Run any command as:
19+
20+
```bash
21+
pnpm <command>
1422
```
1523

16-
Run the development server:
24+
List all available commands:
1725

1826
```bash
19-
npm run dev
20-
# or
21-
yarn dev
22-
# or
23-
pnpm dev
24-
# or
25-
bun dev
27+
pnpm run
2628
```
2729

28-
Build the production Docker container:
30+
### Core
31+
2932
```bash
30-
docker run -d --network host -p 3000:3000 --env-file .env --name codebuilder-webapp codebuilder-webapp:latest
33+
pnpm dev
34+
pnpm build
35+
pnpm build:static
36+
pnpm start
37+
pnpm lint
3138
```
3239

33-
Note: The production website will automatically build & deploy through a GH action anytime a push is made to main.
40+
- `dev`: Start Next.js dev server (Turbopack).
41+
- `build`: Production build.
42+
- `build:static`: Static export build (only if export mode is supported).
43+
- `start`: Run production server from `.next` build output.
44+
- `lint`: Run linting.
3445

35-
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
46+
### Local DB (for development)
3647

37-
You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.
48+
```bash
49+
pnpm dev:db:start
50+
pnpm dev:db:stop
51+
pnpm dev:db:prepare
52+
```
53+
54+
- `dev:db:start`: Start the local Postgres container using `docker-compose.local.yml`.
55+
- `dev:db:stop`: Stop/remove the local Postgres container.
56+
- `dev:db:prepare`: Create the Prisma shadow database inside Postgres (safe to re-run).
3857

39-
This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel.
58+
### Prisma
4059

41-
## Learn More
60+
```bash
61+
pnpm prisma:migrate
62+
pnpm prisma:generate
63+
pnpm prisma:studio
64+
```
4265

43-
To learn more about Next.js, take a look at the following resources:
66+
- `prisma:migrate`: Run Prisma migrations in development mode.
67+
- `prisma:generate`: Regenerate Prisma client.
68+
- `prisma:studio`: Launch Prisma Studio.
4469

45-
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
46-
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
70+
### Docker (Production / Server)
4771

48-
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome!
72+
```bash
73+
pnpm prod:up
74+
pnpm prod:down
75+
pnpm prod:logs
76+
pnpm prod:reset
77+
```
4978

50-
## Deploy on Vercel
79+
- `prod:up`: Rebuild and redeploy the Docker Compose stack (frontend + db). This is the main manual deploy command.
80+
- `prod:down`: Stop/remove the stack containers and networks (does not delete external volumes unless `--volumes` is used).
81+
- `prod:logs`: Tail logs for the `frontend` service.
82+
- `prod:reset`: WARNING: brings the stack down with `--volumes` and starts fresh (will wipe DB data).
5183

52-
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
84+
## CI / Deployment
5385

54-
Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.
86+
On push to `main`, the GitHub Actions workflow rebuilds and redeploys the Docker services on the self-hosted runner.
5587

5688
## Activity
5789
![Alt](https://repobeats.axiom.co/api/embed/f01e046c8b7d8a2c653ee751c55c2345072872c4.svg "Repobeats analytics image")

0 commit comments

Comments
 (0)