fix: host volumes

This commit is contained in:
Andras Bacsai 2023-03-07 10:31:10 +01:00
parent 87da27f9bf
commit 04f7e8e777
4 changed files with 40 additions and 24 deletions

View File

@ -78,15 +78,25 @@ export default async function (data) {
if (value['volumes']?.length > 0) { if (value['volumes']?.length > 0) {
value['volumes'] = value['volumes'].map((volume) => { value['volumes'] = value['volumes'].map((volume) => {
let [v, path, permission] = volume.split(':'); let [v, path, permission] = volume.split(':');
if (!path) { if (
path = v; v.startsWith('.') ||
v = `${applicationId}${v.replace(/\//gi, '-').replace(/\./gi, '')}`; v.startsWith('..') ||
v.startsWith('/') ||
v.startsWith('~')
) {
// Nothing to do here, host path
} else { } else {
v = `${applicationId}${v.replace(/\//gi, '-').replace(/\./gi, '')}`; if (!path) {
path = v;
v = `${applicationId}${v.replace(/\//gi, '-').replace(/\./gi, '')}`;
} else {
v = `${applicationId}${v.replace(/\//gi, '-').replace(/\./gi, '')}`;
}
composeVolumes[v] = {
name: v
};
} }
composeVolumes[v] = {
name: v
};
return `${v}:${path}${permission ? ':' + permission : ''}`; return `${v}:${path}${permission ? ':' + permission : ''}`;
}); });
} }

View File

@ -19,7 +19,7 @@ import { saveBuildLog, saveDockerRegistryCredentials } from './buildPacks/common
import { scheduler } from './scheduler'; import { scheduler } from './scheduler';
import type { ExecaChildProcess } from 'execa'; import type { ExecaChildProcess } from 'execa';
export const version = '3.12.23'; export const version = '3.12.26';
export const isDev = process.env.NODE_ENV === 'development'; export const isDev = process.env.NODE_ENV === 'development';
export const proxyPort = process.env.COOLIFY_PROXY_PORT; export const proxyPort = process.env.COOLIFY_PROXY_PORT;
export const proxySecurePort = process.env.COOLIFY_PROXY_SECURE_PORT; export const proxySecurePort = process.env.COOLIFY_PROXY_SECURE_PORT;

View File

@ -36,14 +36,20 @@
if (service?.volumes) { if (service?.volumes) {
for (const [_, volumeName] of Object.entries(service.volumes)) { for (const [_, volumeName] of Object.entries(service.volumes)) {
let [volume, target] = volumeName.split(':'); let [volume, target] = volumeName.split(':');
if (volume === '.') { if (
volume = target; volume.startsWith('.') ||
} volume.startsWith('..') ||
if (!target) { volume.startsWith('/') ||
target = volume; volume.startsWith('~')
volume = `${application.id}${volume.replace(/\//gi, '-').replace(/\./gi, '')}`; ) {
// Nothing to do here, host path
} else { } else {
volume = `${application.id}${volume.replace(/\//gi, '-').replace(/\./gi, '')}`; if (!target) {
target = volume;
volume = `${application.id}${volume.replace(/\//gi, '-').replace(/\./gi, '')}`;
} else {
volume = `${application.id}${volume.replace(/\//gi, '-').replace(/\./gi, '')}`;
}
} }
predefinedVolumes.push({ id: volume, path: target, predefined: true }); predefinedVolumes.push({ id: volume, path: target, predefined: true });
} }
@ -88,14 +94,14 @@
{/key} {/key}
{/each} {/each}
{#if $appSession.isAdmin} {#if $appSession.isAdmin}
<div class:pt-10={predefinedVolumes.length > 0}> <div class:pt-10={predefinedVolumes.length > 0}>
Add New Volume <Explainer Add New Volume <Explainer
position="dropdown-bottom" position="dropdown-bottom"
explanation={$t('application.storage.persistent_storage_explainer')} explanation={$t('application.storage.persistent_storage_explainer')}
/> />
</div> </div>
<Storage on:refresh={refreshStorage} isNew /> <Storage on:refresh={refreshStorage} isNew />
{/if} {/if}
</div> </div>
</div> </div>

View File

@ -1,7 +1,7 @@
{ {
"name": "coolify", "name": "coolify",
"description": "An open-source & self-hostable Heroku / Netlify alternative.", "description": "An open-source & self-hostable Heroku / Netlify alternative.",
"version": "3.12.23", "version": "3.12.26",
"license": "Apache-2.0", "license": "Apache-2.0",
"repository": "github:coollabsio/coolify", "repository": "github:coollabsio/coolify",
"scripts": { "scripts": {