deploy:修改打包脚本

This commit is contained in:
fanxb 2021-12-07 10:17:18 -05:00
parent de0efdda2c
commit 9d5cdbf3a6
4 changed files with 23 additions and 5 deletions

2
.gitignore vendored
View File

@ -102,3 +102,5 @@ dist
# TernJS port file
.tern-port
data

View File

@ -1,7 +1,6 @@
FROM node:lts-buster-slim
WORKDIR /app
copy ./openRenamerBackend /app
RUN rm /app/sqls/* && chmod 777 /app/sqls
ENV PORT 80
CMD ["/usr/local/bin/node", "dist/index.js"]

13
build.sh Normal file
View File

@ -0,0 +1,13 @@
#!/bin/bash
base=$(cd "$(dirname "$0")";pwd)
cd $base
docker run -it --rm --name buildOpenRenamer --user ${UID} -v $base/openRenamerFront:/opt/front node:lts-buster-slim bash -c "cd /opt/front && yarn --registry https://registry.npm.taobao.org && yarn build"
rm -rf openRenamerBackend/static/*
touch openRenamerBackend/static/.gitkeep
mv openRenamerFront/dist/* openRenamerBackend/static
docker run -it --rm --name buildOpenRenamer --user ${UID} -v $base/openRenamerBackend:/opt/backend node:lts-buster-slim bash -c "cd /opt/backend && yarn config set registry https://registry.npm.taobao.org && yarn global add typescript && yarn && tsc"
# docker镜像打包
# docker build -t fleyx:open-renamer:0.3 .

View File

@ -12,12 +12,16 @@ class SqliteHelper {
public static pool: Database = null;
static async createPool() {
let dataFolder = path.join(config.rootPath, "data");
if (!fs.existsSync(dataFolder)) {
fs.mkdir(dataFolder);
}
SqliteHelper.pool = await open({
filename: path.join(config.rootPath, "database.db"),
filename: path.join(dataFolder, "database.db"),
driver: sqlite3.Database
});
let basePath = path.join(config.rootPath, "sqls");
let hisPath = path.join(basePath, HISTORY_NAME);
let hisPath = path.join(dataFolder, HISTORY_NAME);
let history: Array<string>;
if (fs.existsSync(hisPath)) {
history = JSON.parse(await fs.readFile(hisPath, "utf-8"));