Skip to content

Commit 95483f1

Browse files
authored
Merge pull request coollabsio#3615 from liberocks/feature/api-use-build-server
feat: allow specify use_build_server when creating/updating an application through API
2 parents 987b90e + f5785b1 commit 95483f1

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

app/Http/Controllers/Api/ApplicationsController.php

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ public function applications(Request $request)
177177
'docker_compose_custom_build_command' => ['type' => 'string', 'description' => 'The Docker Compose custom build command.'],
178178
'docker_compose_domains' => ['type' => 'array', 'description' => 'The Docker Compose domains.'],
179179
'watch_paths' => ['type' => 'string', 'description' => 'The watch paths.'],
180+
'use_build_server' => ['type' => 'boolean', 'nullable' => true, 'description' => 'Use build server.'],
180181
],
181182
)),
182183
]),
@@ -279,6 +280,7 @@ public function create_public_application(Request $request)
279280
'docker_compose_custom_build_command' => ['type' => 'string', 'description' => 'The Docker Compose custom build command.'],
280281
'docker_compose_domains' => ['type' => 'array', 'description' => 'The Docker Compose domains.'],
281282
'watch_paths' => ['type' => 'string', 'description' => 'The watch paths.'],
283+
'use_build_server' => ['type' => 'boolean', 'nullable' => true, 'description' => 'Use build server.'],
282284
],
283285
)),
284286
]),
@@ -381,6 +383,7 @@ public function create_private_gh_app_application(Request $request)
381383
'docker_compose_custom_build_command' => ['type' => 'string', 'description' => 'The Docker Compose custom build command.'],
382384
'docker_compose_domains' => ['type' => 'array', 'description' => 'The Docker Compose domains.'],
383385
'watch_paths' => ['type' => 'string', 'description' => 'The watch paths.'],
386+
'use_build_server' => ['type' => 'boolean', 'nullable' => true, 'description' => 'Use build server.'],
384387
],
385388
)),
386389
]),
@@ -468,6 +471,7 @@ public function create_private_deploy_key_application(Request $request)
468471
'manual_webhook_secret_gitea' => ['type' => 'string', 'description' => 'Manual webhook secret for Gitea.'],
469472
'redirect' => ['type' => 'string', 'nullable' => true, 'description' => 'How to set redirect with Traefik / Caddy. www<->non-www.', 'enum' => ['www', 'non-www', 'both']],
470473
'instant_deploy' => ['type' => 'boolean', 'description' => 'The flag to indicate if the application should be deployed instantly.'],
474+
'use_build_server' => ['type' => 'boolean', 'nullable' => true, 'description' => 'Use build server.'],
471475
],
472476
)),
473477
]),
@@ -552,6 +556,7 @@ public function create_dockerfile_application(Request $request)
552556
'manual_webhook_secret_gitea' => ['type' => 'string', 'description' => 'Manual webhook secret for Gitea.'],
553557
'redirect' => ['type' => 'string', 'nullable' => true, 'description' => 'How to set redirect with Traefik / Caddy. www<->non-www.', 'enum' => ['www', 'non-www', 'both']],
554558
'instant_deploy' => ['type' => 'boolean', 'description' => 'The flag to indicate if the application should be deployed instantly.'],
559+
'use_build_server' => ['type' => 'boolean', 'nullable' => true, 'description' => 'Use build server.'],
555560
],
556561
)),
557562
]),
@@ -602,6 +607,7 @@ public function create_dockerimage_application(Request $request)
602607
'name' => ['type' => 'string', 'description' => 'The application name.'],
603608
'description' => ['type' => 'string', 'description' => 'The application description.'],
604609
'instant_deploy' => ['type' => 'boolean', 'description' => 'The flag to indicate if the application should be deployed instantly.'],
610+
'use_build_server' => ['type' => 'boolean', 'nullable' => true, 'description' => 'Use build server.'],
605611
],
606612
)),
607613
]),
@@ -627,7 +633,7 @@ public function create_dockercompose_application(Request $request)
627633

