From f12ad10fcef49485c5dc75771dddb9ec2ed3b061 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Thu, 27 Apr 2023 12:25:32 +0200 Subject: [PATCH] update --- .../Project/New/PublicGitRepository.php | 4 +-- database/seeders/ProductionSeeder.php | 31 +++++++++++-------- docker/builder/Dockerfile | 2 +- .../etc/s6-overlay/s6-rc.d/db-migration/up | 2 +- scripts/install.sh | 5 +-- 5 files changed, 25 insertions(+), 19 deletions(-) diff --git a/app/Http/Livewire/Project/New/PublicGitRepository.php b/app/Http/Livewire/Project/New/PublicGitRepository.php index 98662f056..d0a1d7021 100644 --- a/app/Http/Livewire/Project/New/PublicGitRepository.php +++ b/app/Http/Livewire/Project/New/PublicGitRepository.php @@ -28,13 +28,13 @@ class PublicGitRepository extends Component public $gitlab_apps; public bool $is_static = false; - public string $publish_directory = ''; + public null|string $publish_directory = null; protected $rules = [ 'public_repository_url' => 'required|url', 'port' => 'required|numeric', 'is_static' => 'required|boolean', - 'publish_directory' => 'string', + 'publish_directory' => 'nullable|string', ]; public function mount() { diff --git a/database/seeders/ProductionSeeder.php b/database/seeders/ProductionSeeder.php index 298d8cbf5..8334cd5a4 100644 --- a/database/seeders/ProductionSeeder.php +++ b/database/seeders/ProductionSeeder.php @@ -32,21 +32,26 @@ class ProductionSeeder extends Seeder // Save SSH Keys for the Coolify Host $coolify_key_name = "id.root@host.docker.internal"; $coolify_key = Storage::disk('local')->get("ssh-keys/{$coolify_key_name}"); - $coolify_key_in_database = PrivateKey::where('name', 'Coolify Host'); - if (!$coolify_key && $coolify_key_in_database->exists()) { - Storage::disk('local')->put("ssh-keys/{$coolify_key_name}", $coolify_key_in_database->first()->private_key); + if ($coolify_key) { + $private_key = PrivateKey::find(0); + if ($private_key == null) { + PrivateKey::create([ + 'id' => 0, + 'name' => 'localhost\'s key', + 'description' => 'The private key for the Coolify host machine (localhost).', + 'private_key' => $coolify_key, + 'team_id' => 0, + ]); + } else { + $private_key->private_key = $coolify_key; + $private_key->save(); + } + } else { + echo "No SSH key found for the Coolify host machine (localhost).\n"; + echo "Please generate one and save it in storage/app/ssh-keys/{$coolify_key_name}\n"; + exit(1); } - if ($coolify_key && !$coolify_key_in_database->exists()) { - PrivateKey::create([ - 'id' => 0, - 'name' => 'localhost\'s key', - 'description' => 'The private key for the Coolify host machine (localhost).', - 'private_key' => $coolify_key, - 'team_id' => 0, - ]); - } - // Add Coolify host (localhost) as Server if it doesn't exist if (Server::find(0) == null) { diff --git a/docker/builder/Dockerfile b/docker/builder/Dockerfile index bbeca59b1..5499375c5 100644 --- a/docker/builder/Dockerfile +++ b/docker/builder/Dockerfile @@ -22,5 +22,5 @@ RUN curl -sSL https://nixpacks.com/install.sh | bash RUN chmod +x ~/.docker/cli-plugins/docker-compose /usr/bin/docker /usr/local/bin/pack ENTRYPOINT ["/sbin/tini", "--"] -CMD ["sh", "-c", "while true; do sleep 69420; done"] +CMD ["sh", "-c", "while true; do sleep 3600; done"] diff --git a/docker/prod-ssu/etc/s6-overlay/s6-rc.d/db-migration/up b/docker/prod-ssu/etc/s6-overlay/s6-rc.d/db-migration/up index 250d5d8b1..16d04afa2 100644 --- a/docker/prod-ssu/etc/s6-overlay/s6-rc.d/db-migration/up +++ b/docker/prod-ssu/etc/s6-overlay/s6-rc.d/db-migration/up @@ -1,2 +1,2 @@ #!/command/execlineb -P -php /var/www/html/artisan migrate --force --isolated +su - webuser -c "php /var/www/html/artisan migrate --force --isolated" diff --git a/scripts/install.sh b/scripts/install.sh index c3664e4ca..40ab1e255 100644 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -20,7 +20,7 @@ mkdir -p /data/coolify/ssh-keys mkdir -p /data/coolify/proxy mkdir -p /data/coolify/source -chown -R root:root /data +chown -R 9999:root /data chmod -R 700 /data if [ ! -z "$(ls -A /data/coolify/source/.gitignore)" ]; then @@ -42,6 +42,7 @@ fi # Generate an ssh key (ed25519) at /data/coolify/ssh-keys/id.root@host.docker.internal if [ ! -f /data/coolify/ssh-keys/id.root@host.docker.internal ]; then ssh-keygen -t ed25519 -f /data/coolify/ssh-keys/id.root@host.docker.internal -q -N "" -C root@coolify + chown 9999 /data/coolify/ssh-keys/id.root@host.docker.internal fi addSshKey() { @@ -63,4 +64,4 @@ if [ -z "$(grep -w "root@coolify" ~/.ssh/authorized_keys)" ]; then addSshKey fi -docker compose --env-file /data/coolify/source/.env -f /data/coolify/source/docker-compose.yml -f /data/coolify/source/docker-compose.prod.yml up -d +docker compose --env-file /data/coolify/source/.env -f /data/coolify/source/docker-compose.yml -f /data/coolify/source/docker-compose.prod.yml up --pull always