From a4b44bacc18d008eea77fe2943c6a5b6d48826ba Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Tue, 5 Sep 2023 15:43:56 +0200 Subject: [PATCH] updates --- app/Actions/Database/StartPostgresql.php | 2 +- app/Actions/Server/InstallDocker.php | 10 ++++++++-- app/Jobs/DatabaseBackupJob.php | 4 ++-- docker/testing-host/Dockerfile | 19 ++++++++++++++++++- scripts/generate_pg_data.sh | 2 ++ scripts/install.sh | 4 +--- 6 files changed, 32 insertions(+), 9 deletions(-) create mode 100644 scripts/generate_pg_data.sh diff --git a/app/Actions/Database/StartPostgresql.php b/app/Actions/Database/StartPostgresql.php index ba427a93d..c2d7e8a80 100644 --- a/app/Actions/Database/StartPostgresql.php +++ b/app/Actions/Database/StartPostgresql.php @@ -65,7 +65,7 @@ public function __invoke(Server $server, StandalonePostgresql $database) ], 'networks' => [ $this->database->destination->network => [ - 'external' => false, + 'external' => true, 'name' => $this->database->destination->network, 'attachable' => true, ] diff --git a/app/Actions/Server/InstallDocker.php b/app/Actions/Server/InstallDocker.php index a7408b2cc..a85981c6b 100644 --- a/app/Actions/Server/InstallDocker.php +++ b/app/Actions/Server/InstallDocker.php @@ -10,8 +10,14 @@ class InstallDocker { public function __invoke(Server $server, Team $team) { - $dockerVersion = '23.0'; - $config = base64_encode('{ "live-restore": true }'); + $dockerVersion = '24.0'; + $config = base64_encode('{ + "log-driver": "json-file", + "log-opts": { + "max-size": "10m", + "max-file": "3" + } + }'); if (isDev()) { $activity = remote_process([ "echo ####### Installing Prerequisites...", diff --git a/app/Jobs/DatabaseBackupJob.php b/app/Jobs/DatabaseBackupJob.php index 6e1ee2f0c..44873d4af 100644 --- a/app/Jobs/DatabaseBackupJob.php +++ b/app/Jobs/DatabaseBackupJob.php @@ -77,7 +77,7 @@ public function handle(): void $ip = Str::slug($this->server->ip); $this->backup_dir = backup_dir() . "/coolify" . "/coolify-db-$ip"; } - $this->backup_file = "/dumpall-" . Carbon::now()->timestamp . ".sql"; + $this->backup_file = "/dumpall-" . Carbon::now()->timestamp . ".dump"; $this->backup_location = $this->backup_dir . $this->backup_file; $this->backup_log = ScheduledDatabaseBackupExecution::create([ @@ -107,7 +107,7 @@ private function backup_standalone_postgresql(): void try { ray($this->backup_dir); $commands[] = "mkdir -p " . $this->backup_dir; - $commands[] = "docker exec $this->container_name pg_dumpall -U {$this->database->postgres_user} > $this->backup_location"; + $commands[] = "docker exec $this->container_name pg_dump -Fc -U {$this->database->postgres_user} > $this->backup_location"; $this->backup_output = instant_remote_process($commands, $this->server); diff --git a/docker/testing-host/Dockerfile b/docker/testing-host/Dockerfile index 0fed9d014..6783e4f69 100644 --- a/docker/testing-host/Dockerfile +++ b/docker/testing-host/Dockerfile @@ -1,11 +1,28 @@ - FROM debian:12-slim +ARG TARGETPLATFORM +# https://download.docker.com/linux/static/stable/ +ARG DOCKER_VERSION=24.0.5 +# https://github.com/docker/compose/releases +ARG DOCKER_COMPOSE_VERSION=2.21.0 +# https://github.com/docker/buildx/releases +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 + USER root WORKDIR /root ENV PATH "$PATH:/host/usr/local/sbin:/host/usr/local/bin:/host/usr/sbin:/host/usr/bin:/host/sbin:/host/bin" RUN apt update && apt -y install openssh-client openssh-server curl wget git jq jc +RUN mkdir -p ~/.docker/cli-plugins +RUN curl -sSL https://github.com/docker/buildx/releases/download/v${DOCKER_BUILDX_VERSION}/buildx-v${DOCKER_BUILDX_VERSION}.linux-amd64 -o ~/.docker/cli-plugins/docker-buildx +RUN curl -sSL https://github.com/docker/compose/releases/download/v${DOCKER_COMPOSE_VERSION}/docker-compose-linux-x86_64 -o ~/.docker/cli-plugins/docker-compose +RUN (curl -sSL https://download.docker.com/linux/static/stable/x86_64/docker-${DOCKER_VERSION}.tgz | tar -C /usr/bin/ --no-same-owner -xzv --strip-components=1 docker/docker) +RUN chmod +x ~/.docker/cli-plugins/docker-compose /usr/bin/docker /root/.docker/cli-plugins/docker-buildx + # Setup sshd RUN ssh-keygen -A diff --git a/scripts/generate_pg_data.sh b/scripts/generate_pg_data.sh new file mode 100644 index 000000000..009ca697a --- /dev/null +++ b/scripts/generate_pg_data.sh @@ -0,0 +1,2 @@ +psql -U postgres -c "create table if not exists test (id SERIAL UNIQUE NOT NULL,article TEXT);" +psql -U postgres -c "insert into test (article) select md5(random()::text) from generate_series(1, 1000000) s(i);" diff --git a/scripts/install.sh b/scripts/install.sh index 8e30ecf32..e7d7b02b7 100644 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -6,7 +6,7 @@ ########### VERSION="1.0.0" -DOCKER_VERSION="23.0" +DOCKER_VERSION="24.0" CDN="https://cdn.coollabs.io/coolify" OS_TYPE=$(cat /etc/os-release | grep -w "ID" | cut -d "=" -f 2 | tr -d '"') @@ -54,7 +54,6 @@ mkdir -p /etc/docker test -s /etc/docker/daemon.json && cp /etc/docker/daemon.json /etc/docker/daemon.json.original-$DATE || cat >/etc/docker/daemon.json </etc/docker/daemon.json.coolify <