@@ -16,7 +16,7 @@ class SyncBunny extends Command
16
16
*
17
17
* @var string
18
18
*/
19
- protected $ signature = 'sync:bunny {--templates} {--release} ' ;
19
+ protected $ signature = 'sync:bunny {--templates} {--release} {--nightly} ' ;
20
20
21
21
/**
22
22
* The console command description.
@@ -33,6 +33,7 @@ public function handle()
33
33
$ that = $ this ;
34
34
$ only_template = $ this ->option ('templates ' );
35
35
$ only_version = $ this ->option ('release ' );
36
+ $ nightly = $ this ->option ('nightly ' );
36
37
$ bunny_cdn = 'https://cdn.coollabs.io ' ;
37
38
$ bunny_cdn_path = 'coolify ' ;
38
39
$ bunny_cdn_storage_name = 'coolcdn ' ;
@@ -45,9 +46,15 @@ public function handle()
45
46
$ upgrade_script = 'upgrade.sh ' ;
46
47
$ production_env = '.env.production ' ;
47
48
$ service_template = 'service-templates.json ' ;
48
-
49
49
$ versions = 'versions.json ' ;
50
50
51
+ $ compose_file_location = "$ parent_dir/ $ compose_file " ;
52
+ $ compose_file_prod_location = "$ parent_dir/ $ compose_file_prod " ;
53
+ $ install_script_location = "$ parent_dir/scripts/install.sh " ;
54
+ $ upgrade_script_location = "$ parent_dir/scripts/upgrade.sh " ;
55
+ $ production_env_location = "$ parent_dir/.env.production " ;
56
+ $ versions_location = "$ parent_dir/ $ versions " ;
57
+
51
58
PendingRequest::macro ('storage ' , function ($ fileName ) use ($ that ) {
52
59
$ headers = [
53
60
'AccessKey ' => env ('BUNNY_STORAGE_API_KEY ' ),
@@ -73,8 +80,26 @@ public function handle()
73
80
]);
74
81
});
75
82
try {
83
+ if ($ nightly ) {
84
+ $ bunny_cdn_path = 'coolify-nightly ' ;
85
+
86
+ $ compose_file_location = "$ parent_dir/other/nightly/ $ compose_file " ;
87
+ $ compose_file_prod_location = "$ parent_dir/other/nightly/ $ compose_file_prod " ;
88
+ $ production_env_location = "$ parent_dir/other/nightly/ $ production_env " ;
89
+ $ upgrade_script_location = "$ parent_dir/other/nightly/ $ upgrade_script " ;
90
+ $ install_script_location = "$ parent_dir/other/nightly/ $ install_script " ;
91
+ $ versions_location = "$ parent_dir/other/nightly/ $ versions " ;
92
+ }
76
93
if (! $ only_template && ! $ only_version ) {
77
- $ this ->info ('About to sync files (docker-compose.prod.yaml, upgrade.sh, install.sh, etc) to BunnyCDN. ' );
94
+ if ($ nightly ) {
95
+ $ this ->info ('About to sync files NIGHTLY (docker-compose.prod.yaml, upgrade.sh, install.sh, etc) to BunnyCDN. ' );
96
+ } else {
97
+ $ this ->info ('About to sync files PRODUCTION (docker-compose.yml, docker-compose.prod.yml, upgrade.sh, install.sh, etc) to BunnyCDN. ' );
98
+ }
99
+ $ confirmed = confirm ('Are you sure you want to sync? ' );
100
+ if (! $ confirmed ) {
101
+ return ;
102
+ }
78
103
}
79
104
if ($ only_template ) {
80
105
$ this ->info ('About to sync service-templates.json to BunnyCDN. ' );
@@ -90,8 +115,12 @@ public function handle()
90
115
91
116
return ;
92
117
} elseif ($ only_version ) {
93
- $ this ->info ('About to sync versions.json to BunnyCDN. ' );
94
- $ file = file_get_contents ("$ parent_dir/ $ versions " );
118
+ if ($ nightly ) {
119
+ $ this ->info ('About to sync NIGHLTY versions.json to BunnyCDN. ' );
120
+ } else {
121
+ $ this ->info ('About to sync PRODUCTION versions.json to BunnyCDN. ' );
122
+ }
123
+ $ file = file_get_contents ($ versions_location );
95
124
$ json = json_decode ($ file , true );
96
125
$ actual_version = data_get ($ json , 'coolify.v4.version ' );
97
126
@@ -100,7 +129,7 @@ public function handle()
100
129
return ;
101
130
}
102
131
Http::pool (fn (Pool $ pool ) => [
103
- $ pool ->storage (fileName: " $ parent_dir / $ versions " )->put ("/ $ bunny_cdn_storage_name/ $ bunny_cdn_path/ $ versions " ),
132
+ $ pool ->storage (fileName: $ versions_location )->put ("/ $ bunny_cdn_storage_name/ $ bunny_cdn_path/ $ versions " ),
104
133
$ pool ->purge ("$ bunny_cdn/ $ bunny_cdn_path/ $ versions " ),
105
134
]);
106
135
$ this ->info ('versions.json uploaded & purged... ' );
@@ -109,11 +138,11 @@ public function handle()
109
138
}
110
139
111
140
Http::pool (fn (Pool $ pool ) => [
112
- $ pool ->storage (fileName: "$ parent_dir / $ compose_file " )->put ("/ $ bunny_cdn_storage_name/ $ bunny_cdn_path/ $ compose_file " ),
113
- $ pool ->storage (fileName: "$ parent_dir / $ compose_file_prod " )->put ("/ $ bunny_cdn_storage_name/ $ bunny_cdn_path/ $ compose_file_prod " ),
114
- $ pool ->storage (fileName: "$ parent_dir / $ production_env " )->put ("/ $ bunny_cdn_storage_name/ $ bunny_cdn_path/ $ production_env " ),
115
- $ pool ->storage (fileName: "$ parent_dir /scripts/ $ upgrade_script " )->put ("/ $ bunny_cdn_storage_name/ $ bunny_cdn_path/ $ upgrade_script " ),
116
- $ pool ->storage (fileName: "$ parent_dir /scripts/ $ install_script " )->put ("/ $ bunny_cdn_storage_name/ $ bunny_cdn_path/ $ install_script " ),
141
+ $ pool ->storage (fileName: "$ compose_file_location " )->put ("/ $ bunny_cdn_storage_name/ $ bunny_cdn_path/ $ compose_file " ),
142
+ $ pool ->storage (fileName: "$ compose_file_prod_location " )->put ("/ $ bunny_cdn_storage_name/ $ bunny_cdn_path/ $ compose_file_prod " ),
143
+ $ pool ->storage (fileName: "$ production_env_location " )->put ("/ $ bunny_cdn_storage_name/ $ bunny_cdn_path/ $ production_env " ),
144
+ $ pool ->storage (fileName: "$ upgrade_script_location " )->put ("/ $ bunny_cdn_storage_name/ $ bunny_cdn_path/ $ upgrade_script " ),
145
+ $ pool ->storage (fileName: "$ install_script_location " )->put ("/ $ bunny_cdn_storage_name/ $ bunny_cdn_path/ $ install_script " ),
117
146
]);
118
147
Http::pool (fn (Pool $ pool ) => [
119
148
$ pool ->purge ("$ bunny_cdn/ $ bunny_cdn_path/ $ compose_file " ),
0 commit comments