From 31077bd2c4834a4e059689f0964e8fc1dee1b0a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krist=C3=B3f=20Hauser?= Date: Wed, 1 May 2024 15:53:47 +0200 Subject: [PATCH 1/2] feat: use `ss -tulnp | grep ':PORT '` instead of `lsof -i :PORT` On GCP instances lsof -i gives false positive about port usage. Using ss -tulnp fixes this --- docker/prod.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/prod.sh b/docker/prod.sh index 6408807d..caafe960 100644 --- a/docker/prod.sh +++ b/docker/prod.sh @@ -19,13 +19,13 @@ if [ -f /.dockerenv ]; then fi # check if something is running on port 80 -if lsof -i :80 >/dev/null; then +if ss -tulnp | grep ':80 ' >/dev/null; then echo "Error: something is already running on port 80" >&2 exit 1 fi # check if something is running on port 443 -if lsof -i :443 >/dev/null; then +if ss -tulnp | grep ':443 ' >/dev/null; then echo "Error: something is already running on port 443" >&2 exit 1 fi From 9fae479e718d76e236f7e7ac9bb12b97bcd01533 Mon Sep 17 00:00:00 2001 From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com> Date: Wed, 1 May 2024 15:17:08 -0600 Subject: [PATCH 2/2] Update prod.sh I updated the script since the actual script was outdate --- docker/prod.sh | 49 ++++++++++++++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 19 deletions(-) diff --git a/docker/prod.sh b/docker/prod.sh index caafe960..77513175 100644 --- a/docker/prod.sh +++ b/docker/prod.sh @@ -31,27 +31,9 @@ if ss -tulnp | grep ':443 ' >/dev/null; then fi -# Network -network_exists=$(docker network ls | grep dokploy-network) - -if [ -z "$network_exists" ]; then - docker network create --driver overlay --attachable dokploy-network - echo "Network was initialized" -else - echo "Network is already initialized" -fi -# Swarm -swarm_status=$(docker info --format '{{.Swarm.LocalNodeState}}') -if [ "$swarm_status" = "active" ]; then - docker swarm leave --force 1> /dev/null 2> /dev/null || true - echo "Swarm is already initialized" -else - docker swarm init --advertise-addr 127.0.0.1 --listen-addr 0.0.0.0 - echo "Swarm was initialized" -fi command_exists() { command -v "$@" > /dev/null 2>&1 @@ -63,6 +45,20 @@ else curl -sSL https://get.docker.com | sh fi +docker swarm leave --force 2>/dev/null +docker swarm init --advertise-addr 127.0.0.1 --listen-addr 0.0.0.0; + +echo "Swarm initialized" + +docker network rm -f dokploy-network 2>/dev/null +docker network create --driver overlay --attachable dokploy-network + +echo "Network created" + +mkdir -p /etc/dokploy + +chmod -R 777 /etc/dokploy + docker pull dokploy/dokploy:latest # Installation @@ -75,4 +71,19 @@ docker service create \ --publish published=3000,target=3000,mode=host \ --update-parallelism 1 \ --update-order stop-first \ - dokploy/dokploy:latest \ No newline at end of file + dokploy/dokploy:latest + + +public_ip=$(hostname -I | awk '{print $1}') + +GREEN="\033[0;32m" +YELLOW="\033[1;33m" +BLUE="\033[0;34m" +NC="\033[0m" # No Color + + +echo "" +printf "${GREEN}Congratulations, Dokploy is installed!${NC}\n" +printf "${BLUE}Wait 15 seconds for the server to start${NC}\n" +printf "${YELLOW}Please go to http://${public_ip}:3000${NC}\n\n" +echo ""