Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

fix: volume names for undefined volume names in compose

Andras Bacsai66276be1d2ab
diff --git a/apps/api/src/lib/buildPacks/compose.ts b/apps/api/src/lib/buildPacks/compose.ts
index a871618492..c8287f43ea 100644
--- a/apps/api/src/lib/buildPacks/compose.ts
+++ b/apps/api/src/lib/buildPacks/compose.ts
@@ -38,9 +38,10 @@ export default async function (data) {
if (!dockerComposeYaml.services) {
throw 'No Services found in docker-compose file.'
}
- const envs = [
- `PORT=${port}`
- ];
+ const envs = [];
+ if (Object.entries(dockerComposeYaml.services).length === 1) {
+ envs.push(`PORT=${port}`)
+ }
if (secrets.length > 0) {
secrets.forEach((secret) => {
if (pullmergeRequestId) {
@@ -65,30 +66,36 @@ export default async function (data) {
//
}
const composeVolumes = [];
- for (const volume of volumes) {
- let [v, _] = volume.split(':');
- composeVolumes[v] = {
- name: v,
+ if (volumes.length > 0) {
+ for (const volume of volumes) {
+ let [v, path] = volume.split(':');
+ composeVolumes[v] = {
+ name: v,
+ }
}
-
}
+
let networks = {}
for (let [key, value] of Object.entries(dockerComposeYaml.services)) {
value['container_name'] = `${applicationId}-${key}`
value['env_file'] = envFound ? [`${workdir}/.env`] : []
value['labels'] = labels
// TODO: If we support separated volume for each service, we need to add it here
- if (value['volumes'].length > 0) {
+ if (value['volumes']?.length > 0) {
value['volumes'] = value['volumes'].map((volume) => {
let [v, path, permission] = volume.split(':');
- v = `${applicationId}-${v}`
+ if (!path) {
+ path = v;
+ v = `${applicationId}${v.replace(/\//gi, '-')}`
+ } else {
+ v = `${applicationId}-${v}`
+ }
composeVolumes[v] = {
name: v
}
return `${v}:${path}${permission ? ':' + permission : ''}`
})
}
-
if (volumes.length > 0) {
for (const volume of volumes) {
value['volumes'].push(volume)
@@ -106,6 +113,7 @@ export default async function (data) {
}
value['networks'] = [...value['networks'] || '', network]
dockerComposeYaml.services[key] = { ...dockerComposeYaml.services[key], restart: defaultComposeConfiguration(network).restart, deploy: defaultComposeConfiguration(network).deploy }
+
}
if (Object.keys(composeVolumes).length > 0) {
dockerComposeYaml['volumes'] = { ...composeVolumes }
diff --git a/apps/ui/src/routes/applications/[id]/storages.svelte b/apps/ui/src/routes/applications/[id]/storages.svelte
index 5dc2926ac5..8b4868c7dd 100644
--- a/apps/ui/src/routes/applications/[id]/storages.svelte
+++ b/apps/ui/src/routes/applications/[id]/storages.svelte
@@ -27,7 +27,7 @@
import { get } from '$lib/api';
import { t } from '$lib/translations';
import Explainer from '$lib/components/Explainer.svelte';
-
+
let composeJson = JSON.parse(application?.dockerComposeFile || '{}');
let predefinedVolumes: any[] = [];
if (composeJson?.services) {
@@ -35,7 +35,12 @@
if (service?.volumes) {
for (const [_, volumeName] of Object.entries(service.volumes)) {
let [volume, target] = volumeName.split(':');
- volume = `${application.id}-${volume}`;
+ if (!target) {
+ target = volume;
+ volume = `${application.id}${volume.replace(/\//gi, '-')}`;
+ } else {
+ volume = `${application.id}-${volume}`;
+ }
predefinedVolumes.push({ id: volume, path: target, predefined: true });
}
}