This commit is contained in:
Andras Bacsai 2023-05-02 15:20:45 +02:00
parent 53e2960ffd
commit 23cea9a130
5 changed files with 28 additions and 11 deletions

View File

@ -23,6 +23,12 @@ public function mount()
{
$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']);

View File

@ -123,12 +123,15 @@ public function handle(): void
$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}... '"
]);

View File

@ -131,7 +131,7 @@ function runRemoteCommandSync(Server $server, array $command, $throwError = true
if (!$throwError) {
return false;
}
Log::error($output);
Log::error($process->errorOutput());
throw new \RuntimeException('There was an error running the command.');
}
return $output;

View File

@ -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"]

View File

@ -22,6 +22,7 @@
Submit
</button>
<button wire:click.prevent='checkConnection'>Check Connection</button>
<button wire:click.prevent='installDocker'>Install Docker</button>
</div>
</form>
@isset($uptime)