diff --git a/Makefile b/Makefile index 8eed1fe5..1866799f 100644 --- a/Makefile +++ b/Makefile @@ -25,7 +25,6 @@ help: @echo " " @echo " Daemon register(any OS, host:port)" @echo " dock2port will map docker socket to port. first use this!" - @echo " dock-certs deploy certs, second use this!" @echo " dock-port27 create docker daemon for Nextcloud 27 (host.docker.internal:8443)" @echo " dock-port28 create docker daemon for Nextcloud 28 (host.docker.internal:8443)" @echo " dock-port create docker daemons for Nextcloud Last (host.docker.internal:8443)" @@ -35,84 +34,72 @@ dock-sock27: @echo "creating daemon for nextcloud 'stable27' container" docker exec master-stable27-1 sudo -u www-data php occ app_api:daemon:unregister docker_dev || true docker exec master-stable27-1 sudo -u www-data php occ app_api:daemon:register \ - docker_dev Docker docker-install unix-socket /var/run/docker.sock http://stable27.local/index.php --net=master_default + docker_dev Docker docker-install http /var/run/docker.sock http://stable27.local/index.php --net=master_default .PHONY: dock-sock27-gpu dock-sock27-gpu: @echo "creating daemon with NVIDIA gpu for nextcloud 'stable27' container" docker exec master-stable27-1 sudo -u www-data php occ app_api:daemon:unregister docker_dev_nvidia || true docker exec master-stable27-1 sudo -u www-data php occ app_api:daemon:register \ - docker_dev_gpu "Docker with GPU" docker-install unix-socket /var/run/docker.sock http://stable27.local/index.php --net=master_default --gpu --set-default + docker_dev_gpu "Docker with GPU" docker-install http /var/run/docker.sock http://stable27.local/index.php --net=master_default --gpu --set-default .PHONY: dock-sock28 dock-sock28: @echo "creating daemon for nextcloud 'stable28' container" docker exec master-stable28-1 sudo -u www-data php occ app_api:daemon:unregister docker_dev || true docker exec master-stable28-1 sudo -u www-data php occ app_api:daemon:register \ - docker_dev Docker docker-install unix-socket /var/run/docker.sock http://stable28.local/index.php --net=master_default + docker_dev Docker docker-install http /var/run/docker.sock http://stable28.local/index.php --net=master_default .PHONY: dock-sock28-gpu dock-sock28-gpu: @echo "creating daemon with NVIDIA gpu for nextcloud 'stable28' container" docker exec master-stable28-1 sudo -u www-data php occ app_api:daemon:unregister docker_dev_nvidia || true docker exec master-stable28-1 sudo -u www-data php occ app_api:daemon:register \ - docker_dev_gpu "Docker with GPU" docker-install unix-socket /var/run/docker.sock http://stable28.local/index.php --net=master_default --gpu --set-default + docker_dev_gpu "Docker with GPU" docker-install http /var/run/docker.sock http://stable28.local/index.php --net=master_default --gpu --set-default .PHONY: dock-sock dock-sock: @echo "creating daemon for nextcloud 'master' container" docker exec master-nextcloud-1 sudo -u www-data php occ app_api:daemon:unregister docker_dev || true docker exec master-nextcloud-1 sudo -u www-data php occ app_api:daemon:register \ - docker_dev Docker docker-install unix-socket /var/run/docker.sock http://nextcloud.local/index.php --net=master_default + docker_dev Docker docker-install http /var/run/docker.sock http://nextcloud.local/index.php --net=master_default .PHONY: dock-sock-gpu dock-sock-gpu: @echo "creating daemon with NVIDIA gpu for nextcloud 'master' container" docker exec master-nextcloud-1 sudo -u www-data php occ app_api:daemon:unregister docker_dev_nvidia || true docker exec master-nextcloud-1 sudo -u www-data php occ app_api:daemon:register \ - docker_dev_gpu "Docker with GPU" docker-install unix-socket /var/run/docker.sock http://nextcloud.local/index.php --net=master_default --gpu --set-default + docker_dev_gpu "Docker with GPU" docker-install http /var/run/docker.sock http://nextcloud.local/index.php --net=master_default --gpu --set-default .PHONY: dock2port dock2port: - @echo "deploying kekru/docker-remote-api-tls..." - docker run --name dock_api2port -d -p 6443:443 -v /var/run/docker.sock:/var/run/docker.sock:ro \ - --env CREATE_CERTS_WITH_PW=supersecret --env CERT_HOSTNAME=host.docker.internal \ - -v `pwd`/certs:/data/certs kekru/docker-remote-api-tls:master - @echo "waiting 20 seconds to finish generating certificates..." - sleep 20 - -.PHONE: dock-certs -dock-certs: - @echo "copying certs to Nextcloud 27" - docker cp ./certs/client/ master-stable27-1:/ || echo "Failed copying certs to Nextcloud 27" - docker exec master-stable27-1 sudo -u www-data php occ security:certificates:import /client/ca.pem || true - @echo "copying certs to Nextcloud 28" - docker cp ./certs/client/ master-stable28-1:/ || echo "Failed copying certs to Nextcloud 28" - docker exec master-stable28-1 sudo -u www-data php occ security:certificates:import /client/ca.pem || true - @echo "copying certs to Nextcloud Last" - docker cp ./certs/client/ master-nextcloud-1:/ || echo "Failed copying certs to Nextcloud 'Last'" - docker exec master-nextcloud-1 sudo -u www-data php occ security:certificates:import /client/ca.pem || true + @echo "deploying Docker-Socket-Proxy.." + docker run -e NC_HAPROXY_PASSWORD="some_secure_password" \ + -v /var/run/docker.sock:/var/run/docker.sock \ + --name aa-docker-socket-proxy -h aa-docker-socket-proxy \ + --net=master_default \ + --restart unless-stopped --privileged -d ghcr.io/cloud-py-api/aa-docker-socket-proxy:latest .PHONY: dock-port27 dock-port27: @echo "creating daemon for nextcloud '27' container" docker exec master-stable27-1 sudo -u www-data php occ app_api:daemon:unregister docker_dev || true docker exec master-stable27-1 sudo -u www-data php occ app_api:daemon:register \ - docker_dev Docker docker-install https host.docker.internal:6443 http://stable27.local/index.php \ - --net=master_default --ssl_cert /client/cert.pem --ssl_key /client/key.pem + docker_dev Docker docker-install http aa-docker-socket-proxy:2375 http://stable27.local/index.php \ + --net=master_default --haproxy_password="some_secure_password" .PHONY: dock-port28 dock-port28: @echo "creating daemon for nextcloud '27' container" docker exec master-stable28-1 sudo -u www-data php occ app_api:daemon:unregister docker_dev || true docker exec master-stable28-1 sudo -u www-data php occ app_api:daemon:register \ - docker_dev Docker docker-install https host.docker.internal:6443 http://stable28.local/index.php \ - --net=master_default --ssl_cert /client/cert.pem --ssl_key /client/key.pem + docker_dev Docker docker-install http aa-docker-socket-proxy:2375 http://stable28.local/index.php \ + --net=master_default --haproxy_password="some_secure_password" .PHONY: dock-port dock-port: @echo "creating daemon for nextcloud 'master' container" docker exec master-nextcloud-1 sudo -u www-data php occ app_api:daemon:unregister docker_dev || true docker exec master-nextcloud-1 sudo -u www-data php occ app_api:daemon:register \ - docker_dev Docker docker-install https host.docker.internal:6443 http://nextcloud.local/index.php \ - --net=master_default --ssl_cert /client/cert.pem --ssl_key /client/key.pem + docker_dev Docker docker-install http aa-docker-socket-proxy:2375 http://nextcloud.local/index.php \ + --net=master_default --haproxy_password="some_secure_password" diff --git a/lib/Command/Daemon/RegisterDaemon.php b/lib/Command/Daemon/RegisterDaemon.php index 10198bf4..26dbdaed 100644 --- a/lib/Command/Daemon/RegisterDaemon.php +++ b/lib/Command/Daemon/RegisterDaemon.php @@ -42,7 +42,7 @@ protected function configure(): void { $this->addOption('set-default', null, InputOption::VALUE_NONE, 'Set DaemonConfig as default'); - $this->addUsage('local_docker "Docker local" "docker-install" "unix-socket" "/var/run/docker.sock" "http://nextcloud.local" --net=nextcloud'); + $this->addUsage('local_docker "Docker local" "docker-install" "http" "/var/run/docker.sock" "http://nextcloud.local" --net=nextcloud'); } protected function execute(InputInterface $input, OutputInterface $output): int { @@ -60,6 +60,15 @@ protected function execute(InputInterface $input, OutputInterface $output): int 'gpu' => $input->getOption('gpu') ?? false, ]; + if (($protocol !== 'http') && ($protocol !== 'https')) { + $output->writeln('Value error: The protocol must be `http` or `https`.'); + return 1; + } + if (($acceptsDeployId === 'manual-install') && ($protocol !== 'http')) { + $output->writeln('Value error: Manual-install daemon supports only `http` protocol.'); + return 1; + } + $daemonConfig = $this->daemonConfigService->registerDaemonConfig([ 'name' => $name, 'display_name' => $displayName,