diff --git a/apps/website/public/canary.sh b/apps/website/public/canary.sh index 3a9102b0..32f95bff 100644 --- a/apps/website/public/canary.sh +++ b/apps/website/public/canary.sh @@ -1,114 +1,133 @@ #!/bin/bash +install_dokploy() { + if [ "$(id -u)" != "0" ]; then + echo "This script must be run as root" >&2 + exit 1 + fi -if [ "$(id -u)" != "0" ]; then - echo "This script must be run as root" >&2 - exit 1 -fi - -# check if is Mac OS -if [ "$(uname)" = "Darwin" ]; then - echo "This script must be run on Linux" >&2 - exit 1 -fi + # check if is Mac OS + if [ "$(uname)" = "Darwin" ]; then + echo "This script must be run on Linux" >&2 + exit 1 + fi -# check if is running inside a container -if [ -f /.dockerenv ]; then - echo "This script must be run on Linux" >&2 - exit 1 -fi + # check if is running inside a container + if [ -f /.dockerenv ]; then + echo "This script must be run on Linux" >&2 + exit 1 + fi -# check if something is running on port 80 -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 80 + 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 ss -tulnp | grep ':443 ' >/dev/null; then - echo "Error: something is already running on port 443" >&2 - exit 1 -fi + # check if something is running on port 443 + if ss -tulnp | grep ':443 ' >/dev/null; then + echo "Error: something is already running on port 443" >&2 + exit 1 + fi -command_exists() { - command -v "$@" > /dev/null 2>&1 -} + command_exists() { + command -v "$@" > /dev/null 2>&1 + } -if command_exists docker; then - echo "Docker already installed" -else - curl -sSL https://get.docker.com | sh -fi - -docker swarm leave --force 2>/dev/null - -get_ip() { - # Try to get IPv4 - local ipv4=$(curl -4s https://ifconfig.io 2>/dev/null) - - if [ -n "$ipv4" ]; then - echo "$ipv4" + if command_exists docker; then + echo "Docker already installed" else - # Try to get IPv6 - local ipv6=$(curl -6s https://ifconfig.io 2>/dev/null) - if [ -n "$ipv6" ]; then - echo "$ipv6" + curl -sSL https://get.docker.com | sh + fi + + docker swarm leave --force 2>/dev/null + + get_ip() { + # Try to get IPv4 + local ipv4=$(curl -4s https://ifconfig.io 2>/dev/null) + + if [ -n "$ipv4" ]; then + echo "$ipv4" + else + # Try to get IPv6 + local ipv6=$(curl -6s https://ifconfig.io 2>/dev/null) + if [ -n "$ipv6" ]; then + echo "$ipv6" + fi fi - fi + } + + advertise_addr=$(get_ip) + + docker swarm init --advertise-addr $advertise_addr + + 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 777 /etc/dokploy + + docker pull dokploy/dokploy:canary + + # Installation + docker service create \ + --name dokploy \ + --replicas 1 \ + --network dokploy-network \ + --mount type=bind,source=/var/run/docker.sock,target=/var/run/docker.sock \ + --mount type=bind,source=/etc/dokploy,target=/etc/dokploy \ + --mount type=volume,source=dokploy-docker-config,target=/root/.docker \ + --publish published=3000,target=3000,mode=host \ + --update-parallelism 1 \ + --update-order stop-first \ + --constraint 'node.role == manager' \ + -e RELEASE_TAG=canary \ + dokploy/dokploy:canary + + GREEN="\033[0;32m" + YELLOW="\033[1;33m" + BLUE="\033[0;34m" + NC="\033[0m" # No Color + + format_ip_for_url() { + local ip="$1" + if echo "$ip" | grep -q ':'; then + # IPv6 + echo "[${ip}]" + else + # IPv4 + echo "${ip}" + fi + } + + formatted_addr=$(format_ip_for_url "$advertise_addr") + 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://${formatted_addr}:3000${NC}\n\n" + echo "" } -advertise_addr=$(get_ip) +update_dokploy() { + echo "Updating Dokploy..." + + # Pull the latest canary image + docker pull dokploy/dokploy:canary -docker swarm init --advertise-addr $advertise_addr + # Update the service + docker service update --image dokploy/dokploy:canary dokploy -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 777 /etc/dokploy - -docker pull dokploy/dokploy:canary - -# Installation -docker service create \ - --name dokploy \ - --replicas 1 \ - --network dokploy-network \ - --mount type=bind,source=/var/run/docker.sock,target=/var/run/docker.sock \ - --mount type=bind,source=/etc/dokploy,target=/etc/dokploy \ - --mount type=volume,source=dokploy-docker-config,target=/root/.docker \ - --publish published=3000,target=3000,mode=host \ - --update-parallelism 1 \ - --update-order stop-first \ - --constraint 'node.role == manager' \ - -e RELEASE_TAG=canary \ - dokploy/dokploy:canary - -GREEN="\033[0;32m" -YELLOW="\033[1;33m" -BLUE="\033[0;34m" -NC="\033[0m" # No Color - -format_ip_for_url() { - local ip="$1" - if echo "$ip" | grep -q ':'; then - # IPv6 - echo "[${ip}]" - else - # IPv4 - echo "${ip}" - fi + echo "Dokploy has been updated to the latest canary version." } -formatted_addr=$(format_ip_for_url "$advertise_addr") -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://${formatted_addr}:3000${NC}\n\n" -echo "" - +# Main script execution +if [ "$1" = "update" ]; then + update_dokploy +else + install_dokploy +fi \ No newline at end of file diff --git a/apps/website/public/feature.sh b/apps/website/public/feature.sh index 453da012..fca4fccd 100644 --- a/apps/website/public/feature.sh +++ b/apps/website/public/feature.sh @@ -1,97 +1,117 @@ #!/bin/bash - -if [ "$(id -u)" != "0" ]; then - echo "This script must be run as root" >&2 - exit 1 -fi - -# check if is Mac OS -if [ "$(uname)" = "Darwin" ]; then - echo "This script must be run on Linux" >&2 - exit 1 -fi - - -# check if is running inside a container -if [ -f /.dockerenv ]; then - echo "This script must be run on Linux" >&2 - exit 1 -fi - -# check if something is running on port 80 -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 ss -tulnp | grep ':443 ' >/dev/null; then - echo "Error: something is already running on port 443" >&2 - exit 1 -fi - -command_exists() { - command -v "$@" > /dev/null 2>&1 -} - -if command_exists docker; then - echo "Docker already installed" -else - curl -sSL https://get.docker.com | sh -fi - -docker swarm leave --force 2>/dev/null -advertise_addr=$(curl -s ifconfig.me) - -docker swarm init --advertise-addr $advertise_addr - -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 777 /etc/dokploy - -docker pull dokploy/dokploy:feature - -# Installation -docker service create \ - --name dokploy \ - --replicas 1 \ - --network dokploy-network \ - --mount type=bind,source=/var/run/docker.sock,target=/var/run/docker.sock \ - --mount type=bind,source=/etc/dokploy,target=/etc/dokploy \ - --mount type=volume,source=dokploy-docker-config,target=/root/.docker \ - --publish published=3000,target=3000,mode=host \ - --update-parallelism 1 \ - --update-order stop-first \ - --constraint 'node.role == manager' \ - -e RELEASE_TAG=feature \ - dokploy/dokploy:feature - -GREEN="\033[0;32m" -YELLOW="\033[1;33m" -BLUE="\033[0;34m" -NC="\033[0m" # No Color - -format_ip_for_url() { - local ip="$1" - if echo "$ip" | grep -q ':'; then - # IPv6 - echo "[${ip}]" - else - # IPv4 - echo "${ip}" +install_dokploy() { + if [ "$(id -u)" != "0" ]; then + echo "This script must be run as root" >&2 + exit 1 fi + + # check if is Mac OS + if [ "$(uname)" = "Darwin" ]; then + echo "This script must be run on Linux" >&2 + exit 1 + fi + + + # check if is running inside a container + if [ -f /.dockerenv ]; then + echo "This script must be run on Linux" >&2 + exit 1 + fi + + # check if something is running on port 80 + 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 ss -tulnp | grep ':443 ' >/dev/null; then + echo "Error: something is already running on port 443" >&2 + exit 1 + fi + + command_exists() { + command -v "$@" > /dev/null 2>&1 + } + + if command_exists docker; then + echo "Docker already installed" + else + curl -sSL https://get.docker.com | sh + fi + + docker swarm leave --force 2>/dev/null + advertise_addr=$(curl -s ifconfig.me) + + docker swarm init --advertise-addr $advertise_addr + + 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 777 /etc/dokploy + + docker pull dokploy/dokploy:feature + + # Installation + docker service create \ + --name dokploy \ + --replicas 1 \ + --network dokploy-network \ + --mount type=bind,source=/var/run/docker.sock,target=/var/run/docker.sock \ + --mount type=bind,source=/etc/dokploy,target=/etc/dokploy \ + --mount type=volume,source=dokploy-docker-config,target=/root/.docker \ + --publish published=3000,target=3000,mode=host \ + --update-parallelism 1 \ + --update-order stop-first \ + --constraint 'node.role == manager' \ + -e RELEASE_TAG=feature \ + dokploy/dokploy:feature + + GREEN="\033[0;32m" + YELLOW="\033[1;33m" + BLUE="\033[0;34m" + NC="\033[0m" # No Color + + format_ip_for_url() { + local ip="$1" + if echo "$ip" | grep -q ':'; then + # IPv6 + echo "[${ip}]" + else + # IPv4 + echo "${ip}" + fi + } + + formatted_addr=$(format_ip_for_url "$advertise_addr") + 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://${formatted_addr}:3000${NC}\n\n" + echo "" } -formatted_addr=$(format_ip_for_url "$advertise_addr") -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://${formatted_addr}:3000${NC}\n\n" -echo "" +update_dokploy() { + echo "Updating Dokploy..." + + # Pull the latest feature image + docker pull dokploy/dokploy:feature + + # Update the service + docker service update --image dokploy/dokploy:feature dokploy + + echo "Dokploy has been updated to the latest feature version." +} + +# Main script execution +if [ "$1" = "update" ]; then + update_dokploy +else + install_dokploy +fi \ No newline at end of file