Skip to content
Closed
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
49 changes: 43 additions & 6 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,45 @@
# This file specifies which files and directories should be ignored by Docker when building images.
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

.gitignore
.env*
*.log
# Dependencies
node_modules
eslint.config.mjs
Dockerfile
.pnp
.pnp.js

# Local env files
.env
.env.local
.env.development.local
.env.test.local
.env.production.local

# Testing
coverage

# Turbo
.turbo

# Vercel
.vercel

# Build Outputs
.next
out
build
dist


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

# Misc
.DS_Store
*.pem

# IDEs and editors
.vscode
.idea

# Git
.git
17 changes: 5 additions & 12 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,15 @@ name: Build Check

on:
pull_request:
branches: [ master ] # 替换为你的保护分支名
branches: [master]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Checkout code
uses: actions/checkout@v3

- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: '20' # 使用你的Node.js版本

- name: Install dependencies
run: npm ci

- name: Run build
run: npm run build
- name: Docker build test
run: docker build -t myapp:latest .
68 changes: 33 additions & 35 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,44 +1,42 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/versions

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*
# Dependencies
node_modules
.pnp
.pnp.js

# env files (can opt-in for committing if needed)
# Local env files
.env
.env.local
.env.development.local
.env.test.local
.env.production.local

# Testing
coverage

# Turbo
.turbo

# vercel
# Vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts
# Build Outputs
.next
out
build
dist


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

# Misc
.DS_Store
*.pem

# IDEs and editors
.vscode
.idea
prisma/migrations
59 changes: 22 additions & 37 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,51 +1,36 @@
# syntax=docker.io/docker/dockerfile:1

FROM node:alpine AS base

# Install dependencies only when needed
FROM base AS deps
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat
FROM base AS turbo
WORKDIR /app
RUN apk add --no-cache libc6-compat
RUN npm install turbo
COPY . .
RUN npx turbo prune user --docker

# Install dependencies based on the preferred package manager
COPY package.json package-lock.json* .npmrc* ./
RUN npm ci


# Rebuild the source code only when needed
FROM base AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .

# Next.js collects completely anonymous telemetry data about general usage.
# Learn more here: https://nextjs.org/telemetry
# Uncomment the following line in case you want to disable telemetry during the build.
# ENV NEXT_TELEMETRY_DISABLED=1

RUN npx prisma generate && npm run build
RUN apk add --no-cache libc6-compat
COPY --from=turbo /app/out/json/ .
RUN npm install
COPY --from=turbo /app/out/full/ .
RUN npx turbo run build --filter=user

# Production image, copy all the files and run next
FROM base AS runner
WORKDIR /app

ENV NODE_ENV=production
# Uncomment the following line in case you want to disable telemetry during runtime.
# ENV NEXT_TELEMETRY_DISABLED=1

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 /app/.next/standalone ./
COPY --from=builder /app/.next/static ./.next/static
COPY --from=builder /app/apps/user/.next/standalone/node_modules ./node_modules
COPY --from=builder /app/apps/user/.next/standalone/apps/user ./user
COPY --from=builder /app/apps/user/.next/static ./user/.next/static
COPY --from=builder /app/apps/user/public ./user/public
COPY --from=builder /app/apps/admin/.next/standalone/node_modules ./node_modules
COPY --from=builder /app/apps/admin/.next/standalone/apps/admin ./admin
COPY --from=builder /app/apps/admin/.next/static ./admin/.next/static
COPY --from=builder /app/apps/admin/public ./user/admin
COPY --chmod=755 docker-entrypoint.sh /

EXPOSE 3000

ENV NODE_ENV=production
ENV HOSTNAME=0.0.0.0
ENV PORT=3000