628634
private function create_application(Request $request, $type)
629635
{
630-
$allowedFields = ['project_uuid', 'environment_name', 'server_uuid', 'destination_uuid', 'type', 'name', 'description', 'is_static', 'domains', 'git_repository', 'git_branch', 'git_commit_sha', 'private_key_uuid', 'docker_registry_image_name', 'docker_registry_image_tag', 'build_pack', 'install_command', 'build_command', 'start_command', 'ports_exposes', 'ports_mappings', 'base_directory', 'publish_directory', 'health_check_enabled', 'health_check_path', 'health_check_port', 'health_check_host', 'health_check_method', 'health_check_return_code', 'health_check_scheme', 'health_check_response_text', 'health_check_interval', 'health_check_timeout', 'health_check_retries', 'health_check_start_period', 'limits_memory', 'limits_memory_swap', 'limits_memory_swappiness', 'limits_memory_reservation', 'limits_cpus', 'limits_cpuset', 'limits_cpu_shares', 'custom_labels', 'custom_docker_run_options', 'post_deployment_command', 'post_deployment_command_container', 'pre_deployment_command', 'pre_deployment_command_container', 'manual_webhook_secret_github', 'manual_webhook_secret_gitlab', 'manual_webhook_secret_bitbucket', 'manual_webhook_secret_gitea', 'redirect', 'github_app_uuid', 'instant_deploy', 'dockerfile', 'docker_compose_location', 'docker_compose_raw', 'docker_compose_custom_start_command', 'docker_compose_custom_build_command', 'docker_compose_domains', 'watch_paths'];
636+
$allowedFields = ['project_uuid', 'environment_name', 'server_uuid', 'destination_uuid', 'type', 'name', 'description', 'is_static', 'domains', 'git_repository', 'git_branch', 'git_commit_sha', 'private_key_uuid', 'docker_registry_image_name', 'docker_registry_image_tag', 'build_pack', 'install_command', 'build_command', 'start_command', 'ports_exposes', 'ports_mappings', 'base_directory', 'publish_directory', 'health_check_enabled', 'health_check_path', 'health_check_port', 'health_check_host', 'health_check_method', 'health_check_return_code', 'health_check_scheme', 'health_check_response_text', 'health_check_interval', 'health_check_timeout', 'health_check_retries', 'health_check_start_period', 'limits_memory', 'limits_memory_swap', 'limits_memory_swappiness', 'limits_memory_reservation', 'limits_cpus', 'limits_cpuset', 'limits_cpu_shares', 'custom_labels', 'custom_docker_run_options', 'post_deployment_command', 'post_deployment_command_container', 'pre_deployment_command', 'pre_deployment_command_container', 'manual_webhook_secret_github', 'manual_webhook_secret_gitlab', 'manual_webhook_secret_bitbucket', 'manual_webhook_secret_gitea', 'redirect', 'github_app_uuid', 'instant_deploy', 'dockerfile', 'docker_compose_location', 'docker_compose_raw', 'docker_compose_custom_start_command', 'docker_compose_custom_build_command', 'docker_compose_domains', 'watch_paths', 'use_build_server'];
631637
$teamId = getTeamIdFromToken();
632638
if (is_null($teamId)) {
633639
return invalidTokenResponse();
@@ -665,6 +671,7 @@ private function create_application(Request $request, $type)
665671
$fqdn = $request->domains;
666672
$instantDeploy = $request->instant_deploy;
667673
$githubAppUuid = $request->github_app_uuid;
674+
$useBuildServer = $request->use_build_server;
668675

669676
$project = Project::whereTeamId($teamId)->whereUuid($request->project_uuid)->first();
670677
if (! $project) {
@@ -737,6 +744,8 @@ private function create_application(Request $request, $type)
737744
$application->destination_id = $destination->id;
738745
$application->destination_type = $destination->getMorphClass();
739746
$application->environment_id = $environment->id;
747+
$application->settings->is_build_server_enabled = $useBuildServer;
748+
$application->settings->save();
740749
$application->save();
741750
$application->refresh();
742751
if (! $application->settings->is_container_label_readonly_enabled) {
@@ -833,6 +842,8 @@ private function create_application(Request $request, $type)
833842
$application->environment_id = $environment->id;
834843
$application->source_type = $githubApp->getMorphClass();
835844
$application->source_id = $githubApp->id;
845+
$application->settings->is_build_server_enabled = $useBuildServer;
846+
$application->settings->save();
836847
$application->save();
837848
$application->refresh();
838849
if (! $application->settings->is_container_label_readonly_enabled) {
@@ -925,6 +936,8 @@ private function create_application(Request $request, $type)
925936
$application->destination_id = $destination->id;
926937
$application->destination_type = $destination->getMorphClass();
927938
$application->environment_id = $environment->id;
939+
$application->settings->is_build_server_enabled = $useBuildServer;
940+
$application->settings->save();
928941
$application->save();
929942
$application->refresh();
930943
if (! $application->settings->is_container_label_readonly_enabled) {
@@ -1004,6 +1017,8 @@ private function create_application(Request $request, $type)
10041017
$application->destination_id = $destination->id;
10051018
$application->destination_type = $destination->getMorphClass();
10061019
$application->environment_id = $environment->id;
1020+
$application->settings->is_build_server_enabled = $useBuildServer;
1021+
$application->settings->save();
10071022

10081023
$application->git_repository = 'coollabsio/coolify';
10091024
$application->git_branch = 'main';
@@ -1062,6 +1077,8 @@ private function create_application(Request $request, $type)
10621077
$application->destination_id = $destination->id;
10631078
$application->destination_type = $destination->getMorphClass();
10641079
$application->environment_id = $environment->id;
1080+
$application->settings->is_build_server_enabled = $useBuildServer;
1081+
$application->settings->save();
10651082

10661083
$application->git_repository = 'coollabsio/coolify';
10671084
$application->git_branch = 'main';
@@ -1404,6 +1421,7 @@ public function delete_by_uuid(Request $request)
14041421
'docker_compose_custom_build_command' => ['type' => 'string', 'description' => 'The Docker Compose custom build command.'],
14051422
'docker_compose_domains' => ['type' => 'array', 'description' => 'The Docker Compose domains.'],
14061423
'watch_paths' => ['type' => 'string', 'description' => 'The watch paths.'],
1424+
'use_build_server' => ['type' => 'boolean', 'nullable' => true, 'description' => 'Use build server.'],
14071425
],
14081426
)),
14091427
]),
@@ -1460,7 +1478,7 @@ public function update_by_uuid(Request $request)
14601478
], 404);
14611479
}
14621480
$server = $application->destination->server;
1463-
$allowedFields = ['name', 'description', 'is_static', 'domains', 'git_repository', 'git_branch', 'git_commit_sha', 'docker_registry_image_name', 'docker_registry_image_tag', 'build_pack', 'static_image', 'install_command', 'build_command', 'start_command', 'ports_exposes', 'ports_mappings', 'base_directory', 'publish_directory', 'health_check_enabled', 'health_check_path', 'health_check_port', 'health_check_host', 'health_check_method', 'health_check_return_code', 'health_check_scheme', 'health_check_response_text', 'health_check_interval', 'health_check_timeout', 'health_check_retries', 'health_check_start_period', 'limits_memory', 'limits_memory_swap', 'limits_memory_swappiness', 'limits_memory_reservation', 'limits_cpus', 'limits_cpuset', 'limits_cpu_shares', 'custom_labels', 'custom_docker_run_options', 'post_deployment_command', 'post_deployment_command_container', 'pre_deployment_command', 'pre_deployment_command_container', 'watch_paths', 'manual_webhook_secret_github', 'manual_webhook_secret_gitlab', 'manual_webhook_secret_bitbucket', 'manual_webhook_secret_gitea', 'docker_compose_location', 'docker_compose_raw', 'docker_compose_custom_start_command', 'docker_compose_custom_build_command', 'docker_compose_domains', 'redirect', 'instant_deploy'];
1481+
$allowedFields = ['name', 'description', 'is_static', 'domains', 'git_repository', 'git_branch', 'git_commit_sha', 'docker_registry_image_name', 'docker_registry_image_tag', 'build_pack', 'static_image', 'install_command', 'build_command', 'start_command', 'ports_exposes', 'ports_mappings', 'base_directory', 'publish_directory', 'health_check_enabled', 'health_check_path', 'health_check_port', 'health_check_host', 'health_check_method', 'health_check_return_code', 'health_check_scheme', 'health_check_response_text', 'health_check_interval', 'health_check_timeout', 'health_check_retries', 'health_check_start_period', 'limits_memory', 'limits_memory_swap', 'limits_memory_swappiness', 'limits_memory_reservation', 'limits_cpus', 'limits_cpuset', 'limits_cpu_shares', 'custom_labels', 'custom_docker_run_options', 'post_deployment_command', 'post_deployment_command_container', 'pre_deployment_command', 'pre_deployment_command_container', 'watch_paths', 'manual_webhook_secret_github', 'manual_webhook_secret_gitlab', 'manual_webhook_secret_bitbucket', 'manual_webhook_secret_gitea', 'docker_compose_location', 'docker_compose_raw', 'docker_compose_custom_start_command', 'docker_compose_custom_build_command', 'docker_compose_domains', 'redirect', 'instant_deploy', 'use_build_server'];
14641482

14651483
$validator = customApiValidator($request->all(), [
14661484
sharedDataApplications(),
@@ -1538,6 +1556,10 @@ public function update_by_uuid(Request $request)
15381556
}
15391557
$instantDeploy = $request->instant_deploy;
15401558

1559+
$use_build_server = $request->use_build_server;
1560+
$application->settings->is_build_server_enabled = $use_build_server;
1561+
$application->settings->save();
1562+
15411563
removeUnnecessaryFieldsFromRequest($request);
15421564

15431565
$data = $request->all();

bootstrap/helpers/api.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,4 +175,5 @@ function removeUnnecessaryFieldsFromRequest(Request $request)
175175
$request->offsetUnset('instant_deploy');
176176
$request->offsetUnset('github_app_uuid');
177177
$request->offsetUnset('private_key_uuid');
178+
$request->offsetUnset('use_build_server');
178179
}

0 commit comments

Comments
 (0)