From b7786504b847aac67a19108fa44eca42c0831c10 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Mon, 11 Sep 2023 15:53:05 +0200 Subject: [PATCH] wip: nixpacksarchive --- .../Livewire/Project/Application/General.php | 2 + app/Http/Middleware/IsBoardingFlow.php | 2 +- app/Jobs/ApplicationDeploymentJob.php | 10 ++ composer.json | 3 +- composer.lock | 112 +++++++++++++++++- ...057_add_nixpkgsarchive_to_applications.php | 22 ++++ docker/coolify-helper/Dockerfile | 2 +- docker/testing-host/Dockerfile | 2 +- .../project/application/general.blade.php | 16 ++- 9 files changed, 161 insertions(+), 10 deletions(-) create mode 100644 database/migrations/2023_08_22_071057_add_nixpkgsarchive_to_applications.php diff --git a/app/Http/Livewire/Project/Application/General.php b/app/Http/Livewire/Project/Application/General.php index 80054d5db..13d73c36e 100644 --- a/app/Http/Livewire/Project/Application/General.php +++ b/app/Http/Livewire/Project/Application/General.php @@ -48,6 +48,7 @@ class General extends Component 'application.ports_exposes' => 'required', 'application.ports_mappings' => 'nullable', 'application.dockerfile' => 'nullable', + 'application.nixpkgsarchive' => 'nullable', ]; protected $validationAttributes = [ 'application.name' => 'name', @@ -66,6 +67,7 @@ class General extends Component 'application.ports_exposes' => 'Ports exposes', 'application.ports_mappings' => 'Ports mappings', 'application.dockerfile' => 'Dockerfile', + 'application.nixpkgsarchive' => 'Nixpkgs archive', ]; public function instantSave() diff --git a/app/Http/Middleware/IsBoardingFlow.php b/app/Http/Middleware/IsBoardingFlow.php index e0542a57a..5858fe191 100644 --- a/app/Http/Middleware/IsBoardingFlow.php +++ b/app/Http/Middleware/IsBoardingFlow.php @@ -15,7 +15,7 @@ class IsBoardingFlow */ public function handle(Request $request, Closure $next): Response { - ray()->showQueries()->color('orange'); + // ray()->showQueries()->color('orange'); if (showBoarding() && !in_array($request->path(), allowedPathsForBoardingAccounts())) { return redirect('boarding'); } diff --git a/app/Jobs/ApplicationDeploymentJob.php b/app/Jobs/ApplicationDeploymentJob.php index d5431b0e8..53a6c1406 100644 --- a/app/Jobs/ApplicationDeploymentJob.php +++ b/app/Jobs/ApplicationDeploymentJob.php @@ -28,6 +28,8 @@ use Symfony\Component\Yaml\Yaml; use Throwable; use Visus\Cuid2\Cuid2; +use Yosymfony\Toml\Toml; +use Yosymfony\Toml\TomlArray; class ApplicationDeploymentJob implements ShouldQueue { @@ -411,6 +413,7 @@ private function cleanup_git() private function generate_nixpacks_confs() { + ray('nixpkgsarchive', $this->application->nixpkgsarchive); $this->execute_remote_command( [ "echo -n 'Generating nixpacks configuration.'", @@ -419,6 +422,13 @@ private function generate_nixpacks_confs() [$this->execute_in_builder("cp {$this->workdir}/.nixpacks/Dockerfile {$this->workdir}/Dockerfile")], [$this->execute_in_builder("rm -f {$this->workdir}/.nixpacks/Dockerfile")] ); + + // if ($this->application->nixpkgsarchive) { + // $this->execute_remote_command([ + // $this->execute_in_builder("cat {$this->workdir}/nixpacks.toml"), "hidden" => true, "save" => 'nixpacks_toml' + // ]); + + // } } private function nixpacks_build_cmd() diff --git a/composer.json b/composer.json index c8acddbe5..79f3793dd 100644 --- a/composer.json +++ b/composer.json @@ -35,7 +35,8 @@ "spatie/url": "^2.2", "stripe/stripe-php": "^12.0", "symfony/yaml": "^6.2", - "visus/cuid2": "^2.0.0" + "visus/cuid2": "^2.0.0", + "yosymfony/toml": "^1.0" }, "require-dev": { "fakerphp/faker": "^v1.21.0", diff --git a/composer.lock b/composer.lock index cef0f8b2b..63d0c626d 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "0603276b60e77cd859fabacdaaf31550", + "content-hash": "cf138424c896f30b035bc8cdff63e8d1", "packages": [ { "name": "aws/aws-crt-php", @@ -9771,6 +9771,116 @@ }, "time": "2022-06-03T18:03:27+00:00" }, + { + "name": "yosymfony/parser-utils", + "version": "v2.0.0", + "source": { + "type": "git", + "url": "https://github.com/yosymfony/parser-utils.git", + "reference": "00bec9a12722b21f2baf7f9db35f127e90c162c9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/yosymfony/parser-utils/zipball/00bec9a12722b21f2baf7f9db35f127e90c162c9", + "reference": "00bec9a12722b21f2baf7f9db35f127e90c162c9", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "require-dev": { + "phpunit/phpunit": "^6" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "psr-4": { + "Yosymfony\\ParserUtils\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Victor Puertas", + "email": "vpgugr@gmail.com", + "homepage": "http://yosymfony.com" + } + ], + "description": "Parser utilities", + "homepage": "http://github.com/yosymfony/toml", + "keywords": [ + "lexer", + "parser" + ], + "support": { + "issues": "https://github.com/yosymfony/parser-utils/issues", + "source": "https://github.com/yosymfony/parser-utils/tree/master" + }, + "time": "2018-06-29T15:31:11+00:00" + }, + { + "name": "yosymfony/toml", + "version": "v1.0.4", + "source": { + "type": "git", + "url": "https://github.com/yosymfony/toml.git", + "reference": "bdab92ad920d0e36810a3a3e4a998d23f3498f8e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/yosymfony/toml/zipball/bdab92ad920d0e36810a3a3e4a998d23f3498f8e", + "reference": "bdab92ad920d0e36810a3a3e4a998d23f3498f8e", + "shasum": "" + }, + "require": { + "php": ">=7.1", + "yosymfony/parser-utils": "^2.0" + }, + "require-dev": { + "phpunit/phpunit": "^7.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "psr-4": { + "Yosymfony\\Toml\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Victor Puertas", + "email": "vpgugr@gmail.com", + "homepage": "http://yosymfony.com" + } + ], + "description": "A PHP parser for TOML compatible with specification 0.4.0", + "homepage": "http://github.com/yosymfony/toml", + "keywords": [ + "mojombo", + "parser", + "toml" + ], + "support": { + "issues": "https://github.com/yosymfony/toml/issues", + "source": "https://github.com/yosymfony/toml/tree/master" + }, + "time": "2018-08-08T15:08:14+00:00" + }, { "name": "zbateson/mail-mime-parser", "version": "2.4.0", diff --git a/database/migrations/2023_08_22_071057_add_nixpkgsarchive_to_applications.php b/database/migrations/2023_08_22_071057_add_nixpkgsarchive_to_applications.php new file mode 100644 index 000000000..4c3b283db --- /dev/null +++ b/database/migrations/2023_08_22_071057_add_nixpkgsarchive_to_applications.php @@ -0,0 +1,22 @@ +string('nixpkgsarchive')->nullable(); + }); + } + + public function down(): void + { + Schema::table('teams', function (Blueprint $table) { + $table->dropColumn('nixpkgsarchive'); + }); + } +}; diff --git a/docker/coolify-helper/Dockerfile b/docker/coolify-helper/Dockerfile index 301322c63..45834de78 100644 --- a/docker/coolify-helper/Dockerfile +++ b/docker/coolify-helper/Dockerfile @@ -10,7 +10,7 @@ ARG DOCKER_BUILDX_VERSION=0.11.2 # https://github.com/buildpacks/pack/releases ARG PACK_VERSION=0.30.0 # https://github.com/railwayapp/nixpacks/releases -ARG NIXPACKS_VERSION=1.13.0 +ARG NIXPACKS_VERSION=1.14.0 USER root WORKDIR /artifacts diff --git a/docker/testing-host/Dockerfile b/docker/testing-host/Dockerfile index 6783e4f69..3a1e053a5 100644 --- a/docker/testing-host/Dockerfile +++ b/docker/testing-host/Dockerfile @@ -10,7 +10,7 @@ ARG DOCKER_BUILDX_VERSION=0.11.2 # https://github.com/buildpacks/pack/releases ARG PACK_VERSION=0.30.0 # https://github.com/railwayapp/nixpacks/releases -ARG NIXPACKS_VERSION=1.13.0 +ARG NIXPACKS_VERSION=1.14.0 USER root WORKDIR /root diff --git a/resources/views/livewire/project/application/general.blade.php b/resources/views/livewire/project/application/general.blade.php index f8d5aff37..768f19d7e 100644 --- a/resources/views/livewire/project/application/general.blade.php +++ b/resources/views/livewire/project/application/general.blade.php @@ -26,11 +26,17 @@ @endif @endif - - - - - +
+ + + + + + {{-- @if ($application->build_pack === 'nixpacks') + + @endif --}} +
@if ($application->settings->is_static)