fix(coolify): remove disallowed fields from dockercompose create payload
Coolify's /applications/dockercompose endpoint rejects build_pack (it hardcodes dockercompose), is_force_https_enabled, and docker_compose_domains at creation time. Move those to a follow-up PATCH call that runs immediately after creation. Made-with: Cursor
This commit is contained in:
@@ -516,29 +516,43 @@ export interface CreateDockerComposeAppOpts {
|
|||||||
export async function createDockerComposeApp(
|
export async function createDockerComposeApp(
|
||||||
opts: CreateDockerComposeAppOpts,
|
opts: CreateDockerComposeAppOpts,
|
||||||
): Promise<{ uuid: string }> {
|
): Promise<{ uuid: string }> {
|
||||||
|
// NOTE: the /applications/dockercompose endpoint has a restricted
|
||||||
|
// field allowlist vs the PATCH endpoint. It rejects `build_pack`
|
||||||
|
// (hardcoded to "dockercompose"), `is_force_https_enabled`, and
|
||||||
|
// `docker_compose_domains` — those must be set via PATCH afterward.
|
||||||
const body = stripUndefined({
|
const body = stripUndefined({
|
||||||
project_uuid: opts.projectUuid,
|
project_uuid: opts.projectUuid,
|
||||||
server_uuid: opts.serverUuid ?? COOLIFY_DEFAULT_SERVER_UUID,
|
server_uuid: opts.serverUuid ?? COOLIFY_DEFAULT_SERVER_UUID,
|
||||||
environment_name: opts.environmentName ?? 'production',
|
environment_name: opts.environmentName ?? 'production',
|
||||||
destination_uuid: opts.destinationUuid ?? COOLIFY_DEFAULT_DESTINATION_UUID,
|
destination_uuid: opts.destinationUuid ?? COOLIFY_DEFAULT_DESTINATION_UUID,
|
||||||
build_pack: 'dockercompose',
|
|
||||||
name: opts.name,
|
name: opts.name,
|
||||||
description: opts.description,
|
description: opts.description,
|
||||||
docker_compose_raw: opts.composeRaw,
|
docker_compose_raw: opts.composeRaw,
|
||||||
is_force_https_enabled: opts.isForceHttpsEnabled ?? true,
|
|
||||||
instant_deploy: opts.instantDeploy ?? false,
|
instant_deploy: opts.instantDeploy ?? false,
|
||||||
// domains for compose are set via docker_compose_domains after creation
|
autogenerate_domain: false,
|
||||||
docker_compose_domains: opts.composeDomains
|
|
||||||
? JSON.stringify(opts.composeDomains.map(({ service, domain }) => ({
|
|
||||||
name: service,
|
|
||||||
domain: `https://${domain.replace(/^https?:\/\//, '')}`,
|
|
||||||
})))
|
|
||||||
: undefined,
|
|
||||||
});
|
});
|
||||||
return coolifyFetch('/applications/dockercompose', {
|
const created = await coolifyFetch('/applications/dockercompose', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: JSON.stringify(body),
|
body: JSON.stringify(body),
|
||||||
});
|
}) as { uuid: string };
|
||||||
|
|
||||||
|
// Set domains + https enforcement via PATCH (compose-aware)
|
||||||
|
if (opts.composeDomains && opts.composeDomains.length > 0) {
|
||||||
|
await coolifyFetch(`/applications/${created.uuid}`, {
|
||||||
|
method: 'PATCH',
|
||||||
|
body: JSON.stringify(stripUndefined({
|
||||||
|
is_force_https_enabled: opts.isForceHttpsEnabled ?? true,
|
||||||
|
docker_compose_domains: JSON.stringify(
|
||||||
|
opts.composeDomains.map(({ service, domain }) => ({
|
||||||
|
name: service,
|
||||||
|
domain: `https://${domain.replace(/^https?:\/\//, '')}`,
|
||||||
|
})),
|
||||||
|
),
|
||||||
|
})),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return created;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function updateApplication(
|
export async function updateApplication(
|
||||||
|
|||||||
Reference in New Issue
Block a user