From 43a4b1c9cba462809180c4264bdaf3794e77ff9d Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Mon, 15 May 2023 15:13:34 +0200 Subject: [PATCH] update testing hosts --- .dockerignore | 2 +- .gitignore | 2 +- _testing_hosts/host_2_proxy/.gitignore | 2 - app/Actions/Proxy/InstallProxy.php | 5 +- docker-compose.dev.yml | 7 +-- docker/testing-host/Dockerfile | 53 ++++--------------- docker/testing-host/dummy-project/Dockerfile | 31 ----------- .../dummy-project/docker-compose.yml | 10 ---- docker/testing-host/dummy-project/index.php | 3 -- docker/testing-host/start-container | 3 -- docker/testing-host/supervisord.conf | 13 ----- 11 files changed, 18 insertions(+), 113 deletions(-) delete mode 100644 _testing_hosts/host_2_proxy/.gitignore delete mode 100644 docker/testing-host/dummy-project/Dockerfile delete mode 100644 docker/testing-host/dummy-project/docker-compose.yml delete mode 100644 docker/testing-host/dummy-project/index.php delete mode 100644 docker/testing-host/start-container delete mode 100644 docker/testing-host/supervisord.conf diff --git a/.dockerignore b/.dockerignore index ec0614330..090a80fbb 100644 --- a/.dockerignore +++ b/.dockerignore @@ -19,4 +19,4 @@ yarn-error.log /.vscode /.npm /.bash_history -/_volumes +/_data diff --git a/.gitignore b/.gitignore index 0be87eac1..b666520a4 100644 --- a/.gitignore +++ b/.gitignore @@ -19,7 +19,7 @@ yarn-error.log /.vscode /.npm /.bash_history -/_volumes +/_data # Temp while developing Proxy deployment resources/recipes diff --git a/_testing_hosts/host_2_proxy/.gitignore b/_testing_hosts/host_2_proxy/.gitignore deleted file mode 100644 index d6b7ef32c..000000000 --- a/_testing_hosts/host_2_proxy/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore diff --git a/app/Actions/Proxy/InstallProxy.php b/app/Actions/Proxy/InstallProxy.php index 2cbd4103d..0788fa765 100644 --- a/app/Actions/Proxy/InstallProxy.php +++ b/app/Actions/Proxy/InstallProxy.php @@ -11,7 +11,6 @@ class InstallProxy { - public Collection $networks; public function __invoke(Server $server): Activity { @@ -21,9 +20,9 @@ public function __invoke(Server $server): Activity return $docker['network']; })->unique(); if ($networks->count() === 0) { - $this->networks = collect(['coolify']); + $networks = collect(['coolify']); } - $create_networks_command = $this->networks->map(function ($network) { + $create_networks_command = $networks->map(function ($network) { return "docker network ls --format '{{.Name}}' | grep '^$network$' >/dev/null 2>&1 || docker network create --attachable $network > /dev/null 2>&1"; }); diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index 9cd655181..a59dd6abd 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -36,14 +36,14 @@ services: POSTGRES_DB: "${DB_DATABASE}" POSTGRES_HOST_AUTH_METHOD: "trust" volumes: - - ./_volumes/database/:/var/lib/postgresql/data + - ./_data/_volumes/database/:/var/lib/postgresql/data redis: ports: - "${FORWARD_REDIS_PORT:-6379}:6379" env_file: - .env volumes: - - ./_volumes/redis/:/data + - ./_data/_volumes/redis/:/data vite: image: node:19 working_dir: /var/www/html @@ -57,9 +57,10 @@ services: container_name: coolify-testing-host volumes: - /var/run/docker.sock:/var/run/docker.sock + - "./_data/coolify/proxy/testing-host-1:/data/coolify/proxy" testing-host-2: <<: *testing-host-base container_name: coolify-testing-host-2 volumes: - /var/run/docker.sock:/var/run/docker.sock - - "./_testing_hosts/host_2_proxy:/root/projects/proxy" + - "./_data/coolify/proxy/testing-host-2:/data/coolify/proxy" diff --git a/docker/testing-host/Dockerfile b/docker/testing-host/Dockerfile index 1e8628d87..cd61d6d52 100644 --- a/docker/testing-host/Dockerfile +++ b/docker/testing-host/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:22.04 +FROM alpine:3.17 ARG TARGETPLATFORM # https://download.docker.com/linux/static/stable/ @@ -12,22 +12,10 @@ ARG PACK_VERSION=0.29.0 # https://github.com/railwayapp/nixpacks/releases ARG NIXPACKS_VERSION=1.6.1 -ENV DEBIAN_FRONTEND noninteractive -ENV TZ=UTC - -RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone - -RUN apt-get update \ - && apt-get install -y gnupg gosu curl ca-certificates zip unzip git git-lfs supervisor \ - sqlite3 libcap2-bin libpng-dev python2 dnsutils openssh-server sudo \ - && apt-get -y autoremove \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* - -# Setup sshd -RUN ssh-keygen -A -RUN mkdir -p /run/sshd - +USER root +WORKDIR /root +RUN apk add --no-cache bash curl git git-lfs openssh-client openssh-server tar tini +RUN mkdir -p ~/.docker/cli-plugins RUN if [[ ${TARGETPLATFORM} == 'linux/amd64' ]]; then \ 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 && \ curl -sSL https://github.com/docker/compose/releases/download/v${DOCKER_COMPOSE_VERSION}/docker-compose-linux-x86_64 -o ~/.docker/cli-plugins/docker-compose && \ @@ -36,35 +24,14 @@ RUN if [[ ${TARGETPLATFORM} == 'linux/amd64' ]]; then \ curl -sSL https://nixpacks.com/install.sh | bash && \ chmod +x ~/.docker/cli-plugins/docker-compose /usr/bin/docker /usr/local/bin/pack /root/.docker/cli-plugins/docker-buildx \ ;fi -RUN groupadd docker -# Setup coolify user -RUN useradd -ms /bin/bash coolify -RUN usermod -aG sudo coolify -RUN usermod -aG docker coolify -RUN echo 'coolify ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers - -# Setup ssh'ing into the destination as Coolify User -USER coolify -RUN mkdir -p ~/.ssh -RUN echo "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFuGmoeGq/pojrsyP1pszcNVuZx9iFkCELtxrh31QJ68 coolify@coolify-instance" >> ~/.ssh/authorized_keys - -USER root - -# Setup ssh'ing into the destination as Root +# Setup sshd +RUN ssh-keygen -A +RUN mkdir -p /run/sshd RUN mkdir -p ~/.ssh RUN echo "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFuGmoeGq/pojrsyP1pszcNVuZx9iFkCELtxrh31QJ68 coolify@coolify-instance" >> ~/.ssh/authorized_keys EXPOSE 22 +ENTRYPOINT ["/sbin/tini", "--"] +CMD ["/usr/sbin/sshd", "-D", "-o", "ListenAddress=0.0.0.0"] -COPY start-container /usr/local/bin/start-container -COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf -RUN chmod +x /usr/local/bin/start-container - -WORKDIR /root - -# Prepare projects -RUN mkdir -p projects -COPY dummy-project projects/dummy-project - -ENTRYPOINT ["start-container"] diff --git a/docker/testing-host/dummy-project/Dockerfile b/docker/testing-host/dummy-project/Dockerfile deleted file mode 100644 index e18a991dd..000000000 --- a/docker/testing-host/dummy-project/Dockerfile +++ /dev/null @@ -1,31 +0,0 @@ -FROM ubuntu:22.04 - -ARG WWWGROUP - -WORKDIR /var/www/html - -ENV DEBIAN_FRONTEND noninteractive -ENV TZ=UTC - -RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone - -RUN apt-get update \ - && apt-get install -y gnupg gosu curl ca-certificates zip unzip git git-lfs supervisor sqlite3 libcap2-bin libpng-dev python2 dnsutils \ - && curl -sS 'https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x14aa40ec0831756756d7f66c4f4ea0aae5267a6c' | gpg --dearmor | tee /usr/share/keyrings/ppa_ondrej_php.gpg > /dev/null \ - && echo "deb [signed-by=/usr/share/keyrings/ppa_ondrej_php.gpg] https://ppa.launchpadcontent.net/ondrej/php/ubuntu jammy main" > /etc/apt/sources.list.d/ppa_ondrej_php.list \ - && apt-get update \ - && apt-get install -y php8.2-cli php8.2-dev \ - php8.2-curl php8.2-mbstring php8.2-xml php8.2-zip php8.2-bcmath \ - php8.2-intl php8.2-readline php8.2-msgpack php8.2-igbinary \ - && php -r "readfile('https://getcomposer.org/installer');" | php -- --install-dir=/usr/bin/ --filename=composer \ - && apt-get -y autoremove \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* - -RUN setcap "cap_net_bind_service=+ep" /usr/bin/php8.2 - -EXPOSE 8000 - -COPY . . - -ENTRYPOINT ["php", "-S", "0.0.0.0:8000"] diff --git a/docker/testing-host/dummy-project/docker-compose.yml b/docker/testing-host/dummy-project/docker-compose.yml deleted file mode 100644 index ea23501c2..000000000 --- a/docker/testing-host/dummy-project/docker-compose.yml +++ /dev/null @@ -1,10 +0,0 @@ -version: "3" - -services: - dummy-project: - image: dummy-project - build: - context: . - dockerfile: Dockerfile - extra_hosts: - - "host.docker.internal:host-gateway" diff --git a/docker/testing-host/dummy-project/index.php b/docker/testing-host/dummy-project/index.php deleted file mode 100644 index 42cfa8699..000000000 --- a/docker/testing-host/dummy-project/index.php +++ /dev/null @@ -1,3 +0,0 @@ -