Add GitOps stack for abrban.com with Gitea Actions CI/CD.
Build and Deploy Platform / build-push-deploy (push) Has been cancelled
Build and Deploy Platform / build-push-deploy (push) Has been cancelled
Harbor in-cluster builds via Kaniko, ArgoCD auto-sync, and production Helm values for abrban.com domains. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -21,6 +21,8 @@ import {
|
||||
assertRuntimeMatch,
|
||||
detectRuntimeFromArchive,
|
||||
} from '../build/runtime-detector';
|
||||
import { SourceStorageService } from '../storage/source-storage.service';
|
||||
import * as os from 'os';
|
||||
|
||||
@Injectable()
|
||||
export class ApplicationsService {
|
||||
@@ -31,6 +33,7 @@ export class ApplicationsService {
|
||||
private appsRepository: Repository<Application>,
|
||||
private clustersService: ClustersService,
|
||||
private configService: ConfigService,
|
||||
private sourceStorage: SourceStorageService,
|
||||
) {}
|
||||
|
||||
private toDnsLabel(value: string): string {
|
||||
@@ -208,17 +211,12 @@ export class ApplicationsService {
|
||||
async delete(id: string, userId: string): Promise<Application> {
|
||||
const app = await this.findOne(id, userId);
|
||||
|
||||
// Delete uploaded files
|
||||
// Delete uploaded source files
|
||||
if (app.codePath) {
|
||||
try {
|
||||
const uploadDir = this.configService.get<string>('platform.uploadDir') || './uploads';
|
||||
const appDir = path.join(uploadDir, app.userId, app.id);
|
||||
if (fs.existsSync(appDir)) {
|
||||
fs.rmSync(appDir, { recursive: true, force: true });
|
||||
this.logger.log(`Deleted upload directory: ${appDir}`);
|
||||
}
|
||||
await this.sourceStorage.deleteSource(app.userId, app.id, app.codePath);
|
||||
} catch (e: any) {
|
||||
this.logger.warn(`Failed to delete upload dir for ${app.name}: ${e.message}`);
|
||||
this.logger.warn(`Failed to delete source for ${app.name}: ${e.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -265,21 +263,15 @@ export class ApplicationsService {
|
||||
}
|
||||
|
||||
const app = await this.findOne(id, userId);
|
||||
const uploadDir = this.configService.get<string>('platform.uploadDir') || './uploads';
|
||||
const appDir = path.join(uploadDir, app.userId, app.id);
|
||||
|
||||
// Ensure directory exists
|
||||
fs.mkdirSync(appDir, { recursive: true });
|
||||
|
||||
// Save the zip file
|
||||
const zipPath = path.join(appDir, 'source.zip');
|
||||
fs.writeFileSync(zipPath, file.buffer);
|
||||
const tempPath = path.join(os.tmpdir(), `upload-${app.id}-${Date.now()}.zip`);
|
||||
fs.writeFileSync(tempPath, file.buffer);
|
||||
|
||||
try {
|
||||
const detected = await detectRuntimeFromArchive(zipPath);
|
||||
const detected = await detectRuntimeFromArchive(tempPath);
|
||||
assertRuntimeMatch(app.runtime, detected);
|
||||
|
||||
app.codePath = zipPath;
|
||||
const storedPath = await this.sourceStorage.putSource(app.userId, app.id, file.buffer);
|
||||
app.codePath = storedPath;
|
||||
const saved = await this.appsRepository.save(app);
|
||||
|
||||
if (detected.confidence === 'low') {
|
||||
@@ -289,13 +281,19 @@ export class ApplicationsService {
|
||||
});
|
||||
}
|
||||
|
||||
this.logger.log(`Uploaded code for ${app.name} → ${zipPath} (${(file.size / 1024).toFixed(1)} KB)`);
|
||||
this.logger.log(`Uploaded code for ${app.name} → ${storedPath} (${(file.size / 1024).toFixed(1)} KB)`);
|
||||
return saved;
|
||||
} catch (err) {
|
||||
if (fs.existsSync(zipPath)) {
|
||||
fs.unlinkSync(zipPath);
|
||||
try {
|
||||
await this.sourceStorage.deleteSource(app.userId, app.id);
|
||||
} catch {
|
||||
// ignore rollback errors
|
||||
}
|
||||
throw err;
|
||||
} finally {
|
||||
if (fs.existsSync(tempPath)) {
|
||||
fs.unlinkSync(tempPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user