Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

Update UI elements and add new build pack option (static)

Andras Bacsaifb2598f2e464
diff --git a/app/Jobs/ApplicationDeploymentJob.php b/app/Jobs/ApplicationDeploymentJob.php
index 74d8f2af2a..4695660601 100644
--- a/app/Jobs/ApplicationDeploymentJob.php
+++ b/app/Jobs/ApplicationDeploymentJob.php
@@ -192,6 +192,8 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
$this->deploy_dockerimage_buildpack();
} else if ($this->application->build_pack === 'dockerfile') {
$this->deploy_dockerfile_buildpack();
+ } else if ($this->application->build_pack === 'static') {
+ $this->deploy_static_buildpack();
} else {
if ($this->pull_request_id !== 0) {
$this->deploy_pull_request();
@@ -227,6 +229,14 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
[
"docker rm -f {$this->deployment_uuid} >/dev/null 2>&1",
"hidden" => true,
+ "ignore_errors" => true,
+ ]
+ );
+ $this->execute_remote_command(
+ [
+ "docker image prune -f >/dev/null 2>&1",
+ "hidden" => true,
+ "ignore_errors" => true,
]
);
}
@@ -421,6 +431,23 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
$this->build_image();
$this->rolling_update();
}
+ private function deploy_static_buildpack()
+ {
+ $this->execute_remote_command(
+ [
+ "echo 'Starting deployment of {$this->customRepository}:{$this->application->git_branch}.'"
+ ],
+ );
+ $this->prepare_builder_image();
+ $this->check_git_if_build_needed();
+ $this->set_base_dir();
+ $this->generate_image_names();
+ $this->clone_repository();
+ $this->cleanup_git();
+ $this->build_image();
+ $this->generate_compose_file();
+ $this->rolling_update();
+ }
private function rolling_update()
{
@@ -910,22 +937,53 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
private function build_image()
{
- $this->execute_remote_command([
- "echo -n 'Building docker image for your application. To check the current progress, click on Show Debug Logs.'",
- ]);
-
- if ($this->application->settings->is_static) {
+ if ($this->application->build_pack === 'static') {
$this->execute_remote_command([
- executeInDocker($this->deployment_uuid, "docker build $this->buildTarget $this->addHosts --network host -f {$this->workdir}/{$this->dockerfile_location} {$this->build_args} --progress plain -t $this->build_image_name {$this->workdir}"), "hidden" => true
+ "echo -n 'Static deployment. Copying static assets to the image.'",
]);
+ } else {
+ $this->execute_remote_command([
+ "echo -n 'Building docker image for your application. To check the current progress, click on Show Debug Logs.'",
+ ]);
+ }
- $dockerfile = base64_encode("FROM {$this->application->static_image}
+ if ($this->application->settings->is_static || $this->application->build_pack === 'static') {
+ if ($this->application->build_pack === 'static') {
+ $dockerfile = base64_encode("FROM {$this->application->static_image}
+WORKDIR /usr/share/nginx/html/
+LABEL coolify.deploymentId={$this->deployment_uuid}
+COPY . .
+RUN rm -f /usr/share/nginx/html/nginx.conf
+RUN rm -f /usr/share/nginx/html/Dockerfile
+COPY ./nginx.conf /etc/nginx/conf.d/default.conf");
+ $nginx_config = base64_encode("server {
+ listen 80;
+ listen [::]:80;
+ server_name localhost;
+
+ location / {
+ root /usr/share/nginx/html;
+ index index.html;
+ try_files \$uri \$uri.html \$uri/index.html \$uri/ /index.html =404;
+ }
+
+ error_page 500 502 503 504 /50x.html;
+ location = /50x.html {
+ root /usr/share/nginx/html;
+ }
+ }");
+ } else {
+ $this->execute_remote_command([
+ executeInDocker($this->deployment_uuid, "docker build $this->buildTarget $this->addHosts --network host -f {$this->workdir}/{$this->dockerfile_location} {$this->build_args} --progress plain -t $this->build_image_name {$this->workdir}"), "hidden" => true
+ ]);
+
+ $dockerfile = base64_encode("FROM {$this->application->static_image}
WORKDIR /usr/share/nginx/html/
LABEL coolify.deploymentId={$this->deployment_uuid}
COPY --from=$this->build_image_name /app/{$this->application->publish_directory} .
COPY ./nginx.conf /etc/nginx/conf.d/default.conf");
- $nginx_config = base64_encode("server {
+ $nginx_config = base64_encode("server {
listen 80;
listen [::]:80;
server_name localhost;
@@ -941,15 +999,16 @@ COPY ./nginx.conf /etc/nginx/conf.d/default.conf");
root /usr/share/nginx/html;
}
}");
+ }
$this->execute_remote_command(
[
- executeInDocker($this->deployment_uuid, "echo '{$dockerfile}' | base64 -d > {$this->workdir}/Dockerfile-prod")
+ executeInDocker($this->deployment_uuid, "echo '{$dockerfile}' | base64 -d > {$this->workdir}/Dockerfile")
],
[
executeInDocker($this->deployment_uuid, "echo '{$nginx_config}' | base64 -d > {$this->workdir}/nginx.conf")
],
[
- executeInDocker($this->deployment_uuid, "docker build $this->addHosts --network host -f {$this->workdir}/Dockerfile-prod {$this->build_args} --progress plain -t $this->production_image_name {$this->workdir}"), "hidden" => true
+ executeInDocker($this->deployment_uuid, "docker build $this->addHosts --network host -f {$this->workdir}/Dockerfile {$this->build_args} --progress plain -t $this->production_image_name {$this->workdir}"), "hidden" => true
]
);
} else {
diff --git a/resources/js/components/MagicBar.vue b/resources/js/components/MagicBar.vue
index 9797e14b65..4fc1fc5dfa 100644
--- a/resources/js/components/MagicBar.vue
+++ b/resources/js/components/MagicBar.vue
@@ -1,7 +1,7 @@
<template>
<Transition name="fade">
<div>
- <div class="flex items-center p-1 px-2 overflow-hidden transition-all transform rounded cursor-pointer bg-coolgray-200"
+ <div class="flex items-center p-1 px-2 overflow-hidden transition-all transform rounded cursor-pointer bg-coolgray-100"
@click="showCommandPalette = true">
<svg xmlns="http://www.w3.org/2000/svg" class="w-6 h-6 icon" viewBox="0 0 24 24" stroke-width="2"
stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
diff --git a/resources/views/components/navbar-subscription.blade.php b/resources/views/components/navbar-subscription.blade.php
index 06c6c4aad5..4636db475a 100644
--- a/resources/views/components/navbar-subscription.blade.php
+++ b/resources/views/components/navbar-subscription.blade.php
@@ -1,6 +1,6 @@
@auth
<nav class="fixed h-full overflow-hidden overflow-y-auto pt-14 scrollbar">
- <a href="/" class="fixed top-0 z-50 mx-3 mt-3 cursor-pointer bg-coolgray-100"><img
+ <a href="/" class="fixed top-0 z-50 mx-3 mt-3 bg-transparent cursor-pointer"><img
class="transition rounded w-11 h-11" src="{{ asset('coolify-transparent.png') }}"></a>
<ul class="flex flex-col h-full gap-4 menu flex-nowrap">
<li title="Dashboard">
diff --git a/resources/views/components/navbar.blade.php b/resources/views/components/navbar.blade.php
index 0c63a07fba..62d7b1b523 100644
--- a/resources/views/components/navbar.blade.php
+++ b/resources/views/components/navbar.blade.php
@@ -1,6 +1,6 @@
@auth
<nav class="fixed h-full overflow-hidden overflow-y-auto pt-28 scrollbar">
- <a href="/" class="fixed top-0 z-50 mx-3 mt-3 cursor-pointer bg-coolgray-100"><img
+ <a href="/" class="fixed top-0 z-50 mx-3 mt-3 bg-transparent cursor-pointer"><img
class="transition rounded w-11 h-11" src="{{ asset('coolify-transparent.png') }}"></a>
<ul class="flex flex-col h-full gap-4 menu flex-nowrap">
<li title="Dashboard">
diff --git a/resources/views/livewire/project/application/general.blade.php b/resources/views/livewire/project/application/general.blade.php
index 31f0e1cdc0..f59353854d 100644
--- a/resources/views/livewire/project/application/general.blade.php
+++ b/resources/views/livewire/project/application/general.blade.php
@@ -27,10 +27,11 @@
<div class="flex gap-2">
<x-forms.select wire:model="application.build_pack" label="Build Pack" required>
<option value="nixpacks">Nixpacks</option>
+ <option value="static">Static</option>
<option value="dockerfile">Dockerfile</option>
<option value="dockerimage">Docker Image</option>
</x-forms.select>
- @if ($application->settings->is_static)
+ @if ($application->settings->is_static || $application->build_pack === 'static')
<x-forms.select id="application.static_image" label="Static Image" required>
<option value="nginx:alpine">nginx:alpine</option>
<option disabled value="apache:alpine">apache:alpine</option>
@@ -97,7 +98,7 @@
@endif
<h3>Network</h3>
<div class="flex flex-col gap-2 xl:flex-row">
- @if ($application->settings->is_static)
+ @if ($application->settings->is_static || $application->build_pack === 'static')
<x-forms.input id="application.ports_exposes" label="Ports Exposes" readonly />
@else
<x-forms.input placeholder="3000,3001" id="application.ports_exposes" label="Ports Exposes" required