From 23cea9a130649c8955c0433e5c5b49c752c63a70 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Tue, 2 May 2023 15:20:45 +0200 Subject: [PATCH] wip --- app/Http/Livewire/Server/Form.php | 6 +++++ app/Jobs/DeployApplicationJob.php | 7 ++++-- bootstrap/helpers.php | 2 +- docker/builder/Dockerfile | 23 ++++++++++++------- .../views/livewire/server/form.blade.php | 1 + 5 files changed, 28 insertions(+), 11 deletions(-) diff --git a/app/Http/Livewire/Server/Form.php b/app/Http/Livewire/Server/Form.php index 2d9a6cf60..7b512f066 100644 --- a/app/Http/Livewire/Server/Form.php +++ b/app/Http/Livewire/Server/Form.php @@ -23,6 +23,12 @@ class Form extends Component { $this->server = Server::find($this->server_id); } + public function installDocker() + { + $config = base64_encode('{ "live-restore": true }'); + runRemoteCommandSync($this->server, ["mkdir -p /etc/docker/", "touch /etc/docker/daemon.json", "echo '{$config}' | base64 -d > /etc/docker/daemon.json"]); + runRemoteCommandSync($this->server, ['sh -c "$(curl --silent -fsSL https://get.docker.com)"']); + } public function checkConnection() { $this->uptime = runRemoteCommandSync($this->server, ['uptime']); diff --git a/app/Jobs/DeployApplicationJob.php b/app/Jobs/DeployApplicationJob.php index 7fdd48190..9a4393f7c 100644 --- a/app/Jobs/DeployApplicationJob.php +++ b/app/Jobs/DeployApplicationJob.php @@ -123,12 +123,15 @@ class DeployApplicationJob implements ShouldQueue $this->executeNow([ "echo 'Starting deployment of {$this->application->git_repository}:{$this->application->git_branch}...'", "echo -n 'Pulling latest version of the builder image (ghcr.io/coollabsio/coolify-builder)... '", - "docker run --pull=always -d --name {$this->deployment_uuid} --rm -v /var/run/docker.sock:/var/run/docker.sock ghcr.io/coollabsio/coolify-builder", - "echo 'Done.'", ]); + $this->executeNow([ + "docker run --pull=always -d --name {$this->deployment_uuid} --rm -v /var/run/docker.sock:/var/run/docker.sock ghcr.io/coollabsio/coolify-builder", + ], isDebuggable: true); + // Import git repository $this->executeNow([ + "echo 'Done.'", "echo -n 'Importing {$this->application->git_repository}:{$this->application->git_branch} to {$this->workdir}... '" ]); diff --git a/bootstrap/helpers.php b/bootstrap/helpers.php index 830df31c5..7e86b016c 100644 --- a/bootstrap/helpers.php +++ b/bootstrap/helpers.php @@ -131,7 +131,7 @@ if (!function_exists('runRemoteCommandSync')) { if (!$throwError) { return false; } - Log::error($output); + Log::error($process->errorOutput()); throw new \RuntimeException('There was an error running the command.'); } return $output; diff --git a/docker/builder/Dockerfile b/docker/builder/Dockerfile index aa7e9de1e..868c48cd3 100644 --- a/docker/builder/Dockerfile +++ b/docker/builder/Dockerfile @@ -4,11 +4,11 @@ ARG TARGETPLATFORM # https://download.docker.com/linux/static/stable/ ARG DOCKER_VERSION=23.0.5 # https://github.com/docker/compose/releases -# Reverted to 2.6.1 because of this https://github.com/docker/compose/issues/9704. 2.9.0 still has a bug. -# Using the latest now ARG DOCKER_COMPOSE_VERSION=2.17.3 +# https://github.com/docker/buildx/releases +ARG DOCKER_BUILDX_VERSION=0.10.4 # https://github.com/buildpacks/pack/releases -ARG PACK_VERSION=0.27.0 +ARG PACK_VERSION=0.29.0 # https://github.com/railwayapp/nixpacks/releases ARG NIXPACKS_VERSION=1.6.1 @@ -16,11 +16,18 @@ USER root WORKDIR /artifacts RUN apk add --no-cache bash curl git git-lfs openssh-client tar tini RUN mkdir -p ~/.docker/cli-plugins -RUN curl -SL https://cdn.coollabs.io/bin/$TARGETPLATFORM/docker-$DOCKER_VERSION -o /usr/bin/docker -RUN curl -SL https://cdn.coollabs.io/bin/$TARGETPLATFORM/docker-compose-linux-$DOCKER_COMPOSE_VERSION -o ~/.docker/cli-plugins/docker-compose -RUN curl -SL https://cdn.coollabs.io/bin/$TARGETPLATFORM/pack-$PACK_VERSION -o /usr/local/bin/pack -RUN curl -sSL https://nixpacks.com/install.sh | bash -RUN chmod +x ~/.docker/cli-plugins/docker-compose /usr/bin/docker /usr/local/bin/pack +RUN if [[ ${TARGETPLATFORM} == 'linux/amd64' ]]; then \ + curl -SL https://github.com/docker/buildx/releases/download/v${DOCKER_BUILDX_VERSION}/buildx-v0.10.4.linux-amd64 -o ~/.docker/cli-plugins/docker-buildx && \ + curl -SL https://github.com/docker/compose/releases/download/v${DOCKER_COMPOSE_VERSION}}/docker-compose-linux-x86_64 -o ~/.docker/cli-plugins/docker-compose && \ + (curl -sSL "https://github.com/buildpacks/pack/releases/download/v${PACK_VERSION}/pack-v${PACK_VERSION}-linux.tgz" | sudo tar -C /usr/local/bin/ --no-same-owner -xzv pack) && \ + curl -sSL https://nixpacks.com/install.sh | bash && \ + chmod +x ~/.docker/cli-plugins/docker-compose /usr/bin/docker /usr/local/bin/pack; \ + fi +# RUN curl -SL https://cdn.coollabs.io/bin/$TARGETPLATFORM/docker-$DOCKER_VERSION -o /usr/bin/docker +# RUN curl -SL https://cdn.coollabs.io/bin/$TARGETPLATFORM/docker-compose-linux-$DOCKER_COMPOSE_VERSION -o ~/.docker/cli-plugins/docker-compose +# RUN curl -SL https://cdn.coollabs.io/bin/$TARGETPLATFORM/pack-$PACK_VERSION -o /usr/local/bin/pack +# 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 3600; done"] diff --git a/resources/views/livewire/server/form.blade.php b/resources/views/livewire/server/form.blade.php index 1226bf3f8..15ead9a79 100644 --- a/resources/views/livewire/server/form.blade.php +++ b/resources/views/livewire/server/form.blade.php @@ -22,6 +22,7 @@ Submit + @isset($uptime)