chore(db): add local PostgreSQL Compose setup

This commit is contained in:
2026-09-28 14:25:47 +08:00
parent c33857ffac
commit 99d4a85ece
5 changed files with 50 additions and 12 deletions
+1
View File
@@ -0,0 +1 @@
DATABASE_URL=postgresql://postgres:Aa110011@localhost:5432/fluxent
+1
View File
@@ -30,6 +30,7 @@ pnpm-debug.log*
# env files (can opt-in for committing if needed)
.env*
!.env.example
# typescript
*.tsbuildinfo
+20 -12
View File
@@ -1,21 +1,29 @@
# Next.js template
# Fluxent Web
This is a Next.js template with shadcn/ui.
## 本地开发
## Adding components
To add components to your app, run the following command:
需要已安装 Docker 和 pnpm。在项目目录执行:
```bash
npx shadcn@latest add button
pnpm install
test -f .env.local || cp .env.example .env.local
docker compose up -d
docker compose ps
pnpm db:logs
pnpm drizzle-kit push --force
```
This will place the ui components in the `components` directory.
数据库镜像通过 `registry1.fw.ac.cn/docker.io/` 代理拉取最新的
PostgreSQL Alpine 版本。
## Using components
`pnpm db:logs` 会持续显示数据库日志,可按 `Ctrl-C` 返回终端。数据库停止后仍会保留命名卷中的数据:
To use the components in your app, import them as follows:
```tsx
import { Button } from "@/components/ui/button";
```bash
pnpm db:down
```
如需有意删除数据库及全部数据,执行以下命令。此操作不可恢复:
```bash
docker compose down -v
```
+25
View File
@@ -0,0 +1,25 @@
services:
db:
image: registry1.fw.ac.cn/docker.io/postgres:alpine
restart: unless-stopped
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: Aa110011
POSTGRES_DB: fluxent
ports:
- "127.0.0.1:5432:5432"
volumes:
- fluxent-postgres-data:/var/lib/postgresql
healthcheck:
test:
[
"CMD-SHELL",
'pg_isready -U "$${POSTGRES_USER}" -d "$${POSTGRES_DB}" -h 127.0.0.1 -p 5432',
]
interval: 5s
timeout: 5s
retries: 10
start_period: 10s
volumes:
fluxent-postgres-data:
+3
View File
@@ -7,6 +7,9 @@
"dev": "next dev",
"build": "next build",
"start": "next start",
"db:up": "docker compose up -d --wait",
"db:down": "docker compose down",
"db:logs": "docker compose logs -f db",
"lint": "eslint",
"format": "prettier --write \"**/*.{ts,tsx}\"",
"typecheck": "tsc --noEmit"