Skip to content

Commit 4329d9b

Browse files
committed
first commit
0 parents  commit 4329d9b

217 files changed

Lines changed: 27420 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.dockerignore

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# 依赖
2+
node_modules
3+
4+
# 构建产物
5+
.next
6+
out
7+
dist
8+
9+
# 开发文件
10+
*.log
11+
npm-debug.log*
12+
13+
# 环境变量
14+
.env
15+
.env.*
16+
!.env.example
17+
18+
# Git
19+
.git
20+
.gitignore
21+
22+
# IDE
23+
.idea
24+
.vscode
25+
*.swp
26+
*.swo
27+
28+
# Docker
29+
Dockerfile*
30+
docker-compose*
31+
.dockerignore
32+
33+
# 其他
34+
README.md
35+
AGENTS.md
36+
.github
37+
38+
# uploads
39+
data/uploads
40+
41+
# prisma generated
42+
src/generated/prisma

.env.example

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# 正常 Docker 安装不需要预先配置 DATABASE_URL/JWT_SECRET/SITE_URL。
2+
# 首次访问 /install 后会把数据库连接和应用密钥写入 data/config.json。
3+
#
4+
# 下面三个变量只用于开发调试:
5+
# DATABASE_URL="postgresql://user:password@localhost:5432/memoir"
6+
# JWT_SECRET="replace-with-a-long-random-secret"
7+
# SITE_URL="http://localhost:3000"
8+
9+
# 可选:开发环境把本地 /uploads 代理到已有站点,便于复用线上图片。
10+
# DEV_UPLOADS_ORIGIN="https://example.com"
11+
12+
# 可选:MaxMind GeoLite2 City 数据库路径,用于访问统计的国家/省份/城市占比。
13+
# 需要手动下载 .mmdb 文件并放到对应位置;未配置或文件不存在时地区会记录为未知。
14+
# GEOIP_DATABASE_PATH="data/GeoLite2-City.mmdb"

.github/workflows/docker.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Build and Push Docker Image
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
tags:
8+
- "v*"
9+
pull_request:
10+
branches:
11+
- main
12+
workflow_dispatch:
13+
14+
env:
15+
REGISTRY: ghcr.io
16+
IMAGE_NAME: ${{ github.repository }}
17+
18+
jobs:
19+
build:
20+
runs-on: ubuntu-latest
21+
permissions:
22+
contents: read
23+
packages: write
24+
25+
steps:
26+
- name: Checkout repository
27+
uses: actions/checkout@v4
28+
29+
- name: Set up Docker Buildx
30+
uses: docker/setup-buildx-action@v3
31+
32+
- name: Log in to Container Registry
33+
if: github.event_name != 'pull_request'
34+
uses: docker/login-action@v3
35+
with:
36+
registry: ${{ env.REGISTRY }}
37+
username: ${{ github.actor }}
38+
password: ${{ secrets.GITHUB_TOKEN }}
39+
40+
- name: Extract metadata (tags, labels)
41+
id: meta
42+
uses: docker/metadata-action@v5
43+
with:
44+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
45+
tags: |
46+
type=ref,event=branch
47+
type=ref,event=pr
48+
type=semver,pattern={{version}}
49+
type=semver,pattern={{major}}.{{minor}}
50+
type=sha,prefix=
51+
type=raw,value=latest,enable={{is_default_branch}}
52+
53+
- name: Build and push Docker image
54+
uses: docker/build-push-action@v6
55+
with:
56+
context: .
57+
push: ${{ github.event_name != 'pull_request' }}
58+
tags: ${{ steps.meta.outputs.tags }}
59+
labels: ${{ steps.meta.outputs.labels }}
60+
cache-from: type=gha
61+
cache-to: type=gha,mode=max
62+
platforms: linux/amd64