# server.js is created by next build from the standalone output
# https://nextjs.org/docs/pages/api-reference/config/next-config-js/output
ENV HOSTNAME="0.0.0.0"
CMD ["node", "server.js"]
ENTRYPOINT ["/docker-entrypoint.sh"]
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,18 @@ docker run -d \
--name nextmyorder \
-p 3000:3000 \
-e DATABASE_URL="mysql://user:password@host:port/database" \
-e API_KEY="your_fast_express_api_key" \
-e APP_KEY="your_fast_express_api_key" \
-e EXPRESS_KEY="your_fast_express_api_secret" \
-e EXPRESS_SECRET="https://api.fast-express.com" \
-e CALLBACK_URL="https://example.com/api/v1.0/webhook/delivery" \
250king/nextmyorder:beta
```

### 环境变量说明
- `DATABASE_URL`: 用于配置Prisma与数据库连接,详情请参考[Prisma文档](https://www.prisma.io/docs/orm/reference/connection-urls)。
- `API_KEY`: 应用加密密钥,请使用`openssl rand -base64 64 | tr -d '\n'`生成随机密钥
- `APP_KEY`: 应用加密密钥,请使用`openssl rand -base64 64 | tr -d '\n'`生成随机密钥
- `EXPRESS_KEY` `EXPRESS_SECRET`: 快递100 API密钥,请在[快递100官网](https://api.kuaidi100.com/manager/v2/myinfo/enterprise)申请。
- `CALLBACK_URL`: 快递100 API回调地址,需配置为您的服务器地址。

### 访问
访问`http://localhost:3000`即可访问系统。请注意,首次访问请在设置页面完成应用配置。
Expand Down
45 changes: 45 additions & 0 deletions apps/admin/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# Dependencies
node_modules
.pnp
.pnp.js

# Local env files
.env
.env.local
.env.development.local
.env.test.local
.env.production.local

# Testing
coverage

# Turbo
.turbo

# Vercel
.vercel

# Build Outputs
.next
out
build
dist


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

# Misc
.DS_Store
*.pem

# IDEs and editors
.vscode
.idea

# Git
.git
4 changes: 4 additions & 0 deletions apps/admin/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import eslintConfig from "@repo/config/eslint.js";

/** @type {import("eslint").Linter.Config} */
export default eslintConfig;
5 changes: 5 additions & 0 deletions apps/admin/next-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
6 changes: 6 additions & 0 deletions apps/admin/next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
output: "standalone",
};

export default nextConfig;
39 changes: 39 additions & 0 deletions apps/admin/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"name": "admin",
"version": "0.1.0",
"type": "module",
"private": true,
"scripts": {
"dev": "next dev --port 3000",
"build": "next build",
"start": "next start",
"lint": "next lint --max-warnings 0",
"check-types": "tsc --noEmit"
},
"devDependencies": {
"@repo/config": "*",
"@types/lodash": "^4.17.20",
"@types/node": "^22.15.3",
"@types/react": "19.1.0",
"@types/react-dom": "19.1.1"
},
"dependencies": {
"@ant-design/icons": "^6.0.2",
"@ant-design/nextjs-registry": "^1.1.0",
"@ant-design/pro-components": "^2.8.10",
"@ant-design/v5-patch-for-react-19": "^1.0.3",
"@react-email/render": "^1.2.3",
"@repo/schema": "*",
"@repo/component": "*",
"@repo/util": "*",
"@trpc/client": "^11.5.1",
"@trpc/server": "^11.5.1",
"antd": "^5.27.3",
"lodash": "^4.17.21",
"next": "^15.5.0",
"path-to-regexp": "^8.3.0",
"react": "^19.1.0",
"react-dom": "^19.1.0",
"zod": "^3.24.4"
}
}
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import appRouter from "@/server";
import appRouter from "@/trpc";
import {fetchRequestHandler} from "@trpc/server/adapters/fetch";
import {createContext} from "@/server/context";
import {createContext} from "@/trpc/server";

const handler = (req: Request) => fetchRequestHandler({
endpoint: "/api/v1.0",
req,
router: appRouter,
createContext: createContext,
})
});

export {handler as GET, handler as POST};
Loading
Loading