Merge remote-tracking branch 'origin/master'
# Conflicts: # package.json
This commit is contained in:
commit
4d84f44ea4
38
.gitlab-ci.yml
Normal file
38
.gitlab-ci.yml
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
docker-build:
|
||||||
|
image: docker:latest
|
||||||
|
stage: build
|
||||||
|
before_script:
|
||||||
|
- docker login "$DOCKER_REGISTRY" -u "$DOCKER_USER" -p "$DOCKER_PASSWORD"
|
||||||
|
script:
|
||||||
|
- |
|
||||||
|
if [[ "$CI_COMMIT_BRANCH" == "$CI_DEFAULT_BRANCH" ]]; then
|
||||||
|
tag=""
|
||||||
|
echo "Running on default branch '$CI_DEFAULT_BRANCH': tag = 'latest'"
|
||||||
|
else
|
||||||
|
tag=":$CI_COMMIT_REF_SLUG"
|
||||||
|
echo "Running on branch '$CI_COMMIT_BRANCH': tag = $tag"
|
||||||
|
fi
|
||||||
|
- docker build --pull -t "$CI_REGISTRY_IMAGE${tag}" .
|
||||||
|
- docker push "$CI_REGISTRY_IMAGE${tag}"
|
||||||
|
# Run this job in a branch where a Dockerfile exists
|
||||||
|
rules:
|
||||||
|
- if: $CI_COMMIT_BRANCH
|
||||||
|
exists:
|
||||||
|
- Dockerfile
|
||||||
|
kubectl:
|
||||||
|
image: bitnami/kubectl
|
||||||
|
stage: build
|
||||||
|
tags:
|
||||||
|
- k8s
|
||||||
|
before_script:
|
||||||
|
- kubectl get pods -n foo
|
||||||
|
script:
|
||||||
|
- |
|
||||||
|
if [[ "$CI_COMMIT_BRANCH" == "$CI_DEFAULT_BRANCH" ]]; then
|
||||||
|
tag=""
|
||||||
|
echo "Running on default branch '$CI_DEFAULT_BRANCH': tag = 'latest'"
|
||||||
|
else
|
||||||
|
tag=":$CI_COMMIT_REF_SLUG"
|
||||||
|
echo "Running on branch '$CI_COMMIT_BRANCH': tag = $tag"
|
||||||
|
fi
|
||||||
|
- echo test
|
19
Dockerfile
Normal file
19
Dockerfile
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
FROM node:20
|
||||||
|
LABEL authors="ivamp"
|
||||||
|
|
||||||
|
WORKDIR /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/
|
||||||
|
RUN npm install
|
||||||
|
|
||||||
|
|
||||||
|
CMD [ "npm", "run", "migrate" ]
|
||||||
|
|
||||||
|
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
@ -3,7 +3,6 @@
|
|||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"main": "main.ts",
|
"main": "main.ts",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"bin": "./main.ts",
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"express": "^4.18.2",
|
"express": "^4.18.2",
|
||||||
"express-jwt": "^8.4.1",
|
"express-jwt": "^8.4.1",
|
||||||
@ -17,7 +16,6 @@
|
|||||||
"@types/express": "^4.17.20",
|
"@types/express": "^4.17.20",
|
||||||
"@types/morgan": "^1.9.7",
|
"@types/morgan": "^1.9.7",
|
||||||
"@types/node": "^16.11.10",
|
"@types/node": "^16.11.10",
|
||||||
"pkg": "^5.8.1",
|
|
||||||
"ts-node": "^10.9.1",
|
"ts-node": "^10.9.1",
|
||||||
"typescript": "4.5.2"
|
"typescript": "4.5.2"
|
||||||
},
|
},
|
||||||
|
@ -7,12 +7,9 @@ if (!is_loaded) {
|
|||||||
// 检测运行目录下是否有 .env 文件,如果没有,则创建
|
// 检测运行目录下是否有 .env 文件,如果没有,则创建
|
||||||
const envPath = process.cwd()
|
const envPath = process.cwd()
|
||||||
|
|
||||||
console.log(envPath)
|
|
||||||
|
|
||||||
if (!fs.existsSync(envPath)) {
|
if (!fs.existsSync(envPath)) {
|
||||||
// 如果没有,则创建
|
// 如果没有,则创建
|
||||||
if (!fs.existsSync(envPath)) {
|
if (!fs.existsSync(envPath)) {
|
||||||
console.log('create .env file at ' + envPath)
|
|
||||||
fs.writeFileSync(envPath, '')
|
fs.writeFileSync(envPath, '')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,4 +4,9 @@ typeorm.initialize().then(async () => {
|
|||||||
console.log("Datasource initialized.")
|
console.log("Datasource initialized.")
|
||||||
}).catch(error => console.log(error))
|
}).catch(error => console.log(error))
|
||||||
|
|
||||||
|
|
||||||
|
typeorm.runMigrations().then(async () => {
|
||||||
|
console.log("Migration run successfully.")
|
||||||
|
}).catch(error => console.log(error))
|
||||||
|
|
||||||
export default typeorm.manager
|
export default typeorm.manager
|
@ -1,6 +1,15 @@
|
|||||||
import "reflect-metadata"
|
import "reflect-metadata"
|
||||||
import { DataSource } from "typeorm"
|
import { DataSource } from "typeorm"
|
||||||
import "./env"
|
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({
|
const typeorm = new DataSource({
|
||||||
type: "mysql",
|
type: "mysql",
|
||||||
@ -11,8 +20,13 @@ const typeorm = new DataSource({
|
|||||||
database: process.env.DB_DATABASE,
|
database: process.env.DB_DATABASE,
|
||||||
synchronize: false,
|
synchronize: false,
|
||||||
logging: false,
|
logging: false,
|
||||||
entities: ["src/entity/*.ts"],
|
// entities: ["src/entity/*.ts"],
|
||||||
migrations: ["src/migration/*.ts"],
|
// migrations: ["src/migration/*.ts"],
|
||||||
|
entities: [
|
||||||
|
],
|
||||||
|
migrations: [
|
||||||
|
CreateUsersTable1698126666203
|
||||||
|
],
|
||||||
subscribers: [],
|
subscribers: [],
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user