mirror of
https://github.com/coollabsio/coolify.git
synced 2026-11-06 13:10:37 -04:00
feat(database): let docker compose applications mount the sqlite volume
This commit is contained in:
@@ -410,12 +410,50 @@ function legacyApplicationComposeVolumeName(Application $resource, string $sourc
|
||||
*/
|
||||
function composeLegacyExternalVolumeWarning(string $source, array $declaration, string $legacyName): string
|
||||
{
|
||||
$dockerVolume = data_get($declaration, 'name') ?? data_get($declaration, 'external.name') ?? $source;
|
||||
$dockerVolume = composeExternalVolumeDockerName($source, $declaration);
|
||||
$external = $dockerVolume === $source ? 'external' : "external (Docker volume '{$dockerVolume}')";
|
||||
|
||||
return "Volume '{$source}' is declared as {$external}, but Coolify still uses '{$legacyName}' because this resource used it before. To use the external volume, copy your data into it and delete the storage entry '{$legacyName}', then redeploy.";
|
||||
}
|
||||
|
||||
/**
|
||||
* The Docker volume that an external Compose volume declaration refers to: `name:`, the old
|
||||
* `external: {name: x}` syntax, or else the key.
|
||||
*
|
||||
* @param array<string, mixed> $declaration
|
||||
*/
|
||||
function composeExternalVolumeDockerName(string $key, array $declaration): string
|
||||
{
|
||||
return (string) (data_get($declaration, 'name') ?? data_get($declaration, 'external.name') ?? $key);
|
||||
}
|
||||
|
||||
/**
|
||||
* The Docker volumes that a Compose file declares as external. Returns an empty list for a
|
||||
* Compose file that is empty or not valid YAML.
|
||||
*
|
||||
* @return list<string>
|
||||
*/
|
||||
function composeExternalVolumeDockerNames(?string $compose): array
|
||||
{
|
||||
if (blank($compose)) {
|
||||
return [];
|
||||
}
|
||||
try {
|
||||
$volumes = data_get(Yaml::parse($compose), 'volumes');
|
||||
} catch (Throwable) {
|
||||
return [];
|
||||
}
|
||||
if (! is_array($volumes)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return collect($volumes)
|
||||
->filter(fn (mixed $declaration): bool => isComposeExternalVolume($declaration))
|
||||
->map(fn (array $declaration, int|string $key): string => composeExternalVolumeDockerName((string) $key, $declaration))
|
||||
->values()
|
||||
->all();
|
||||
}
|
||||
|
||||
/**
|
||||
* The key and the name of an external volume must be literal Docker volume names. Docker Compose
|
||||
* can resolve variables in `name:`, but then only the deployment `.env` sets which existing volume
|
||||
|
||||
Reference in New Issue
Block a user