feat: base volume path setting

Add global base_volume_path to settings. Relative volume source
paths are automatically prepended with the base path at deploy
time. Absolute paths are used as-is. Configurable in Settings >
General.
This commit is contained in:
2026-03-28 15:21:37 +03:00
parent 62a9249abf
commit 1cfd23c431
6 changed files with 23 additions and 5 deletions
+10
View File
@@ -707,9 +707,19 @@ func (d *Deployer) computeVolumeMounts(projectID, stageName, imageTag string) []
return nil return nil
} }
// Get base volume path from settings.
basePath := ""
if settings, err := d.store.GetSettings(); err == nil {
basePath = settings.BaseVolumePath
}
mounts := make([]mount.Mount, 0, len(vols)) mounts := make([]mount.Mount, 0, len(vols))
for _, vol := range vols { for _, vol := range vols {
source := vol.Source source := vol.Source
// Prepend base path if source is relative (doesn't start with /).
if basePath != "" && !filepath.IsAbs(source) {
source = filepath.Join(basePath, source)
}
if vol.Mode == "isolated" { if vol.Mode == "isolated" {
source = filepath.Join(source, fmt.Sprintf("%s-%s", stageName, imageTag)) source = filepath.Join(source, fmt.Sprintf("%s-%s", stageName, imageTag))
} }
+1
View File
@@ -53,6 +53,7 @@ type Settings struct {
NpmPassword string `json:"npm_password"` NpmPassword string `json:"npm_password"`
WebhookSecret string `json:"webhook_secret"` WebhookSecret string `json:"webhook_secret"`
PollingInterval string `json:"polling_interval"` PollingInterval string `json:"polling_interval"`
BaseVolumePath string `json:"base_volume_path"`
UpdatedAt string `json:"updated_at"` UpdatedAt string `json:"updated_at"`
} }
+4 -4
View File
@@ -9,10 +9,10 @@ func (s *Store) GetSettings() (Settings, error) {
var st Settings var st Settings
err := s.db.QueryRow( err := s.db.QueryRow(
`SELECT domain, server_ip, network, subdomain_pattern, notification_url, `SELECT domain, server_ip, network, subdomain_pattern, notification_url,
npm_url, npm_email, npm_password, webhook_secret, polling_interval, updated_at npm_url, npm_email, npm_password, webhook_secret, polling_interval, base_volume_path, updated_at
FROM settings WHERE id = 1`, FROM settings WHERE id = 1`,
).Scan(&st.Domain, &st.ServerIP, &st.Network, &st.SubdomainPattern, &st.NotificationURL, ).Scan(&st.Domain, &st.ServerIP, &st.Network, &st.SubdomainPattern, &st.NotificationURL,
&st.NpmURL, &st.NpmEmail, &st.NpmPassword, &st.WebhookSecret, &st.PollingInterval, &st.UpdatedAt) &st.NpmURL, &st.NpmEmail, &st.NpmPassword, &st.WebhookSecret, &st.PollingInterval, &st.BaseVolumePath, &st.UpdatedAt)
if err != nil { if err != nil {
return Settings{}, fmt.Errorf("query settings: %w", err) return Settings{}, fmt.Errorf("query settings: %w", err)
} }
@@ -25,10 +25,10 @@ func (s *Store) UpdateSettings(st Settings) error {
_, err := s.db.Exec( _, err := s.db.Exec(
`UPDATE settings SET `UPDATE settings SET
domain=?, server_ip=?, network=?, subdomain_pattern=?, notification_url=?, domain=?, server_ip=?, network=?, subdomain_pattern=?, notification_url=?,
npm_url=?, npm_email=?, npm_password=?, webhook_secret=?, polling_interval=?, updated_at=? npm_url=?, npm_email=?, npm_password=?, webhook_secret=?, polling_interval=?, base_volume_path=?, updated_at=?
WHERE id = 1`, WHERE id = 1`,
st.Domain, st.ServerIP, st.Network, st.SubdomainPattern, st.NotificationURL, st.Domain, st.ServerIP, st.Network, st.SubdomainPattern, st.NotificationURL,
st.NpmURL, st.NpmEmail, st.NpmPassword, st.WebhookSecret, st.PollingInterval, st.UpdatedAt, st.NpmURL, st.NpmEmail, st.NpmPassword, st.WebhookSecret, st.PollingInterval, st.BaseVolumePath, st.UpdatedAt,
) )
if err != nil { if err != nil {
return fmt.Errorf("update settings: %w", err) return fmt.Errorf("update settings: %w", err)
+3
View File
@@ -71,6 +71,8 @@ func (s *Store) runMigrations() error {
migrations := []string{ migrations := []string{
// Add owner column to registries (2026-03-28). // Add owner column to registries (2026-03-28).
`ALTER TABLE registries ADD COLUMN owner TEXT NOT NULL DEFAULT ''`, `ALTER TABLE registries ADD COLUMN owner TEXT NOT NULL DEFAULT ''`,
// Add base_volume_path to settings (2026-03-28).
`ALTER TABLE settings ADD COLUMN base_volume_path TEXT NOT NULL DEFAULT ''`,
} }
for _, m := range migrations { for _, m := range migrations {
@@ -131,6 +133,7 @@ CREATE TABLE IF NOT EXISTS settings (
npm_password TEXT NOT NULL DEFAULT '', npm_password TEXT NOT NULL DEFAULT '',
webhook_secret TEXT NOT NULL DEFAULT '', webhook_secret TEXT NOT NULL DEFAULT '',
polling_interval TEXT NOT NULL DEFAULT '5m', polling_interval TEXT NOT NULL DEFAULT '5m',
base_volume_path TEXT NOT NULL DEFAULT '',
updated_at TEXT NOT NULL DEFAULT (datetime('now')) updated_at TEXT NOT NULL DEFAULT (datetime('now'))
); );
+1
View File
@@ -103,6 +103,7 @@ export interface Settings {
npm_password: string; npm_password: string;
webhook_secret: string; webhook_secret: string;
polling_interval: string; polling_interval: string;
base_volume_path: string;
updated_at: string; updated_at: string;
} }
+4 -1
View File
@@ -17,6 +17,7 @@
let network = $state(''); let network = $state('');
let subdomainPattern = $state(''); let subdomainPattern = $state('');
let pollingInterval = $state(''); let pollingInterval = $state('');
let baseVolumePath = $state('');
let notificationUrl = $state(''); let notificationUrl = $state('');
let errors = $state<Record<string, string>>({}); let errors = $state<Record<string, string>>({});
@@ -68,6 +69,7 @@
network = settings.network ?? ''; network = settings.network ?? '';
subdomainPattern = settings.subdomain_pattern ?? ''; subdomainPattern = settings.subdomain_pattern ?? '';
pollingInterval = settings.polling_interval ?? ''; pollingInterval = settings.polling_interval ?? '';
baseVolumePath = settings.base_volume_path ?? '';
notificationUrl = settings.notification_url ?? ''; notificationUrl = settings.notification_url ?? '';
} catch (err) { } catch (err) {
toasts.error(err instanceof Error ? err.message : $t('settingsGeneral.loadFailed')); toasts.error(err instanceof Error ? err.message : $t('settingsGeneral.loadFailed'));
@@ -90,7 +92,7 @@
await updateSettings({ await updateSettings({
domain: domain.trim(), server_ip: serverIp.trim(), network: network.trim(), domain: domain.trim(), server_ip: serverIp.trim(), network: network.trim(),
subdomain_pattern: subdomainPattern.trim(), polling_interval: pollingInterval.trim(), subdomain_pattern: subdomainPattern.trim(), polling_interval: pollingInterval.trim(),
notification_url: notificationUrl.trim() base_volume_path: baseVolumePath.trim(), notification_url: notificationUrl.trim()
}); });
toasts.success($t('settingsGeneral.saved')); toasts.success($t('settingsGeneral.saved'));
} catch (err) { } catch (err) {
@@ -139,6 +141,7 @@
<FormField label={$t('settingsGeneral.dockerNetwork')} name="network" bind:value={network} placeholder="staging-net" helpText={$t('settingsGeneral.dockerNetworkHelp')} /> <FormField label={$t('settingsGeneral.dockerNetwork')} name="network" bind:value={network} placeholder="staging-net" helpText={$t('settingsGeneral.dockerNetworkHelp')} />
<FormField label={$t('settingsGeneral.subdomainPattern')} name="subdomainPattern" bind:value={subdomainPattern} placeholder="stage-{'{stage}'}-{'{project}'}" helpText={$t('settingsGeneral.subdomainPatternHelp')} /> <FormField label={$t('settingsGeneral.subdomainPattern')} name="subdomainPattern" bind:value={subdomainPattern} placeholder="stage-{'{stage}'}-{'{project}'}" helpText={$t('settingsGeneral.subdomainPatternHelp')} />
<FormField label={$t('settingsGeneral.pollingInterval')} name="pollingInterval" type="number" bind:value={pollingInterval} placeholder="60" error={errors.pollingInterval ?? ''} helpText={$t('settingsGeneral.pollingIntervalHelp')} /> <FormField label={$t('settingsGeneral.pollingInterval')} name="pollingInterval" type="number" bind:value={pollingInterval} placeholder="60" error={errors.pollingInterval ?? ''} helpText={$t('settingsGeneral.pollingIntervalHelp')} />
<FormField label="Base Volume Path" name="baseVolumePath" bind:value={baseVolumePath} placeholder="/data" helpText="Prepended to relative volume sources (e.g., /data + my-app/uploads = /data/my-app/uploads)" />
<FormField label={$t('settingsGeneral.notificationUrl')} name="notificationUrl" bind:value={notificationUrl} placeholder="https://notify.example.com/webhook" error={errors.notificationUrl ?? ''} helpText={$t('settingsGeneral.notificationUrlHelp')} /> <FormField label={$t('settingsGeneral.notificationUrl')} name="notificationUrl" bind:value={notificationUrl} placeholder="https://notify.example.com/webhook" error={errors.notificationUrl ?? ''} helpText={$t('settingsGeneral.notificationUrlHelp')} />
</div> </div>
<div class="mt-6"> <div class="mt-6">