feat: merge front and server dockerfiles and optimize build (#4589)
* feat: merge front and server dockerfiles and optimize build * fix: update image label * fix: bring back support for REACT_APP_SERVER_BASE_URL injection at runtime * fix: remove old entries & add nx cache in dockerignore * feat: generate frontend config at runtime using Nest * fix: format and filename * feat: use the EnvironmentService and leave default blank * feat: add support for DB migrations
This commit is contained in:
31
packages/twenty-server/src/utils/generate-front-config.ts
Normal file
31
packages/twenty-server/src/utils/generate-front-config.ts
Normal file
@ -0,0 +1,31 @@
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
|
||||
import { ConfigService } from '@nestjs/config';
|
||||
import { EnvironmentService } from 'src/engine/integrations/environment/environment.service';
|
||||
|
||||
const environmentService = new EnvironmentService(new ConfigService());
|
||||
|
||||
export function generateFrontConfig(): void {
|
||||
const configObject = {
|
||||
window: {
|
||||
_env_: {
|
||||
REACT_APP_SERVER_BASE_URL: environmentService.get('SERVER_URL'),
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const configString = `window._env_ = ${JSON.stringify(
|
||||
configObject.window._env_,
|
||||
null,
|
||||
2,
|
||||
)};`;
|
||||
|
||||
const distPath = path.join(__dirname, '../..', 'front');
|
||||
|
||||
if (!fs.existsSync(distPath)) {
|
||||
fs.mkdirSync(distPath, { recursive: true });
|
||||
}
|
||||
|
||||
fs.writeFileSync(path.join(distPath, 'env-config.js'), configString, 'utf8');
|
||||
}
|
||||
Reference in New Issue
Block a user