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.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
fixes related to docker-compose
Andras Bacsai18064ef6a24d
diff --git a/apps/api/src/jobs/deployApplication.ts b/apps/api/src/jobs/deployApplication.tsindex cc3740af41..f5809c684d 100644--- a/apps/api/src/jobs/deployApplication.ts+++ b/apps/api/src/jobs/deployApplication.ts@@ -601,6 +601,7 @@ import * as buildpacks from '../lib/buildPacks';}if (buildPack === 'compose') {+ const fileYaml = `${workdir}${baseDirectory}${dockerComposeFileLocation}`;try {const { stdout: containers } = await executeCommand({dockerId: destinationDockerId,@@ -630,7 +631,7 @@ import * as buildpacks from '../lib/buildPacks';buildId,applicationId,dockerId: destinationDocker.id,- command: `docker compose --project-directory ${workdir} up -d`+ command: `docker compose --project-directory ${workdir} -f ${fileYaml} up -d`});await saveBuildLog({ line: 'Deployed 🎉', buildId, applicationId });await prisma.build.update({diff --git a/apps/api/src/lib/buildPacks/compose.ts b/apps/api/src/lib/buildPacks/compose.tsindex c8cbc9f163..4e11168f6c 100644--- a/apps/api/src/lib/buildPacks/compose.ts+++ b/apps/api/src/lib/buildPacks/compose.ts@@ -43,7 +43,10 @@ export default async function (data) {let networks = {};for (let [key, value] of Object.entries(dockerComposeYaml.services)) {value['container_name'] = `${applicationId}-${key}`;- let environment = typeof value['environment'] === 'undefined' ? [] : value['environment']+ let environment = typeof value['environment'] === 'undefined' ? [] : value['environment'];+ if (Object.keys(environment).length > 0) {+ environment = Object.entries(environment).map(([key, value]) => `${key}=${value}`);+ }value['environment'] = [...environment, ...envs];value['labels'] = labels;// TODO: If we support separated volume for each service, we need to add it here@@ -95,7 +98,7 @@ export default async function (data) {buildId,applicationId,dockerId,- command: `docker compose --project-directory ${workdir} pull`+ command: `docker compose --project-directory ${workdir} -f ${fileYaml} pull`});await saveBuildLog({ line: 'Pulling images from Compose file...', buildId, applicationId });await executeCommand({@@ -103,7 +106,7 @@ export default async function (data) {buildId,applicationId,dockerId,- command: `docker compose --project-directory ${workdir} build --progress plain`+ command: `docker compose --project-directory ${workdir} -f ${fileYaml} build --progress plain`});await saveBuildLog({ line: 'Building images from Compose file...', buildId, applicationId });}diff --git a/apps/client/src/routes/applications/[id]/+page.svelte b/apps/client/src/routes/applications/[id]/+page.svelteindex be04741aa4..2747090b89 100644--- a/apps/client/src/routes/applications/[id]/+page.svelte+++ b/apps/client/src/routes/applications/[id]/+page.svelte@@ -351,13 +351,17 @@}async function reloadCompose() {if (loading.reloadCompose) return;+ if (!$appSession.tokens.github) {+ const { token } = await get(`/applications/${id}/configuration/githubToken`);+ $appSession.tokens.github = token;+ }loading.reloadCompose = true;try {if (application.gitSource.type === 'github') {const composeLocation = application.dockerComposeFileLocation.startsWith('/')- ? application.dockerComposeFileLocation- : `/${application.dockerComposeFileLocation}`;-+ ? application.dockerComposeFileLocation+ : `/${application.dockerComposeFileLocation}`;+const headers = isPublicRepository? {}: {@@ -384,17 +388,17 @@if (!$appSession.tokens.gitlab) {await getGitlabToken();}-+const composeLocation = application.dockerComposeFileLocation.startsWith('/')- ? application.dockerComposeFileLocation.substring(1) // Remove the '/' from the start- : application.dockerComposeFileLocation;-+ ? application.dockerComposeFileLocation.substring(1) // Remove the '/' from the start+ : application.dockerComposeFileLocation;+// If the file is in a subdirectory, lastIndex will be > 0// Otherwise it will be -1 and path will be an empty string- const lastIndex = composeLocation.lastIndexOf('/') + 1- const path = composeLocation.substring(0, lastIndex)- const fileName = composeLocation.substring(lastIndex)-+ const lastIndex = composeLocation.lastIndexOf('/') + 1;+ const path = composeLocation.substring(0, lastIndex);+ const fileName = composeLocation.substring(lastIndex);+const headers = isPublicRepository? {}: {@@ -407,8 +411,7 @@...headers});const dockerComposeFileYml = files.find(- (file: { name: string; type: string }) =>- file.name === fileName && file.type === 'blob'+ (file: { name: string; type: string }) => file.name === fileName && file.type === 'blob');const id = dockerComposeFileYml.id;diff --git a/apps/client/src/routes/applications/[id]/logs/+page.svelte b/apps/client/src/routes/applications/[id]/logs/+page.svelteindex 310d65b324..2448ab2965 100644--- a/apps/client/src/routes/applications/[id]/logs/+page.svelte+++ b/apps/client/src/routes/applications/[id]/logs/+page.svelte@@ -21,7 +21,7 @@onMount(async () => {const { data } = await trpc.applications.getApplicationById.query({ id });application = data;- if (data.dockerComposeFile) {+ if (application.dockerComposeFile && application.buildPack === 'compose') {services = normalizeDockerServices(JSON.parse(data.dockerComposeFile).services);} else {services = [diff --git a/apps/client/src/routes/applications/[id]/usage/+page.svelte b/apps/client/src/routes/applications/[id]/usage/+page.svelteindex 656c697e37..446f5abf51 100644--- a/apps/client/src/routes/applications/[id]/usage/+page.svelte+++ b/apps/client/src/routes/applications/[id]/usage/+page.svelte@@ -55,7 +55,7 @@clearInterval(usageInterval);});onMount(async () => {- if (application.dockerComposeFile) {+ if (application.dockerComposeFile && application.buildPack === 'compose') {services = normalizeDockerServices(JSON.parse(application.dockerComposeFile).services);} else {services = [diff --git a/apps/server/src/jobs/applicationBuildQueue.ts b/apps/server/src/jobs/applicationBuildQueue.tsindex 92ddc3b849..ff94f01db2 100644--- a/apps/server/src/jobs/applicationBuildQueue.ts+++ b/apps/server/src/jobs/applicationBuildQueue.ts@@ -640,6 +640,7 @@ import { defaultComposeConfiguration } from '../lib/docker';}if (buildPack === 'compose') {+ const fileYaml = `${workdir}${baseDirectory}${dockerComposeFileLocation}`;try {const { stdout: containers } = await executeCommand({dockerId: destinationDockerId,@@ -669,7 +670,7 @@ import { defaultComposeConfiguration } from '../lib/docker';buildId,applicationId,dockerId: destinationDocker.id,- command: `docker compose --project-directory ${workdir} up -d`+ command: `docker compose --project-directory ${workdir} -f ${fileYaml} up -d`});await saveBuildLog({ line: 'Deployed 🎉', buildId, applicationId });await prisma.build.update({diff --git a/apps/server/src/lib/buildPacks/compose.ts b/apps/server/src/lib/buildPacks/compose.tsindex 695e205c99..9aa2d7b79f 100644--- a/apps/server/src/lib/buildPacks/compose.ts+++ b/apps/server/src/lib/buildPacks/compose.ts@@ -1,7 +1,7 @@import { promises as fs } from 'fs';-import { generateSecrets } from '../common';import { saveBuildLog } from './common';import yaml from 'js-yaml';+import { generateSecrets } from '../common';import { defaultComposeConfiguration } from '../docker';import { executeCommand } from '../executeCommand';@@ -45,7 +45,10 @@ export default async function (data) {let networks = {};for (let [key, value] of Object.entries(dockerComposeYaml.services)) {value['container_name'] = `${applicationId}-${key}`;- let environment = typeof value['environment'] === 'undefined' ? [] : value['environment']+ let environment = typeof value['environment'] === 'undefined' ? [] : value['environment'];+ if (Object.keys(environment).length > 0) {+ environment = Object.entries(environment).map(([key, value]) => `${key}=${value}`);+ }value['environment'] = [...environment, ...envs];value['labels'] = labels;// TODO: If we support separated volume for each service, we need to add it here@@ -97,7 +100,7 @@ export default async function (data) {buildId,applicationId,dockerId,- command: `docker compose --project-directory ${workdir} pull`+ command: `docker compose --project-directory ${workdir} -f ${fileYaml} pull`});await saveBuildLog({ line: 'Pulling images from Compose file...', buildId, applicationId });await executeCommand({@@ -105,7 +108,7 @@ export default async function (data) {buildId,applicationId,dockerId,- command: `docker compose --project-directory ${workdir} build --progress plain`+ command: `docker compose --project-directory ${workdir} -f ${fileYaml} build --progress plain`});await saveBuildLog({ line: 'Building images from Compose file...', buildId, applicationId });}diff --git a/apps/ui/src/routes/applications/[id]/configuration/_BuildPack.svelte b/apps/ui/src/routes/applications/[id]/configuration/_BuildPack.svelteindex fb913b5a90..c6872dedec 100644--- a/apps/ui/src/routes/applications/[id]/configuration/_BuildPack.svelte+++ b/apps/ui/src/routes/applications/[id]/configuration/_BuildPack.svelte@@ -28,12 +28,15 @@delete tempBuildPack.fancyName;delete tempBuildPack.color;delete tempBuildPack.hoverColor;- let composeConfiguration: any = {}- if (!dockerComposeConfiguration && dockerComposeFile) {- for (const [name, _] of Object.entries(JSON.parse(dockerComposeFile).services)) {+ let composeConfiguration: any = {};+ if (!dockerComposeConfiguration && dockerComposeFile && buildPack.name === 'compose') {+ const parsed = JSON.parse(dockerComposeFile);+ if (!parsed?.services) {+ throw new Error('No services found in docker-compose file. <br>Choose a different buildpack.');+ }+ for (const [name, _] of Object.entries(parsed.services)) {composeConfiguration[name] = {};}-}await post(`/applications/${id}`, {...tempBuildPack,diff --git a/apps/ui/src/routes/applications/[id]/index.svelte b/apps/ui/src/routes/applications/[id]/index.svelteindex e630106f4e..5dd50825a8 100644--- a/apps/ui/src/routes/applications/[id]/index.svelte+++ b/apps/ui/src/routes/applications/[id]/index.svelte@@ -366,6 +366,10 @@async function reloadCompose() {if (loading.reloadCompose) return;loading.reloadCompose = true;+ if (!$appSession.tokens.github) {+ const { token } = await get(`/applications/${id}/configuration/githubToken`);+ $appSession.tokens.github = token;+ }try {if (application.gitSource.type === 'github') {const composeLocation = application.dockerComposeFileLocation.startsWith('/')diff --git a/apps/ui/src/routes/applications/[id]/logs/index.svelte b/apps/ui/src/routes/applications/[id]/logs/index.svelteindex 84fabd7b98..48922e6609 100644--- a/apps/ui/src/routes/applications/[id]/logs/index.svelte+++ b/apps/ui/src/routes/applications/[id]/logs/index.svelte@@ -21,7 +21,7 @@onMount(async () => {const response = await get(`/applications/${id}`);application = response.application;- if (response.application.dockerComposeFile) {+ if (response.application.dockerComposeFile && application.buildPack === 'compose') {services = normalizeDockerServices(JSON.parse(response.application.dockerComposeFile).services);diff --git a/apps/ui/src/routes/applications/[id]/usage.svelte b/apps/ui/src/routes/applications/[id]/usage.svelteindex b0f10a63da..a2e09ff147 100644--- a/apps/ui/src/routes/applications/[id]/usage.svelte+++ b/apps/ui/src/routes/applications/[id]/usage.svelte@@ -55,7 +55,7 @@onMount(async () => {const response = await get(`/applications/${id}`);application = response.application;- if (response.application.dockerComposeFile) {+ if (response.application.dockerComposeFile && application.buildPack === 'compose') {services = normalizeDockerServices(JSON.parse(response.application.dockerComposeFile).services);