File tree Expand file tree Collapse file tree 2 files changed +12
-10
lines changed
Expand file tree Collapse file tree 2 files changed +12
-10
lines changed Original file line number Diff line number Diff line change 11# 构建前端
2- FROM node:18-alpine as frontend-build
2+ FROM node:18-alpine AS frontend-build
33
44WORKDIR /app/frontend
55
@@ -42,16 +42,18 @@ COPY --from=frontend-build /app/frontend/dist ./public
4242RUN mkdir -p uploads/watermarks
4343
4444# 生成随机 JWT_SECRET 并创建 .env 文件
45- RUN echo "JWT_SECRET=$(node -e \" console.log(require('crypto').randomBytes(64).toString('hex'))\" )" > .env && \
46- echo "# 端口号" >> .env && \
47- echo "PORT=25519" >> .env && \
48- echo "# 数据库连接字符串 27017是mongodb的默认端口 stb是数据库默认名称" >> .env && \
49- echo "MONGODB_URI=mongodb://mongodb:27017/stb" >> .env && \
50- echo "# 默认上传目录" >> .env && \
51- echo "UPLOAD_DIR=/app/uploads" >> .env
45+ RUN node -e "require('fs').writeFileSync('.env', \
46+ 'JWT_SECRET=' + require('crypto').randomBytes(64).toString('hex') + '\n ' + \
47+ '# 端口号\n ' + \
48+ 'PORT=25519\n ' + \
49+ '# 数据库连接字符串 27017是mongodb的默认端口 stb是数据库默认名称\n ' + \
50+ 'MONGODB_URI=mongodb://mongodb:27017/stb\n ' + \
51+ '# 默认上传目录\n ' + \
52+ 'UPLOAD_DIR=/app/uploads\n ' \
53+ )"
5254
5355# 暴露端口
54- EXPOSE 3000
56+ EXPOSE 25519
5557
5658# 启动命令
5759CMD ["pnpm" , "start" ]
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ services:
66 context : .
77 dockerfile : Dockerfile
88 ports :
9- - " 3000:3000 "
9+ - " 25519:25519 "
1010 volumes :
1111 - ./server/uploads:/app/uploads
1212 - ./.env:/app/.env # 挂载 .env 文件以持久化 JWT_SECRET
You can’t perform that action at this time.
0 commit comments