feat: Enable database detection and backup support for Docker Compose via GitHub App#8430
Closed
sushi-levanter wants to merge 1 commit intocoollabsio:v4.xfrom
Closed
Conversation
… deployments via GitHub App - Add nullable application_id FK to service_databases table so a ServiceDatabase can belong to either a Service or an Application - Create ServiceDatabase records in the Application model parsing path of parseDockerComposeFile() when isDatabaseImage() detects a database - Add helper methods (getServer, getOwnerUuid, getNetwork, isApplicationOwned) to ServiceDatabase for owner-agnostic resolution - Update all code paths that resolve server/network/uuid through ServiceDatabase to use the new helpers instead of hardcoded ->service-> chains - Add composeDatabases() relationship to Application model with cleanup on build_pack change and force delete - Add Backups tab to Application configuration UI for dockercompose apps - Create ComposeBackups Livewire component with database selector Files modified: - database/migrations: new migration for application_id column - app/Models/ServiceDatabase.php: application() relationship + helpers - app/Models/Application.php: composeDatabases() relationship + cleanup - bootstrap/helpers/shared.php: ServiceDatabase creation in App path - app/Jobs/DatabaseBackupJob.php: owner-agnostic server/uuid resolution - app/Actions/Database/Start/StopDatabaseProxy.php: same - app/Livewire/Project/Database/*: same - app/Models/ScheduledDatabaseBackup.php: same - app/Models/LocalFileVolume.php: same - bootstrap/helpers/databases.php: same - routes/web.php: new route + updated download handler - resources/views: Backups tab + compose-backups view Resolves #7528
Contributor
|
This PR did not pass quality checks so it will be closed. If you believe this is a mistake please let us know. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Enables database detection and backup support for Docker Compose deployments via GitHub App (
dockercomposebuildpack). Previously, database services in these deployments were not detected andServiceDatabaserecords were not created, meaning automated backups were unavailable.Issue
Resolves #7528
/claim #7528
Category
Technical Details
Root Cause
parseDockerComposeFile()inbootstrap/helpers/shared.phphas two code paths:isDatabaseImage()ServiceDatabaseServiceApplicationThe Application path already called
isDatabaseImage()and setis_database, but never createdServiceDatabaserecords because the existing FK (service_id) only pointed to theservicestable.Database Changes
New migration: Adds nullable
application_idFK (constrained toapplications, cascade on delete) toservice_databasestable. Makesservice_idnullable so Application-owned databases do not need it.Model Changes
ServiceDatabase:application()relationship (belongsTo Application)isApplicationOwned()— checks if owned by Application vs ServicegetOwner()— returns the owning Service or ApplicationgetOwnerUuid()— UUID of the ownergetServer()— resolves server through either ownership pathgetNetwork()— resolves network through either ownership pathrestart(),getServiceDatabaseUrl(),team(),workdir()to use helpersownedByCurrentTeam()andownedByCurrentTeamAPI()to query both ownership pathsApplication:composeDatabases()HasMany relationshipdockercomposebuild packforceDeletingParser Changes (
shared.php)parseDockerComposeFile(), afterisDatabaseImage()detection, creates/updatesServiceDatabaserecords withapplication_id(skips preview deployments)ServiceDatabaserecords when services are removed from the compose filegetResourceByUuidteam ownership check to handle Application-owned ServiceDatabasesUpdated Code Paths
All locations that previously used hardcoded
->service->server,->service->uuid,->service->destination->networkchains now use the newgetServer(),getOwnerUuid(),getNetwork()helpers:DatabaseBackupJob: Server resolution, container naming, network for S3 uploadStartDatabaseProxy/StopDatabaseProxy: Network, server, container name resolutionBackupExecutions: Server resolution for backup deletion and downloadBackupEdit: Server resolution, redirect for Application-owned databasesScheduledDatabaseBackup: Server resolutionImport: Server, container name, network resolutionLocalFileVolume: Server/workdir resolution for file storage operationsdatabases.phphelper: Server resolution for backup cleanupweb.phpdownload route: Server resolution for backup file downloadsUI Changes
dockercomposebuild pack when databases are detected)ComposeBackupsLivewire component with database selector and backup managementScheduledBackupsandCreateScheduledBackupcomponentsSteps to Test
dockercomposebuildpack via GitHub Appdocker-compose.ymlcontaining a database service (e.g.,postgres:16-alpine) and at least one non-database serviceServiceDatabaserecordAI Usage
Contributor Agreement
Important