修改部署文件
This commit is contained in:
parent
bfc937c585
commit
cdab03190c
31
Dockerfile
Normal file
31
Dockerfile
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
FROM node:18-alpine
|
||||||
|
|
||||||
|
# 设置时区
|
||||||
|
ENV TZ=Asia/Shanghai
|
||||||
|
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
|
||||||
|
|
||||||
|
# 指定工作目录
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# 复制当前代码到/app工作目录
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
# npm 源,选用国内镜像源以提高下载速度
|
||||||
|
RUN npm config set registry https://registry.npm.taobao.org/
|
||||||
|
|
||||||
|
# 使用通配符来确保 package.json 和 package-lock.json 被复制
|
||||||
|
COPY package.json /app/package.json
|
||||||
|
|
||||||
|
# 安装应用依赖
|
||||||
|
RUN cd /app && rm -rf /app/node_modules && node -v && npm cache verify && npm config set strict-ssl false && npm install --force
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# 打包
|
||||||
|
RUN npm run build
|
||||||
|
|
||||||
|
# 启动服务
|
||||||
|
# "start:prod": "cross-env NODE_ENV=production node ./dist/src/main.js",
|
||||||
|
CMD npm run start:prod
|
||||||
|
|
||||||
|
EXPOSE 7666
|
26
docker-compose.yml
Normal file
26
docker-compose.yml
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
version: "1.0"
|
||||||
|
|
||||||
|
services:
|
||||||
|
drive-server:
|
||||||
|
# nestjs服务
|
||||||
|
container_name: drive-server
|
||||||
|
build:
|
||||||
|
# 根据Dockerfile构建镜像
|
||||||
|
context: .
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
ports:
|
||||||
|
- 7666:7666
|
||||||
|
restart: on-failure # 设置自动重启,这一步必须设置,主要是存在mysql还没有启动完成就启动了node服务
|
||||||
|
volumes:
|
||||||
|
- ./prod.yaml:/prod:yaml
|
||||||
|
environment:
|
||||||
|
- HOST = 192.168.10.13
|
||||||
|
- PASSWORD = '123456'
|
||||||
|
# networks:
|
||||||
|
# - drive-server
|
||||||
|
|
||||||
|
# 声明一下网桥 my-server。
|
||||||
|
# 重要:将所有服务都挂载在同一网桥即可通过容器名来互相通信了
|
||||||
|
# 如nestjs连接mysql和redis,可以通过容器名来互相通信
|
||||||
|
# networks:
|
||||||
|
# drive-server:
|
8
prod.yaml
Normal file
8
prod.yaml
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
TEST_VALUE:
|
||||||
|
name: cookie
|
||||||
|
# 数据库相关
|
||||||
|
DATABASE: drive
|
||||||
|
USER: root
|
||||||
|
PORT: 3306
|
||||||
|
HOST: 192.168.10.13
|
||||||
|
PASSWORD: '123456'
|
|
@ -12,7 +12,11 @@ import { getMysql } from './utils/config';
|
||||||
// 加载连接数据库
|
// 加载连接数据库
|
||||||
TypeOrmModule.forRootAsync({
|
TypeOrmModule.forRootAsync({
|
||||||
useFactory: async () => {
|
useFactory: async () => {
|
||||||
return getMysql() as TypeOrmModuleAsyncOptions;
|
return {
|
||||||
|
...getMysql(), entities: [__dirname + '/**/*.entity{.ts,.js}'], // 扫描本项目中.entity.ts或者.entity.js的文件
|
||||||
|
synchronize: false,
|
||||||
|
logging: true,
|
||||||
|
} as TypeOrmModuleAsyncOptions;
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
ClientModule,
|
ClientModule,
|
||||||
|
|
|
@ -16,6 +16,7 @@ export class ClientService {
|
||||||
* 获取家庭统计信息
|
* 获取家庭统计信息
|
||||||
*/
|
*/
|
||||||
async queryHccNum({ areaCode }) {
|
async queryHccNum({ areaCode }) {
|
||||||
|
console.log('queryHccNum');
|
||||||
const [parent, child] = await Promise.all([
|
const [parent, child] = await Promise.all([
|
||||||
clientMapper.queryHccNum({ areaCode }),
|
clientMapper.queryHccNum({ areaCode }),
|
||||||
clientMapper.queryHccChildNum({ areaCode }),
|
clientMapper.queryHccChildNum({ areaCode }),
|
||||||
|
@ -51,6 +52,7 @@ export class ClientService {
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
async queryUserNum({ areaCode }) {
|
async queryUserNum({ areaCode }) {
|
||||||
|
console.log('queryUserNum');
|
||||||
const [parent, child, childNum] = await Promise.all([
|
const [parent, child, childNum] = await Promise.all([
|
||||||
await clientMapper.queryHccNum({ areaCode }),
|
await clientMapper.queryHccNum({ areaCode }),
|
||||||
await clientMapper.queryUserNum({ areaCode }),
|
await clientMapper.queryUserNum({ areaCode }),
|
||||||
|
@ -94,6 +96,7 @@ export class ClientService {
|
||||||
* 4.4获取热门应用服务信息
|
* 4.4获取热门应用服务信息
|
||||||
*/
|
*/
|
||||||
async queryMpNum({ areaCode, topLimit = 6, type = 0 }) {
|
async queryMpNum({ areaCode, topLimit = 6, type = 0 }) {
|
||||||
|
console.log('queryMpNum');
|
||||||
const { startTime, endTime } = this.dealTime(type);
|
const { startTime, endTime } = this.dealTime(type);
|
||||||
const count = await clientMapper.queryMp({
|
const count = await clientMapper.queryMp({
|
||||||
areaCode,
|
areaCode,
|
||||||
|
@ -248,6 +251,7 @@ export class ClientService {
|
||||||
* 4.5获取用户档案列表
|
* 4.5获取用户档案列表
|
||||||
*/
|
*/
|
||||||
async queryArchiveList({ areaCode, pageNo = 0, pageSize = 10, type }) {
|
async queryArchiveList({ areaCode, pageNo = 0, pageSize = 10, type }) {
|
||||||
|
console.log('queryArchiveList');
|
||||||
// await clientMapper.queryArchiveListNum(areaCode, type),
|
// await clientMapper.queryArchiveListNum(areaCode, type),
|
||||||
const [info, count] = await clientMapper.queryArchiveList({
|
const [info, count] = await clientMapper.queryArchiveList({
|
||||||
areaCode,
|
areaCode,
|
||||||
|
@ -274,6 +278,7 @@ export class ClientService {
|
||||||
* 4.6获取用户健康档案数据
|
* 4.6获取用户健康档案数据
|
||||||
*/
|
*/
|
||||||
async queryDataList({ archiveId, hccId, areaCode }) {
|
async queryDataList({ archiveId, hccId, areaCode }) {
|
||||||
|
console.log('queryDataList');
|
||||||
const dataList = await clientMapper.queryDataList({
|
const dataList = await clientMapper.queryDataList({
|
||||||
archiveId,
|
archiveId,
|
||||||
hccId,
|
hccId,
|
||||||
|
@ -319,6 +324,7 @@ export class ClientService {
|
||||||
* 4.7告警数据统计
|
* 4.7告警数据统计
|
||||||
*/
|
*/
|
||||||
async queryWarnData({ areaCode, timeRange }) {
|
async queryWarnData({ areaCode, timeRange }) {
|
||||||
|
console.log('queryWarnData');
|
||||||
const tokenResult = await axios.post(
|
const tokenResult = await axios.post(
|
||||||
`http://106.14.155.39:60036/api/v1/szjt/getToken`,
|
`http://106.14.155.39:60036/api/v1/szjt/getToken`,
|
||||||
{
|
{
|
||||||
|
@ -349,6 +355,7 @@ export class ClientService {
|
||||||
* 4.8获取告警数据列表
|
* 4.8获取告警数据列表
|
||||||
*/
|
*/
|
||||||
async queryWarnList({ code, type, time, page }) {
|
async queryWarnList({ code, type, time, page }) {
|
||||||
|
console.log('queryWarnList');
|
||||||
// let pageSize, pageIndex;
|
// let pageSize, pageIndex;
|
||||||
// if (!page) {
|
// if (!page) {
|
||||||
// pageSize = 10;
|
// pageSize = 10;
|
||||||
|
@ -464,6 +471,7 @@ export class ClientService {
|
||||||
* 4.9获取平台家庭数据使用记录
|
* 4.9获取平台家庭数据使用记录
|
||||||
*/
|
*/
|
||||||
async queryDataUseNum({ areaCode, dateRange = 1, limit = 7 }) {
|
async queryDataUseNum({ areaCode, dateRange = 1, limit = 7 }) {
|
||||||
|
console.log('queryDataUseNum');
|
||||||
const { startTime, endTime } = this.dealTime(dateRange);
|
const { startTime, endTime } = this.dealTime(dateRange);
|
||||||
const result = await clientMapper.queryDataUseNum({
|
const result = await clientMapper.queryDataUseNum({
|
||||||
areaCode,
|
areaCode,
|
||||||
|
|
|
@ -36,6 +36,6 @@ async function bootstrap() {
|
||||||
app.useGlobalPipes(new ValidationPipe());
|
app.useGlobalPipes(new ValidationPipe());
|
||||||
|
|
||||||
app.useStaticAssets(join(__dirname, '..', 'public'));
|
app.useStaticAssets(join(__dirname, '..', 'public'));
|
||||||
await app.listen(60036, '0.0.0.0');
|
await app.listen(7666, '0.0.0.0');
|
||||||
}
|
}
|
||||||
bootstrap();
|
bootstrap();
|
||||||
|
|
|
@ -18,20 +18,21 @@ export const getConfig = () => {
|
||||||
return configAll
|
return configAll
|
||||||
}
|
}
|
||||||
const environment = getEnv();
|
const environment = getEnv();
|
||||||
const yamlPath = path.join(process.cwd(), `./.config/.${environment}.yaml`);
|
// const yamlPath = path.join(process.cwd(), `./.config/.${environment}.yaml`);
|
||||||
|
const yamlPath = path.join(process.cwd(), `./${environment}.yaml`);
|
||||||
const file = fs.readFileSync(yamlPath, 'utf8');
|
const file = fs.readFileSync(yamlPath, 'utf8');
|
||||||
let config = parse(file);
|
let config = parse(file);
|
||||||
if (process?.argv[2]?.length) {
|
// if (process?.argv[2]?.length) {
|
||||||
config = { ...config, HOST: process.argv[2] }
|
// config = { ...config, HOST: process.argv[2] }
|
||||||
}
|
// }
|
||||||
if (process?.argv[3]?.length) {
|
// if (process?.argv[3]?.length) {
|
||||||
config = { ...config, USER: process.argv[3] }
|
// config = { ...config, USER: process.argv[3] }
|
||||||
}
|
// }
|
||||||
if (process?.argv[4]?.length) {
|
// if (process?.argv[4]?.length) {
|
||||||
config = { ...config, PASSWORD: process.argv[4] }
|
// config = { ...config, PASSWORD: process.argv[4] }
|
||||||
}
|
// }
|
||||||
// 融合注入参数
|
// 融合注入参数
|
||||||
// config = Object.assign(config, process.env);
|
config = Object.assign(config, process.env);
|
||||||
console.log(config)
|
console.log(config)
|
||||||
configAll = { ...config, isExist: true }
|
configAll = { ...config, isExist: true }
|
||||||
return config;
|
return config;
|
||||||
|
@ -51,9 +52,9 @@ export const getMysql = () => {
|
||||||
// username: 'root',
|
// username: 'root',
|
||||||
// password: '123456',
|
// password: '123456',
|
||||||
// database: 'drive',
|
// database: 'drive',
|
||||||
entities: [__dirname + '/**/*.entity{.ts,.js}'], // 扫描本项目中.entity.ts或者.entity.js的文件
|
// entities: [__dirname + '/**/*.entity{.ts,.js}'], // 扫描本项目中.entity.ts或者.entity.js的文件
|
||||||
synchronize: false,
|
// synchronize: false,
|
||||||
logging: true,
|
// logging: true,
|
||||||
}
|
}
|
||||||
console.log(mysql);
|
console.log(mysql);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user