Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 51 additions & 3 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
# =============================================================================
# Git
# =============================================================================
.git
.gitignore
.gitattributes
.github

# =============================================================================
# Environment & Secrets
# =============================================================================
.env
.env.*
*.key
*.pem

# =============================================================================
# Python
# =============================================================================
__pycache__
*.pyc
*.pyo
Expand All @@ -18,15 +29,52 @@ htmlcov
.venv
venv
env
*.egg-info

# =============================================================================
# Node.js / Frontend
# =============================================================================
node_modules
.next
out
.pnp
.pnp.js
.pnp.cjs
.yarn
*.tsbuildinfo
.eslintcache
.turbo
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# =============================================================================
# Docker
# =============================================================================
Dockerfile
docker-compose.yml
Dockerfile.*
docker-compose*.yml
.dockerignore

# =============================================================================
# IDE & Editor
# =============================================================================
.idea
.vscode
*.swp
*.swo
.claude

# =============================================================================
# Documentation & Tests
# =============================================================================
docs/
tests/
.pre-commit-config.yaml
*.md
.claude
!README.md

# =============================================================================
# CI/CD & Config
# =============================================================================
.pre-commit-config.yaml
.github/
43 changes: 41 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ on:
- "**"

jobs:
cq:
name: Code Quality & Test
python-cq:
name: Python Code Quality
runs-on: ubuntu-latest

if: |
Expand Down Expand Up @@ -40,3 +40,42 @@ jobs:
- run: uv run ruff check . --output-format=github

- run: uv run mypy .

frontend-cq:
name: Frontend Code Quality
runs-on: ubuntu-latest

if: |
(github.event_name == 'push' &&
!contains(github.event.head_commit.message, 'docs:') &&
!contains(github.event.head_commit.message, 'chore:') &&
!contains(github.event.head_commit.message, '[skip ci]')) ||
(github.event_name == 'pull_request' &&
!contains(github.event.pull_request.title, 'docs:') &&
!contains(github.event.pull_request.title, 'chore:') &&
!contains(github.event.pull_request.title, '[skip ci]'))

defaults:
run:
working-directory: frontend

steps:
- uses: actions/checkout@v4

- name: Read .nvmrc
id: nvmrc
run: echo "node_version=$(cat .nvmrc)" >> $GITHUB_OUTPUT

- uses: actions/setup-node@v4
with:
node-version: ${{ steps.nvmrc.outputs.node_version }}
cache: "npm"
cache-dependency-path: frontend/package-lock.json

- run: npm ci

- name: ESLint
run: npm run lint

- name: TypeScript type check
run: npm run typecheck
31 changes: 30 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ dist/
downloads/
eggs/
.eggs/
lib/
/lib/
lib64/
parts/
sdist/
Expand Down Expand Up @@ -218,6 +218,8 @@ CLAUDE.md
node_modules/
.pnp/
.pnp.js
.pnp.cjs
.yarn/

# Next.js
.next/
Expand All @@ -227,6 +229,33 @@ out/
build/
dist/

# TypeScript
*.tsbuildinfo
next-env.d.ts

# Testing
coverage/
.nyc_output/

# Misc
*.pem
.vercel

# Debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*

# Local env files
.env*.local

# Turbo
.turbo

# ESLint
.eslintcache

# =============================================================================
# MomShell Project Specific
# =============================================================================
Expand Down
14 changes: 14 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,17 @@ repos:
language: system
files: ^pyproject\.toml$
pass_filenames: false

- id: frontend-eslint
name: Frontend ESLint
entry: bash -c 'cd frontend && npm run lint'
language: system
files: ^frontend/.*\.(ts|tsx|js|jsx)$
pass_filenames: false

- id: frontend-typecheck
name: Frontend TypeScript check
entry: bash -c 'cd frontend && npm run typecheck'
language: system
files: ^frontend/.*\.(ts|tsx)$
pass_filenames: false
6 changes: 6 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# =============================================================================
# MomShell Backend (Python/FastAPI)
# =============================================================================
# For frontend, see frontend/Dockerfile
# =============================================================================

FROM python:3.11.5-slim-bookworm AS builder

COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/uv
Expand Down
29 changes: 29 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
services:
backend:
build:
context: .
dockerfile: Dockerfile
ports:
- "8000:8000"
environment:
- PYTHONUNBUFFERED=1
env_file:
- .env
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8000/health"]
interval: 30s
timeout: 10s
retries: 3

frontend:
build:
context: ./frontend
dockerfile: Dockerfile
ports:
- "3000:3000"
environment:
- NEXT_PUBLIC_API_URL=http://backend:8000
depends_on:
- backend
restart: unless-stopped
44 changes: 44 additions & 0 deletions frontend/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Dependencies
node_modules

# Build output
.next
out
build
dist

# Git
.git
.gitignore

# IDE
.idea
.vscode
*.swp
*.swo

# Environment
.env
.env.*
!.env.example

# TypeScript build info
*.tsbuildinfo

# Testing
coverage
.nyc_output

# Debug logs
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Docker
Dockerfile
.dockerignore

# Misc
*.md
.eslintcache
.turbo
60 changes: 60 additions & 0 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# syntax=docker/dockerfile:1

FROM node:22-alpine AS base

# =============================================================================
# Dependencies stage
# =============================================================================
FROM base AS deps

RUN apk add --no-cache libc6-compat

WORKDIR /app

COPY package.json package-lock.json ./

RUN npm ci

# =============================================================================
# Build stage
# =============================================================================
FROM base AS builder

WORKDIR /app

COPY --from=deps /app/node_modules ./node_modules
COPY . .

ENV NEXT_TELEMETRY_DISABLED=1

RUN npm run build

# =============================================================================
# Production stage
# =============================================================================
FROM base AS runner

WORKDIR /app

ENV NODE_ENV=production \
NEXT_TELEMETRY_DISABLED=1

RUN addgroup --system --gid 1001 nodejs && \
adduser --system --uid 1001 nextjs

# Copy public folder if it has contents
COPY --from=builder /app/public ./public

# Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static

USER nextjs

EXPOSE 3000

ENV PORT=3000 \
HOSTNAME="0.0.0.0"

CMD ["node", "server.js"]
2 changes: 1 addition & 1 deletion frontend/app/chat/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* 情感陪伴页面
*/

import { CompanionInterface } from '@/components/CompanionInterface';
import { CompanionInterface } from '../../components/CompanionInterface';

export default function ChatPage() {
return <CompanionInterface />;
Expand Down
Loading
Loading