.gitignore

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.*
7+
.yarn/*
8+
!.yarn/patches
9+
!.yarn/plugins
10+
!.yarn/releases
11+
!.yarn/versions
12+
13+
# testing
14+
/coverage
15+
16+
# next.js
17+
/.next/
18+
/out/
19+
20+
# production
21+
/build
22+
23+
# misc
24+
.DS_Store
25+
*.pem
26+
27+
# debug
28+
npm-debug.log*
29+
yarn-debug.log*
30+
yarn-error.log*
31+
.pnpm-debug.log*
32+
33+
# env files (can opt-in for committing if needed)
34+
.env*
35+
!.env.example
36+
37+
# vercel
38+
.vercel
39+
40+
# typescript
41+
*.tsbuildinfo
42+
next-env.d.ts
43+
44+
# uploads
45+
/data/uploads
46+
*.mmdb
47+
/src/generated/prisma
48+
49+
.codex
50+
AGENTS.MD

AGENTS.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Repository Guidelines
2+
3+
## Project Structure & Module Organization
4+
`src/app` holds App Router pages, layouts, and `/api` route handlers. `src/components` contains reusable feature and UI components, with base primitives under `src/components/ui`. `src/lib` stores shared helpers such as auth, Prisma access, markdown rendering, and validation. `prisma/schema.prisma` defines the data model, while `src/generated/prisma` is generated output and should not be edited manually. Static assets live in `public/`, and one-off migration utilities live in `scripts/`.
5+
6+
## Build, Test, and Development Commands
7+
`bun install` installs dependencies. `bun dev` starts the local server on `http://localhost:3000`. `bun run build` creates a production build and catches many App Router or environment issues early. `bun run lint` runs the repository ESLint rules. `bunx prisma db push` syncs schema changes to the local database, and `bunx prisma generate` regenerates the Prisma client after model updates.
8+
9+
## Coding Style & Naming Conventions
10+
Use TypeScript with strict mode and follow the formatting already present in the touched file; `bun run lint` is the final check. Use `PascalCase` for React components such as `CommentForm.tsx`, `camelCase` for functions and variables, and lowercase route segment names under `src/app`. Prefer the `@/` path alias over deep relative imports. Keep generated Prisma files unchanged unless the source schema changes.
11+
12+
## Testing Guidelines
13+
There is no dedicated automated test suite yet. Treat `bun run lint` as the minimum quality gate and manually verify affected flows before merging. Changes touching articles, comments, admin pages, uploads, or Prisma schema should include a short regression checklist in the pull request. If automated tests are introduced later, place them near the feature or in a local `__tests__/` directory and use `*.test.ts` or `*.test.tsx`.
14+
15+
## Commit & Pull Request Guidelines
16+
Recent history mostly follows short Conventional Commit messages, commonly `feat: 中文描述`. Keep that pattern for new commits, for example `fix: 修复评论筛选`. Pull requests should summarize scope, list schema or `.env` changes, link related issues, and include screenshots for UI changes. This repository builds Docker images through `.github/workflows/docker.yml`, so ensure the branch still builds before requesting review.
17+
18+
## Configuration & Deployment Notes
19+
Required environment variables include `DATABASE_URL`, `JWT_SECRET`, and `SITE_URL`. `SITE_URL` must be valid in production because it is used for canonical URLs, Open Graph metadata, sitemap generation, `robots.txt`, and feed output.

Dockerfile

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
FROM oven/bun:1 AS base
2+
WORKDIR /app
3+
4+
FROM base AS deps
5+
COPY package.json bun.lock* ./
6+
COPY prisma ./prisma/
7+
RUN bun install --frozen-lockfile
8+
9+
FROM base AS builder
10+
COPY --from=deps /app/node_modules ./node_modules
11+
COPY . .
12+
13+
RUN bunx prisma generate
14+
15+
ENV NEXT_TELEMETRY_DISABLED=1
16+
ENV DATABASE_URL="postgresql://placeholder:placeholder@localhost:5432/placeholder"
17+
RUN bun run build
18+
19+
FROM oven/bun:1-slim AS runner
20+
WORKDIR /app
21+
22+
ENV NODE_ENV=production
23+
ENV NEXT_TELEMETRY_DISABLED=1
24+
25+
RUN groupadd --system --gid 1001 nodejs && \
26+
useradd --system --uid 1001 --gid nodejs nextjs
27+
28+
COPY --from=builder /app/public ./public
29+
COPY --from=builder /app/prisma ./prisma
30+
COPY --from=builder /app/prisma.config.ts ./prisma.config.ts
31+
32+
RUN mkdir .next && chown nextjs:nodejs .next
33+
34+
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
35+
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
36+
37+
RUN mkdir -p data/uploads && chown -R nextjs:nodejs data
38+
39+
USER nextjs
40+
41+
EXPOSE 3000
42+
43+
ENV PORT=3000
44+
ENV HOSTNAME="0.0.0.0"
45+
46+
CMD ["bun", "server.js"]

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2026 shiyu
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

0 commit comments

Comments
 (0)