From 41c1c3989b64ff00d2b09b0646240bb978d09e8f Mon Sep 17 00:00:00 2001 From: JohnsonRan Date: Thu, 17 Jul 2025 15:49:58 +0800 Subject: [PATCH] feat: generate manifest.json for docker too Signed-off-by: JohnsonRan --- Dockerfile | 2 ++ public/manifest.json | 33 --------------------------------- start.js | 20 ++++++++++++++++++++ 3 files changed, 22 insertions(+), 33 deletions(-) delete mode 100644 public/manifest.json diff --git a/Dockerfile b/Dockerfile index ecda586..82c9788 100644 --- a/Dockerfile +++ b/Dockerfile @@ -48,6 +48,8 @@ ENV DOCKER_ENV=true # 从构建器中复制 standalone 输出 COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./ +# 从构建器中复制 scripts 目录 +COPY --from=builder --chown=nextjs:nodejs /app/scripts ./scripts # 从构建器中复制 start.js COPY --from=builder --chown=nextjs:nodejs /app/start.js ./start.js # 从构建器中复制 public 和 .next/static 目录 diff --git a/public/manifest.json b/public/manifest.json deleted file mode 100644 index c1f9fed..0000000 --- a/public/manifest.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "name": "MoonTV", - "short_name": "MoonTV", - "description": "影视聚合", - "start_url": "/", - "scope": "/", - "display": "standalone", - "background_color": "#000000", - "apple-mobile-web-app-capable": "yes", - "apple-mobile-web-app-status-bar-style": "black", - "icons": [ - { - "src": "/icons/icon-192x192.png", - "sizes": "192x192", - "type": "image/png" - }, - { - "src": "/icons/icon-256x256.png", - "sizes": "256x256", - "type": "image/png" - }, - { - "src": "/icons/icon-384x384.png", - "sizes": "384x384", - "type": "image/png" - }, - { - "src": "/icons/icon-512x512.png", - "sizes": "512x512", - "type": "image/png" - } - ] -} diff --git a/start.js b/start.js index c980cee..fb09dbf 100644 --- a/start.js +++ b/start.js @@ -2,6 +2,26 @@ /* eslint-disable no-console,@typescript-eslint/no-var-requires */ const http = require('http'); +const path = require('path'); + +// 调用 generate-manifest.js 生成 manifest.json +function generateManifest() { + console.log('Generating manifest.json for Docker deployment...'); + + try { + const generateManifestScript = path.join( + __dirname, + 'scripts', + 'generate-manifest.js' + ); + require(generateManifestScript); + } catch (error) { + console.error('❌ Error calling generate-manifest.js:', error); + throw error; + } +} + +generateManifest(); // 直接在当前进程中启动 standalone Server(`server.js`) require('./server.js');