init: docker-compose support
This commit is contained in:
parent
cb478e0dc8
commit
3f1841a188
34
apps/api/src/lib/buildPacks/compose.ts
Normal file
34
apps/api/src/lib/buildPacks/compose.ts
Normal file
@ -0,0 +1,34 @@
|
||||
import { promises as fs } from 'fs';
|
||||
import { executeDockerCmd } from '../common';
|
||||
import { buildImage } from './common';
|
||||
import yaml from 'js-yaml';
|
||||
|
||||
export default async function (data) {
|
||||
let {
|
||||
applicationId,
|
||||
dockerId,
|
||||
debug,
|
||||
tag,
|
||||
workdir,
|
||||
buildId,
|
||||
baseDirectory,
|
||||
secrets,
|
||||
pullmergeRequestId,
|
||||
dockerFileLocation
|
||||
} = data
|
||||
const file = `${workdir}${baseDirectory}/docker-compose.yml`;
|
||||
const dockerComposeRaw = await fs.readFile(`${file}`, 'utf8')
|
||||
const dockerComposeYaml = yaml.load(dockerComposeRaw)
|
||||
if (!dockerComposeYaml.services) {
|
||||
throw 'No Services found in docker-compose file.'
|
||||
}
|
||||
for (let [key, value] of Object.entries(dockerComposeYaml.services)) {
|
||||
value['container_name'] = `${applicationId}-${key}`
|
||||
console.log({key, value});
|
||||
}
|
||||
|
||||
throw 'Halting'
|
||||
// await executeDockerCmd({ debug, buildId, applicationId, dockerId, command: `docker compose --project-directory ${workdir} pull` })
|
||||
// await executeDockerCmd({ debug, buildId, applicationId, dockerId, command: `docker compose --project-directory ${workdir} build --progress plain --pull` })
|
||||
// await executeDockerCmd({ debug, buildId, applicationId, dockerId, command: `docker compose --project-directory ${workdir} up -d` })
|
||||
}
|
@ -16,6 +16,7 @@ import python from './python';
|
||||
import deno from './deno';
|
||||
import laravel from './laravel';
|
||||
import heroku from './heroku';
|
||||
import compose from './compose'
|
||||
|
||||
export {
|
||||
node,
|
||||
@ -35,5 +36,6 @@ export {
|
||||
python,
|
||||
deno,
|
||||
laravel,
|
||||
heroku
|
||||
heroku,
|
||||
compose
|
||||
};
|
||||
|
@ -598,7 +598,7 @@ export async function executeDockerCmd({ debug, buildId, applicationId, dockerId
|
||||
command = command.replace(/docker compose/gi, 'docker-compose');
|
||||
}
|
||||
}
|
||||
if (command.startsWith(`docker build --progress plain`) || command.startsWith(`pack build`)) {
|
||||
if (command.startsWith(`docker build`) || command.startsWith(`pack build`)|| command.startsWith(`docker compose build`)) {
|
||||
return await asyncExecShellStream({ debug, buildId, applicationId, command, engine });
|
||||
}
|
||||
return await execaCommand(command, { env: { DOCKER_BUILDKIT: "1", DOCKER_HOST: engine }, shell: true })
|
||||
|
@ -235,6 +235,14 @@ export const buildPacks = [
|
||||
color: 'bg-sky-700',
|
||||
isCoolifyBuildPack: true,
|
||||
},
|
||||
{
|
||||
name: 'compose',
|
||||
type: 'base',
|
||||
fancyName: 'Docker Compose',
|
||||
hoverColor: 'hover:bg-sky-700',
|
||||
color: 'bg-sky-700',
|
||||
isCoolifyBuildPack: true,
|
||||
},
|
||||
{
|
||||
name: 'svelte',
|
||||
type: 'specific',
|
||||
|
Loading…
x
Reference in New Issue
Block a user