@@ -132,6 +132,7 @@ public function applications(Request $request)
132
132
'docker_registry_image_name ' => ['type ' => 'string ' , 'description ' => 'The docker registry image name. ' ],
133
133
'docker_registry_image_tag ' => ['type ' => 'string ' , 'description ' => 'The docker registry image tag. ' ],
134
134
'is_static ' => ['type ' => 'boolean ' , 'description ' => 'The flag to indicate if the application is static. ' ],
135
+ 'static_image ' => ['type ' => 'string ' , 'enum ' => ['nginx:alpine ' ], 'description ' => 'The static image. ' ],
135
136
'install_command ' => ['type ' => 'string ' , 'description ' => 'The install command. ' ],
136
137
'build_command ' => ['type ' => 'string ' , 'description ' => 'The build command. ' ],
137
138
'start_command ' => ['type ' => 'string ' , 'description ' => 'The start command. ' ],
@@ -236,6 +237,7 @@ public function create_public_application(Request $request)
236
237
'docker_registry_image_name ' => ['type ' => 'string ' , 'description ' => 'The docker registry image name. ' ],
237
238
'docker_registry_image_tag ' => ['type ' => 'string ' , 'description ' => 'The docker registry image tag. ' ],
238
239
'is_static ' => ['type ' => 'boolean ' , 'description ' => 'The flag to indicate if the application is static. ' ],
240
+ 'static_image ' => ['type ' => 'string ' , 'enum ' => ['nginx:alpine ' ], 'description ' => 'The static image. ' ],
239
241
'install_command ' => ['type ' => 'string ' , 'description ' => 'The install command. ' ],
240
242
'build_command ' => ['type ' => 'string ' , 'description ' => 'The build command. ' ],
241
243
'start_command ' => ['type ' => 'string ' , 'description ' => 'The start command. ' ],
@@ -339,6 +341,7 @@ public function create_private_gh_app_application(Request $request)
339
341
'docker_registry_image_name ' => ['type ' => 'string ' , 'description ' => 'The docker registry image name. ' ],
340
342
'docker_registry_image_tag ' => ['type ' => 'string ' , 'description ' => 'The docker registry image tag. ' ],
341
343
'is_static ' => ['type ' => 'boolean ' , 'description ' => 'The flag to indicate if the application is static. ' ],
344
+ 'static_image ' => ['type ' => 'string ' , 'enum ' => ['nginx:alpine ' ], 'description ' => 'The static image. ' ],
342
345
'install_command ' => ['type ' => 'string ' , 'description ' => 'The install command. ' ],
343
346
'build_command ' => ['type ' => 'string ' , 'description ' => 'The build command. ' ],
344
347
'start_command ' => ['type ' => 'string ' , 'description ' => 'The start command. ' ],
@@ -633,7 +636,7 @@ public function create_dockercompose_application(Request $request)
633
636
634
637
private function create_application (Request $ request , $ type )
635
638
{
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 ' ];
639
+ $ 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 ' , 'static_image ' ];
637
640
$ teamId = getTeamIdFromToken ();
638
641
if (is_null ($ teamId )) {
639
642
return invalidTokenResponse ();
@@ -672,6 +675,7 @@ private function create_application(Request $request, $type)
672
675
$ instantDeploy = $ request ->instant_deploy ;
673
676
$ githubAppUuid = $ request ->github_app_uuid ;
674
677
$ useBuildServer = $ request ->use_build_server ;
678
+ $ isStatic = $ request ->is_static ;
675
679
676
680
$ project = Project::whereTeamId ($ teamId )->whereUuid ($ request ->project_uuid )->first ();
677
681
if (! $ project ) {
@@ -700,28 +704,29 @@ private function create_application(Request $request, $type)
700
704
if ($ request ->build_pack === 'dockercompose ' ) {
701
705
$ request ->offsetSet ('ports_exposes ' , '80 ' );
702
706
}
703
- $ validator = customApiValidator ($ request ->all (), [
704
- sharedDataApplications (),
707
+ $ validationRules = [
705
708
'git_repository ' => 'string|required ' ,
706
709
'git_branch ' => 'string|required ' ,
707
710
'build_pack ' => ['required ' , Rule::enum (BuildPackTypes::class)],
708
711
'ports_exposes ' => 'string|regex:/^(\d+)(,\d+)*$/|required ' ,
709
712
'docker_compose_location ' => 'string ' ,
710
713
'docker_compose_raw ' => 'string|nullable ' ,
711
714
'docker_compose_domains ' => 'array|nullable ' ,
712
- ' docker_compose_custom_start_command ' => ' string|nullable ' ,
713
- ' docker_compose_custom_build_command ' => ' string|nullable ' ,
714
- ] );
715
+ ];
716
+ $ validationRules = array_merge ( $ validationRules , sharedDataApplications ());
717
+ $ validator = customApiValidator ( $ request -> all (), $ validationRules );
715
718
if ($ validator ->fails ()) {
716
719
return response ()->json ([
717
720
'message ' => 'Validation failed. ' ,
718
721
'errors ' => $ validator ->errors (),
719
722
], 422 );
720
723
}
724
+
721
725
$ return = $ this ->validateDataApplications ($ request , $ server );
722
726
if ($ return instanceof \Illuminate \Http \JsonResponse) {
723
727
return $ return ;
724
728
}
729
+
725
730
$ application = new Application ;
726
731
removeUnnecessaryFieldsFromRequest ($ request );
727
732
@@ -744,11 +749,15 @@ private function create_application(Request $request, $type)
744
749
$ application ->destination_id = $ destination ->id ;
745
750
$ application ->destination_type = $ destination ->getMorphClass ();
746
751
$ application ->environment_id = $ environment ->id ;
752
+ $ application ->save ();
753
+ if (isset ($ isStatic )) {
754
+ $ application ->settings ->is_static = $ isStatic ;
755
+ $ application ->settings ->save ();
756
+ }
747
757
if (isset ($ useBuildServer )) {
748
758
$ application ->settings ->is_build_server_enabled = $ useBuildServer ;
749
759
$ application ->settings ->save ();
750
760
}
751
- $ application ->save ();
752
761
$ application ->refresh ();
753
762
if (! $ application ->settings ->is_container_label_readonly_enabled ) {
754
763
$ application ->custom_labels = str (implode ('|coolify| ' , generateLabelsApplication ($ application )))->replace ('|coolify| ' , "\n" );
@@ -782,8 +791,7 @@ private function create_application(Request $request, $type)
782
791
if ($ request ->build_pack === 'dockercompose ' ) {
783
792
$ request ->offsetSet ('ports_exposes ' , '80 ' );
784
793
}
785
- $ validator = customApiValidator ($ request ->all (), [
786
- sharedDataApplications (),
794
+ $ validationRules = [
787
795
'git_repository ' => 'string|required ' ,
788
796
'git_branch ' => 'string|required ' ,
789
797
'build_pack ' => ['required ' , Rule::enum (BuildPackTypes::class)],
@@ -792,10 +800,10 @@ private function create_application(Request $request, $type)
792
800
'watch_paths ' => 'string|nullable ' ,
793
801
'docker_compose_location ' => 'string ' ,
794
802
'docker_compose_raw ' => 'string|nullable ' ,
795
- ' docker_compose_domains ' => ' array|nullable ' ,
796
- ' docker_compose_custom_start_command ' => ' string|nullable ' ,
797
- ' docker_compose_custom_build_command ' => ' string|nullable ' ,
798
- ] );
803
+ ];
804
+ $ validationRules = array_merge ( $ validationRules , sharedDataApplications ());
805
+
806
+ $ validator = customApiValidator ( $ request -> all (), $ validationRules );
799
807
if ($ validator ->fails ()) {
800
808
return response ()->json ([
801
809
'message ' => 'Validation failed. ' ,
@@ -882,8 +890,8 @@ private function create_application(Request $request, $type)
882
890
if ($ request ->build_pack === 'dockercompose ' ) {
883
891
$ request ->offsetSet ('ports_exposes ' , '80 ' );
884
892
}
885
- $ validator = customApiValidator ( $ request -> all (), [
886
- sharedDataApplications (),
893
+
894
+ $ validationRules = [
887
895
'git_repository ' => 'string|required ' ,
888
896
'git_branch ' => 'string|required ' ,
889
897
'build_pack ' => ['required ' , Rule::enum (BuildPackTypes::class)],
@@ -892,10 +900,10 @@ private function create_application(Request $request, $type)
892
900
'watch_paths ' => 'string|nullable ' ,
893
901
'docker_compose_location ' => 'string ' ,
894
902
'docker_compose_raw ' => 'string|nullable ' ,
895
- ' docker_compose_domains ' => ' array|nullable ' ,
896
- ' docker_compose_custom_start_command ' => ' string|nullable ' ,
897
- ' docker_compose_custom_build_command ' => ' string|nullable ' ,
898
- ] );
903
+ ];
904
+
905
+ $ validationRules = array_merge ( $ validationRules , sharedDataApplications ());
906
+ $ validator = customApiValidator ( $ request -> all (), $ validationRules );
899
907
900
908
if ($ validator ->fails ()) {
901
909
return response ()->json ([
@@ -975,10 +983,13 @@ private function create_application(Request $request, $type)
975
983
if (! $ request ->has ('name ' )) {
976
984
$ request ->offsetSet ('name ' , 'dockerfile- ' .new Cuid2 );
977
985
}
978
- $ validator = customApiValidator ( $ request -> all (), [
979
- sharedDataApplications (),
986
+
987
+ $ validationRules = [
980
988
'dockerfile ' => 'string|required ' ,
981
- ]);
989
+ ];
990
+ $ validationRules = array_merge ($ validationRules , sharedDataApplications ());
991
+ $ validator = customApiValidator ($ request ->all (), $ validationRules );
992
+
982
993
if ($ validator ->fails ()) {
983
994
return response ()->json ([
984
995
'message ' => 'Validation failed. ' ,
@@ -1057,12 +1068,14 @@ private function create_application(Request $request, $type)
1057
1068
if (! $ request ->has ('name ' )) {
1058
1069
$ request ->offsetSet ('name ' , 'docker-image- ' .new Cuid2 );
1059
1070
}
1060
- $ validator = customApiValidator ($ request ->all (), [
1061
- sharedDataApplications (),
1071
+ $ validationRules = [
1062
1072
'docker_registry_image_name ' => 'string|required ' ,
1063
1073
'docker_registry_image_tag ' => 'string ' ,
1064
1074
'ports_exposes ' => 'string|regex:/^(\d+)(,\d+)*$/|required ' ,
1065
- ]);
1075
+ ];
1076
+ $ validationRules = array_merge ($ validationRules , sharedDataApplications ());
1077
+ $ validator = customApiValidator ($ request ->all (), $ validationRules );
1078
+
1066
1079
if ($ validator ->fails ()) {
1067
1080
return response ()->json ([
1068
1081
'message ' => 'Validation failed. ' ,
@@ -1135,10 +1148,12 @@ private function create_application(Request $request, $type)
1135
1148
if (! $ request ->has ('name ' )) {
1136
1149
$ request ->offsetSet ('name ' , 'service ' .new Cuid2 );
1137
1150
}
1138
- $ validator = customApiValidator ($ request ->all (), [
1139
- sharedDataApplications (),
1151
+ $ validationRules = [
1140
1152
'docker_compose_raw ' => 'string|required ' ,
1141
- ]);
1153
+ ];
1154
+ $ validationRules = array_merge ($ validationRules , sharedDataApplications ());
1155
+ $ validator = customApiValidator ($ request ->all (), $ validationRules );
1156
+
1142
1157
if ($ validator ->fails ()) {
1143
1158
return response ()->json ([
1144
1159
'message ' => 'Validation failed. ' ,
@@ -1488,8 +1503,7 @@ public function update_by_uuid(Request $request)
1488
1503
$ server = $ application ->destination ->server ;
1489
1504
$ 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 ' ];
1490
1505
1491
- $ validator = customApiValidator ($ request ->all (), [
1492
- sharedDataApplications (),
1506
+ $ validationRules = [
1493
1507
'name ' => 'string|max:255 ' ,
1494
1508
'description ' => 'string|nullable ' ,
1495
1509
'static_image ' => 'string ' ,
@@ -1499,7 +1513,9 @@ public function update_by_uuid(Request $request)
1499
1513
'docker_compose_domains ' => 'array|nullable ' ,
1500
1514
'docker_compose_custom_start_command ' => 'string|nullable ' ,
1501
1515
'docker_compose_custom_build_command ' => 'string|nullable ' ,
1502
- ]);
1516
+ ];
1517
+ $ validationRules = array_merge ($ validationRules , sharedDataApplications ());
1518
+ $ validator = customApiValidator ($ request ->all (), $ validationRules );
1503
1519
1504
1520
// Validate ports_exposes
1505
1521
if ($ request ->has ('ports_exposes ' )) {
0 commit comments