mirror of
https://git.um-react.app/um/um-react.git
synced 2025-11-28 19:43:02 +00:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e9480ce6a4 | ||
|
|
a07bcf2575 | ||
|
|
a40ecc4569 | ||
|
|
1abfe3498f | ||
|
|
e69393d1bc |
3
.dockerignore
Normal file
3
.dockerignore
Normal file
@@ -0,0 +1,3 @@
|
||||
dist
|
||||
node_modules
|
||||
*.log
|
||||
5
.vscode/extensions.json
vendored
5
.vscode/extensions.json
vendored
@@ -3,9 +3,6 @@
|
||||
"editorconfig.editorconfig",
|
||||
"dbaeumer.vscode-eslint",
|
||||
"esbenp.prettier-vscode",
|
||||
"christian-kohler.path-intellisense",
|
||||
"txava.region-marker",
|
||||
"foxundermoon.shell-format",
|
||||
"jock.svg"
|
||||
"foxundermoon.shell-format"
|
||||
]
|
||||
}
|
||||
|
||||
25
Dockerfile
Normal file
25
Dockerfile
Normal file
@@ -0,0 +1,25 @@
|
||||
FROM node:22-slim AS build
|
||||
ENV PNPM_HOME="/p"
|
||||
ENV PATH="$PNPM_HOME:$PATH"
|
||||
WORKDIR /app
|
||||
|
||||
RUN corepack enable pnpm \
|
||||
&& apt-get update \
|
||||
&& apt-get install -y --no-install-recommends git \
|
||||
&& apt-get clean \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
COPY package.json pnpm-lock.yaml .npmrc ./
|
||||
RUN pnpm exec true
|
||||
COPY . .
|
||||
RUN pnpm install --frozen-lockfile
|
||||
|
||||
ARG GIT_COMMIT=
|
||||
ARG GIT_COMMIT_FULL=
|
||||
|
||||
RUN pnpm build
|
||||
|
||||
FROM caddy:latest
|
||||
COPY --from=build /app/dist /srv/um-react
|
||||
EXPOSE 80
|
||||
CMD ["caddy", "file-server", "--root", "/srv/um-react"]
|
||||
27
README.MD
27
README.MD
@@ -59,6 +59,33 @@
|
||||
|
||||
[project-issues]: https://git.unlock-music.dev/um/um-react/issues/new
|
||||
|
||||
## 使用 Docker 构建、部署 (Linux)
|
||||
|
||||
首先克隆仓库并进入目录:
|
||||
|
||||
```sh
|
||||
git clone https://git.unlock-music.dev/um/um-react.git
|
||||
cd um-react
|
||||
```
|
||||
|
||||
构建 Docker 镜像:
|
||||
|
||||
```sh
|
||||
docker build \
|
||||
-t um-react \
|
||||
--build-arg GIT_COMMIT_FULL="$(git describe --long --dirty --tags --always)" \
|
||||
--build-arg GIT_COMMIT="$(git rev-parse --short HEAD)" \
|
||||
.
|
||||
```
|
||||
|
||||
在后台运行 Docker 容器:
|
||||
|
||||
```sh
|
||||
docker run -d -p 8080:80 --name um-react um-react
|
||||
```
|
||||
|
||||
然后访问 `http://localhost:8080` 即可。
|
||||
|
||||
## 开发相关
|
||||
|
||||
从源码运行或编译生产版本,请参考文档「[新手上路](./docs/getting-started.zh.md)」。
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "um-react",
|
||||
"private": true,
|
||||
"version": "0.4.0",
|
||||
"version": "0.4.2",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"start": "vite",
|
||||
|
||||
@@ -7,8 +7,13 @@ import { execSync } from 'node:child_process';
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = dirname(__filename);
|
||||
|
||||
const commitHash = execSync('git rev-parse --short HEAD').toString('utf-8').trim();
|
||||
let commitHash = process.env.GIT_COMMIT || 'unknown';
|
||||
try {
|
||||
execSync('git rev-parse --short HEAD').toString('utf-8').trim();
|
||||
} catch (e) {
|
||||
console.error('Failed to get commit hash:', e);
|
||||
}
|
||||
|
||||
const pkgJson = JSON.parse(readFileSync(__dirname + '/../package.json', 'utf-8'));
|
||||
const pkgVer = `${pkgJson.version ?? 'unknown'}-${commitHash ?? 'unknown'}` + '\n';
|
||||
const pkgVer = `${pkgJson.version ?? 'unknown'}-${commitHash}` + '\n';
|
||||
writeFileSync(__dirname + '/../dist/version.txt', pkgVer, 'utf-8');
|
||||
|
||||
@@ -69,7 +69,17 @@ export class DatabaseKeyExtractor {
|
||||
|
||||
let sql: undefined | string;
|
||||
if (this.hasTable(db, 'ShareFileItems')) {
|
||||
sql = `select EncryptionKeyId, EncryptionKey from ShareFileItems where EncryptionKey != '' group by EncryptionKeyId`;
|
||||
sql = `
|
||||
select H, K from (
|
||||
select EncryptionKeyId as H, EncryptionKey as K from ShareFileItems
|
||||
union all
|
||||
select EnHash as H, EnKey as K from DownloadItem
|
||||
) t
|
||||
where
|
||||
t.H is not null and t.H != ''
|
||||
and t.K is not null and t.K != ''
|
||||
group by t.H
|
||||
`;
|
||||
}
|
||||
if (!sql) return null;
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ const projectRoot = url.fileURLToPath(new URL('.', import.meta.url));
|
||||
const pkg = JSON.parse(fs.readFileSync(projectRoot + '/package.json', 'utf-8'));
|
||||
|
||||
const COMMAND_GIT_VERSION = 'git describe --long --dirty --tags --always';
|
||||
const shortCommit = tryCommand(COMMAND_GIT_VERSION, __dirname, 'unknown');
|
||||
const shortCommit = process.env.GIT_COMMIT_FULL || tryCommand(COMMAND_GIT_VERSION, __dirname, 'unknown');
|
||||
const version = `${pkg.version}-${shortCommit}`;
|
||||
|
||||
// https://vitejs.dev/config/
|
||||
|
||||
Reference in New Issue
Block a user