接入Gitea Actions蓝绿发布:API_KEY构建时注入、新增Dockerfile
- src/config.js 的 API_KEY 改为从构建时环境变量 TINODE_API_KEY 注入, 不再依赖官方demo默认值;未设置时保留原demo key作为本地快速测试的兜底 - webpack.config.js 新增 DefinePlugin 完成注入,并自动加载(gitignored的) .env.local,开发者本地调试不需要每次手动export - 新增 Dockerfile(node构建+nginx serve) 和 docker/nginx.conf - 新增 .gitea/workflows/deploy.yml:手动触发的蓝绿发布流程
This commit is contained in:
@@ -1,6 +1,20 @@
|
||||
const CopyPlugin = require('copy-webpack-plugin');
|
||||
const webpack = require('webpack');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
// Load developer-local overrides (gitignored) so `npm run build` picks up
|
||||
// TINODE_API_KEY etc. without having to export them by hand every time.
|
||||
const envLocalPath = path.resolve(__dirname, '.env.local');
|
||||
if (fs.existsSync(envLocalPath)) {
|
||||
for (const line of fs.readFileSync(envLocalPath, 'utf8').split('\n')) {
|
||||
const match = line.match(/^\s*([A-Z_][A-Z0-9_]*)\s*=\s*(.*)\s*$/);
|
||||
if (match) {
|
||||
process.env[match[1]] = process.env[match[1]] || match[2];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = (env, argv) => {
|
||||
const mode = argv.mode === 'production' ? 'prod' : 'dev';
|
||||
const maxAssetSize = mode === 'prod' ? 360000 : 1512000;
|
||||
@@ -52,6 +66,11 @@ module.exports = (env, argv) => {
|
||||
{ from: `node_modules/tinode-sdk/umd/tinode.${mode}.js.map`, to: `tinode.${mode}.js.map` },
|
||||
],
|
||||
}),
|
||||
// Bakes TINODE_API_KEY (from the environment or .env.local) into the bundle at build
|
||||
// time. See src/config.js for the fallback used when it's not set.
|
||||
new webpack.DefinePlugin({
|
||||
'process.env.TINODE_API_KEY': JSON.stringify(process.env.TINODE_API_KEY || ''),
|
||||
}),
|
||||
],
|
||||
externals: {
|
||||
'livekit-client': 'LivekitClient',
|
||||
|
||||
Reference in New Issue
Block a user