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
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
20 changes: 15 additions & 5 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
# DATABASE_URL用于配置Prisma与数据库连接,详情请参考https://www.prisma.io/docs/orm/reference/connection-urls
# APP_KEY用于配置应用的加密密钥,请使用“openssl rand -base64 64 | tr -d '\n'”生成随机密钥
# EXPRESS_KEY和EXPRESS_SECRET用于配置快递100的API密钥和密钥,详情请参考https://api.kuaidi100.com/manager/v2/myinfo/enterprise

DATABASE_URL=
APP_KEY=
DATABASE_URL=
PUBLIC_APP_URL=

EMAIL_HOST=
EMAIL_PORT=
EMAIL_USER=
EMAIL_PASSWORD=
EMAIL_FROM=

EXPRESS_KEY=
EXPRESS_SECRET=
EXPRESS_CALLBACK=

NAPCAT_URL=
NAPCAT_TOKEN=

TRACKING_KEY=
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
60 changes: 22 additions & 38 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,51 +1,35 @@
# 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 admin --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

# 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 ./admin/public
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"]
70 changes: 31 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,72 +14,64 @@

后端使用TRPC,数据库框架使用Prisma。

使用精臣标签机API打印标签,快递100 API完成C端寄件。
使用精臣标签机API打印标签,快递100 API完成C端寄件,17track API完成物流跟踪。

目前正在集成Napcat来与群机器人联动。

## 使用

> 注意:本项目仍在开发中,功能不完善,可能存在bug,仅供学习和参考使用,**不建议用于生产环境**。
>
>
> 如果您对本项目感兴趣,欢迎参与开发和完善,提交issue或PR。

现在已经支持Docker部署,使用Docker可以更方便地进行部署。

```bash
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 EXPRESS_KEY="your_fast_express_api_secret" \
-e EXPRESS_SECRET="https://api.fast-express.com" \
250king/nextmyorder:beta
docker run -d --name nextmyorder -p 3000:3000 [-e] 250king/nextmyorder:beta [user/admin]
#其中 -e 参数表示使用环境变量配置。user/admin表示指定运行App
```

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

| 环境变量 | 说明 |
|----------------|--------------------------------------------------------------------------------------------|
| DATABASE_URL | 用于配置Prisma与数据库连接,详情请参考[Prisma文档](https://www.prisma.io/docs/orm/reference/connection-urls) |
| APP_KEY | 应用加密密钥,请使用`openssl rand -base64 64 \| tr -d '\n'`生成随机密钥 |
| PUBLIC_APP_URL | 客户端服务器地址 |
| EMAIL_HOST | 邮件服务器地址 |
| EMAIL_PORT | 邮件服务器端口 |
| EMAIL_USER | 邮件服务器用户名 |
| EMAIL_PASS | 邮件服务器密码 |
| EMAIL_FROM | 邮件发送名称 |
| EXPRESS_KEY | 快递100 API密钥,请在[快递100官网](https://api.kuaidi100.com/manager/v2/myinfo/enterprise)申请。 |
| EXPRESS_SECRET | 快递100 API密钥,请在[快递100官网](https://api.kuaidi100.com/manager/v2/myinfo/enterprise)申请。 |
| CALLBACK_URL | 快递100 API回调地址,需配置为您的服务器地址。 |
| NAPCAT_URL | Napcat API地址 |
| NAPCAT_TOKEN | Napcat API访问令牌 |
| TRACKING_TOKEN | 物流跟踪 API访问令牌 |

### 访问

访问`http://localhost:3000`即可访问系统。请注意,首次访问请在设置页面完成应用配置。

基本使用按照正常团购流程进行,创建团购、添加商品、添加订单等。具体教程正在编写中,敬请期待!

## 开发环境搭建

1. 克隆仓库
```bash
git clone https://github.com/250king/NextMyOrder.git
cd NextMyOrder
```
2. 安装依赖
```bash
npm install
```
3. 配置环境变量。复制`.env.example`为`.env`并根据上面的环境变量说明进行修改
4. 初始化数据库
```bash
npx prisma migrate dev --name init
```
5. 启动项目
```bash
npm start
```

## ToDo

- [ ] 完善文档
- [ ] 部署支付系统
- [ ] 部署通知系统
- [X] 部署通知系统
- [ ] 降低使用门槛
- [ ] 完善批量处理
- [X] 完善批量处理
- [ ] 继续集成Napcat
- [ ] 开发Worker提供高稳定性
- [ ] 添加登录功能
- [ ] 提供更高的可拓展性
- [ ] 适配手机端
- [ ] 开发插件系统提供更高的可拓展性

其中支付系统因为还没通过审核,还在研究中

然后关于可用性问题,最大问题是快递API是只面向企业,所以对于个体用户来说使用门槛较高,后续会考虑提供更简单的寄件方式。

关于本地化部署,现在也在研究了。

关于拓展性,目前通过URL解析商品信息是支持自行编写解析过程来适配每个网站。但像标签机目前只能使用精臣的标签机,后续会考虑提供更高的可拓展性,支持为不同的标签机提供不同的API
关于拓展性,目前打算做成插件化的形式,方便后续添加功能。
Loading