This commit is contained in:
longdayi 2025-01-08 00:57:37 +08:00
parent 24bb496198
commit 678a149785
4 changed files with 36 additions and 33 deletions

View File

@ -100,19 +100,3 @@ RUN apk add --no-cache gettext
# 暴露 80 端口 # 暴露 80 端口
EXPOSE 80 EXPOSE 80
FROM tusproject/tusd as tusd
USER root
# 创建一个包装脚本
COPY <<EOF /docker-entrypoint.sh
#!/bin/sh
umask 000
exec "\$@"
EOF
RUN chmod +x /docker-entrypoint.sh
# 设置入口点
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["tusd"]

View File

@ -11,7 +11,6 @@ import { Queue } from 'bullmq';
import { QueueJobType } from '@server/queue/types'; import { QueueJobType } from '@server/queue/types';
import { nanoid } from 'nanoid-cjs'; import { nanoid } from 'nanoid-cjs';
import { slugify } from 'transliteration'; import { slugify } from 'transliteration';
import path from 'path';
const FILE_UPLOAD_CONFIG = { const FILE_UPLOAD_CONFIG = {
directory: process.env.UPLOAD_DIR, directory: process.env.UPLOAD_DIR,
maxSizeBytes: 20_000_000_000, // 20GB maxSizeBytes: 20_000_000_000, // 20GB
@ -68,7 +67,6 @@ export class TusService implements OnModuleInit {
await this.resourceService.create({ await this.resourceService.create({
data: { data: {
title: getFilenameWithoutExt(upload.metadata.filename), title: getFilenameWithoutExt(upload.metadata.filename),
filename,
fileId, // 移除最后的文件名 fileId, // 移除最后的文件名
url: upload.id, url: upload.id,
metadata: upload.metadata, metadata: upload.metadata,
@ -103,9 +101,7 @@ export class TusService implements OnModuleInit {
status: ResourceStatus.UPLOADING status: ResourceStatus.UPLOADING
} }
}); });
const expiredUploadCount = await this.tusServer.cleanUpExpiredUploads(); const expiredUploadCount = await this.tusServer.cleanUpExpiredUploads();
this.logger.log(`Cleanup complete: ${deletedResources.count} resources and ${expiredUploadCount} uploads removed`); this.logger.log(`Cleanup complete: ${deletedResources.count} resources and ${expiredUploadCount} uploads removed`);
} catch (error) { } catch (error) {
this.logger.error('Expired uploads cleanup failed', error); this.logger.error('Expired uploads cleanup failed', error);

View File

@ -1,5 +1,4 @@
version: "3.8" version: "3.8"
services: services:
db: db:
image: postgres:latest image: postgres:latest
@ -40,19 +39,45 @@ services:
environment: environment:
- PGADMIN_DEFAULT_EMAIL=insiinc@outlook.com - PGADMIN_DEFAULT_EMAIL=insiinc@outlook.com
- PGADMIN_DEFAULT_PASSWORD=Letusdoit000 - PGADMIN_DEFAULT_PASSWORD=Letusdoit000
# tusd:
# image: tusproject/tusd
# ports:
# - "8080:8080"
# environment:
# - AWS_REGION=cn-north-1
# - AWS_ACCESS_KEY_ID=minioadmin
# - AWS_SECRET_ACCESS_KEY=minioadmin
# command: -verbose -s3-bucket app -s3-endpoint http://minio:9000 -hooks-http http://host.docker.internal:3000/upload/hook
# volumes:
# - ./volumes/tusd:/data
# extra_hosts:
# - "host.docker.internal:host-gateway"
# depends_on:
# - minio
tusd: tusd:
image: tusproject/tusd image: tusproject/tusd
ports: ports:
- "8080:8080" - "8080:8080"
environment: command: -verbose -upload-dir /data -hooks-http http://host.docker.internal:3000/upload/hook
- AWS_REGION=cn-north-1
- AWS_ACCESS_KEY_ID=minioadmin
- AWS_SECRET_ACCESS_KEY=minioadmin
command: -verbose -s3-bucket app -s3-endpoint http://minio:9000
volumes: volumes:
- ./volumes/tusd:/data - ./uploads:/data
depends_on: extra_hosts:
- minio - "host.docker.internal:host-gateway"
nginx:
image: nice-nginx:latest
ports:
- "80:80"
volumes:
- ./config/nginx/conf.d:/etc/nginx/conf.d
- ./config/nginx/nginx.conf:/etc/nginx/nginx.conf
- ./uploads:/data/uploads # tusd 上传目录
- ./web-dist:/usr/share/nginx/html # 添加前端构建文件的挂载
- ./config/nginx/entrypoint.sh:/docker-entrypoint.sh
environment:
- SERVER_IP=host.docker.internal
entrypoint: ["/docker-entrypoint.sh"]
extra_hosts:
- "host.docker.internal:host-gateway"
redis: redis:
image: redis:latest image: redis:latest
ports: ports:
@ -81,7 +106,7 @@ services:
# environment: # environment:
# - VITE_APP_SERVER_IP=192.168.79.77 # - VITE_APP_SERVER_IP=192.168.79.77
# - VITE_APP_VERSION=0.3.0 # - VITE_APP_VERSION=0.3.0
# - VITE_APP_APP_NAME=fh慕课 # - VITE_APP_APP_NAME=两道防线管理后台
# server: # server:
# image: td-server:latest # image: td-server:latest
# ports: # ports:
@ -106,4 +131,4 @@ services:
networks: networks:
default: default:
name: defender-app name: remooc

View File

@ -424,8 +424,6 @@ model Resource {
title String? @map("title") title String? @map("title")
description String? @map("description") description String? @map("description")
type String? @map("type") type String? @map("type")
// 存储信息
filename String?
fileId String? @unique fileId String? @unique
url String? url String?
// 元数据 // 元数据