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:
Quentin G
2024-03-21 19:22:21 +01:00
committed by GitHub
parent 3fa8c4bace
commit 1aa48d3bf7
9 changed files with 146 additions and 3 deletions

View 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');
}