Merge pull request #1 from KenGrofork/main

This commit is contained in:
vastxie 2024-01-24 08:10:00 +08:00 committed by GitHub
commit 7d6bf72c44
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 80 additions and 2 deletions

20
.dockerignore Normal file
View File

@ -0,0 +1,20 @@
node_modules
data
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
### VS Code ###
.vscode/
### Macos ###
.DS_Store
.env
.git
.gitignore
docker
docs
README.md

View File

@ -4,7 +4,7 @@ PREFIX=/docs
APIPREFIX=/api
# mysql
DB_HOST=localhost
DB_HOST=localhost # 使用docker-compose时值应该为mysql
DB_PORT=3306
DB_USER=root
DB_PASS=
@ -24,7 +24,7 @@ MAILER_FROM=
# Redis
REDIS_PORT=6379
REDIS_HOST=127.0.0.1
REDIS_HOST=127.0.0.1 # 使用docker-compose时值应该为redis
REDIS_PASSWORD=
REDIS_USER=

19
Dockerfile Normal file
View File

@ -0,0 +1,19 @@
# 编译阶段
FROM node:18-alpine AS build
WORKDIR /app
COPY . .
# 使用 pnpm 安装项目依赖
RUN npm install -g pnpm
RUN pnpm install
# 运行阶段
FROM node:18-alpine
ENV TZ="Asia/Shanghai"
WORKDIR /app
COPY --from=build /app .
EXPOSE 9520
CMD ["node", "./dist/main.js"]

39
docker-compose.yml Normal file
View File

@ -0,0 +1,39 @@
version: '3.9'
services:
mysql:
image: mysql:8
command: --default-authentication-plugin=mysql_native_password --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
restart: always
volumes:
- ./data/mysql/:/var/lib/mysql/
# ports:
# - "3306:3306"
environment:
TZ: Asia/Shanghai # 指定时区
MYSQL_ROOT_PASSWORD: "123456" # 配置root用户密码
MYSQL_DATABASE: "chatgpt" # 业务库名
MYSQL_USER: "chatgpt" # 业务库用户名
MYSQL_PASSWORD: "chatgpt" # 业务库密码
redis:
image: redis
# command: --requirepass "12345678" # redis库密码,不需要密码注释本行
restart: always
# ports:
# - "6379:6379"
environment:
TZ: Asia/Shanghai # 指定时区
volumes:
- ./data/redis/:/data/
nineai-open:
build: ./
container_name: nineai-open
restart: always
ports:
- "9520:9520"
volumes:
- ./.env:/app/.env
environment:
- TZ=Asia/Shanghai