test
This commit is contained in:
parent
b211b5e292
commit
2b39807eac
16
Dockerfile
16
Dockerfile
@ -2,16 +2,18 @@ FROM node:20
|
||||
LABEL authors="ivamp"
|
||||
|
||||
WORKDIR /app
|
||||
ADD . /app
|
||||
# 忽略 node_modules 目录
|
||||
COPY src /app/src
|
||||
COPY package.json /app/package.json
|
||||
COPY .env.example /app/.env.example
|
||||
COPY main.ts /app/main.ts
|
||||
|
||||
RUN npm config set registry https://registry.npm.taobao.org/ && yarn config set registry https://registry.npm.taobao.org/
|
||||
RUN npm config set registry https://registry.npm.taobao.org/
|
||||
RUN npm install
|
||||
|
||||
RUN npm install -g -s --no-progress yarn && \
|
||||
yarn && \
|
||||
yarn cache clean \
|
||||
|
||||
CMD [ "yarn", "migrate" ]
|
||||
CMD [ "npm", "run", "migrate" ]
|
||||
|
||||
CMD [ "yarn", "start" ]
|
||||
CMD [ "npm", "run", "start" ]
|
||||
|
||||
EXPOSE 8080
|
||||
|
198482
dist/index.js
vendored
Normal file
198482
dist/index.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -8,10 +8,11 @@
|
||||
"express-jwt": "^8.4.1",
|
||||
"morgan": "^1.10.0",
|
||||
"mysql2": "^3.6.2",
|
||||
"ncc": "^0.3.6",
|
||||
"path": "^0.12.7",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"typeorm": "0.3.17",
|
||||
"ts-node": "^10.9.1"
|
||||
"ts-node": "^10.9.1",
|
||||
"typeorm": "0.3.17"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/express": "^4.17.20",
|
||||
|
@ -7,12 +7,9 @@ if (!is_loaded) {
|
||||
// 检测运行目录下是否有 .env 文件,如果没有,则创建
|
||||
const envPath = process.cwd()
|
||||
|
||||
console.log(envPath)
|
||||
|
||||
if (!fs.existsSync(envPath)) {
|
||||
// 如果没有,则创建
|
||||
if (!fs.existsSync(envPath)) {
|
||||
console.log('create .env file at ' + envPath)
|
||||
fs.writeFileSync(envPath, '')
|
||||
}
|
||||
}
|
||||
|
@ -4,4 +4,9 @@ typeorm.initialize().then(async () => {
|
||||
console.log("Datasource initialized.")
|
||||
}).catch(error => console.log(error))
|
||||
|
||||
|
||||
typeorm.runMigrations().then(async () => {
|
||||
console.log("Migration run successfully.")
|
||||
}).catch(error => console.log(error))
|
||||
|
||||
export default typeorm.manager
|
@ -1,6 +1,15 @@
|
||||
import "reflect-metadata"
|
||||
import { DataSource } from "typeorm"
|
||||
import "./env"
|
||||
import {CreateUsersTable1698126666203} from "../migration/1698126666203-create_users_table";
|
||||
|
||||
// const pwd = process.cwd()
|
||||
//
|
||||
// const migration_path = pwd + '/src/migration'
|
||||
//
|
||||
// // 检测当前目录下有无 migration 文件夹
|
||||
// if (!fs.existsSync(pwd + '/src/migration')) {
|
||||
// }
|
||||
|
||||
const typeorm = new DataSource({
|
||||
type: "mysql",
|
||||
@ -11,8 +20,13 @@ const typeorm = new DataSource({
|
||||
database: process.env.DB_DATABASE,
|
||||
synchronize: false,
|
||||
logging: false,
|
||||
entities: ["src/entity/*.ts"],
|
||||
migrations: ["src/migration/*.ts"],
|
||||
// entities: ["src/entity/*.ts"],
|
||||
// migrations: ["src/migration/*.ts"],
|
||||
entities: [
|
||||
],
|
||||
migrations: [
|
||||
CreateUsersTable1698126666203
|
||||
],
|
||||
subscribers: [],
|
||||
})
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user