Files
RSSHub/scripts/docker/minify-docker.js
Rongrong d8c00ec238 build(docker): optimize; add Chromium bundled ver (#9626)
* build(docker): optimize; add Chromium bundled ver

Signed-off-by: Rongrong <i@rong.moe>

* build(Dockerfile): fix redundant command and label

Signed-off-by: Rongrong <i@rong.moe>

* build(docker): only install prod deps to speed up

Signed-off-by: Rongrong <i@rong.moe>

* docs(install): minor fixes

Signed-off-by: Rongrong <i@rong.moe>

* build(Dockerfile): bump to `node:16-bullseye-slim`

Signed-off-by: Rongrong <i@rong.moe>

* build(Dockerfile): fix yarn registry mirror

Signed-off-by: Rongrong <i@rong.moe>

* build(Dockerfile): minimize dependencies

for Chromium-bundled version

Signed-off-by: Rongrong <i@rong.moe>
2022-04-28 20:40:21 +08:00

27 lines
1.3 KiB
JavaScript

/* eslint-disable no-console */
const fs = require('fs-extra');
const path = require('path');
const { nodeFileTrace } = require('@vercel/nft');
// !!! if any new dependencies are added, update the Dockerfile !!!
const projectRoot = path.resolve(process.env.PROJECT_ROOT || path.join(__dirname, '../..'));
const resultFolder = path.join(projectRoot, 'app-minimal'); // no need to resolve, ProjectRoot is always absolute
const files = ['lib/index.js', 'api/now.js'].map((file) => path.join(projectRoot, file));
(async () => {
console.log('Start analyzing, project root:', projectRoot);
const { fileList: fileSet } = await nodeFileTrace(files, {
base: projectRoot,
});
let fileList = Array.from(fileSet);
console.log('Total touchable files:', fileList.length);
fileList = fileList.filter((file) => file.startsWith('node_modules/')); // only need node_modules
console.log('Total files need to be copied (touchable files in node_modules/):', fileList.length);
console.log('Start copying files, destination:', resultFolder);
return Promise.all(fileList.map((e) => fs.copy(path.join(projectRoot, e), path.join(resultFolder, e))));
})().catch((err) => {
// fix unhandled promise rejections
console.error(err, err.stack);
process.exit(1);
});