Skip to content

Commit 0db4d95

Browse files
committed
docs: install.sh for canary
1 parent 9911414 commit 0db4d95

File tree

2 files changed

+175
-1
lines changed

2 files changed

+175
-1
lines changed

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ Want to skip the installation process? [Try the Dokploy Cloud](https://app.dokpl
4545
curl -sSL https://dokploy.com/install.sh | sh
4646
```
4747

48+
for canary version
49+
50+
```bash
51+
curl -sSL https://raw.githubusercontent.com/Dokploy/dokploy/canary/install.sh | sh
52+
```
53+
4854
For detailed documentation, visit [docs.dokploy.com](https://docs.dokploy.com).
4955

5056
## Sponsors
@@ -75,7 +81,7 @@ For detailed documentation, visit [docs.dokploy.com](https://docs.dokploy.com).
7581
<img src=".github/sponsors/light-node.webp" alt="Lightnode" height="70"/>
7682
</a>
7783

78-
84+
7985
</div>
8086

8187
### Premium Supporters 🥇

install.sh

Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
#!/bin/bash
2+
install_dokploy() {
3+
if [ "$(id -u)" != "0" ]; then
4+
echo "This script must be run as root" >&2
5+
exit 1
6+
fi
7+
8+
# check if is Mac OS
9+
if [ "$(uname)" = "Darwin" ]; then
10+
echo "This script must be run on Linux" >&2
11+
exit 1
12+
fi
13+
14+
# check if is running inside a container
15+
if [ -f /.dockerenv ]; then
16+
echo "This script must be run on Linux" >&2
17+
exit 1
18+
fi
19+
20+
# check if something is running on port 80
21+
if ss -tulnp | grep ':80 ' >/dev/null; then
22+
echo "Error: something is already running on port 80" >&2
23+
exit 1
24+
fi
25+
26+
# check if something is running on port 443
27+
if ss -tulnp | grep ':443 ' >/dev/null; then
28+
echo "Error: something is already running on port 443" >&2
29+
exit 1
30+
fi
31+
32+
command_exists() {
33+
command -v "$@" > /dev/null 2>&1
34+
}
35+
36+
if command_exists docker; then
37+
echo "Docker already installed"
38+
else
39+
curl -sSL https://get.docker.com | sh
40+
fi
41+
42+
docker swarm leave --force 2>/dev/null
43+
44+
get_ip() {
45+
local ip=""
46+
47+
# Try IPv4 first
48+
# First attempt: ifconfig.io
49+
ip=$(curl -4s --connect-timeout 5 https://ifconfig.io 2>/dev/null)
50+
51+
# Second attempt: icanhazip.com
52+
if [ -z "$ip" ]; then
53+
ip=$(curl -4s --connect-timeout 5 https://icanhazip.com 2>/dev/null)
54+
fi
55+
56+
# Third attempt: ipecho.net
57+
if [ -z "$ip" ]; then
58+
ip=$(curl -4s --connect-timeout 5 https://ipecho.net/plain 2>/dev/null)
59+
fi
60+
61+
# If no IPv4, try IPv6
62+
if [ -z "$ip" ]; then
63+
# Try IPv6 with ifconfig.io
64+
ip=$(curl -6s --connect-timeout 5 https://ifconfig.io 2>/dev/null)
65+
66+
# Try IPv6 with icanhazip.com
67+
if [ -z "$ip" ]; then
68+
ip=$(curl -6s --connect-timeout 5 https://icanhazip.com 2>/dev/null)
69+
fi
70+
71+
# Try IPv6 with ipecho.net
72+
if [ -z "$ip" ]; then
73+
ip=$(curl -6s --connect-timeout 5 https://ipecho.net/plain 2>/dev/null)
74+
fi
75+
fi
76+
77+
if [ -z "$ip" ]; then
78+
echo "Error: Could not determine server IP address automatically (neither IPv4 nor IPv6)." >&2
79+
echo "Please set the ADVERTISE_ADDR environment variable manually." >&2
80+
echo "Example: export ADVERTISE_ADDR=<your-server-ip>" >&2
81+
exit 1
82+
fi
83+
84+
echo "$ip"
85+
}
86+
87+
advertise_addr="${ADVERTISE_ADDR:-$(get_ip)}"
88+
echo "Using advertise address: $advertise_addr"
89+
90+
docker swarm init --advertise-addr $advertise_addr
91+
92+
if [ $? -ne 0 ]; then
93+
echo "Error: Failed to initialize Docker Swarm" >&2
94+
exit 1
95+
fi
96+
97+
echo "Swarm initialized"
98+
99+
docker network rm -f dokploy-network 2>/dev/null
100+
docker network create --driver overlay --attachable dokploy-network
101+
102+
echo "Network created"
103+
104+
mkdir -p /etc/dokploy
105+
106+
chmod 777 /etc/dokploy
107+
108+
docker pull postgres:16
109+
docker pull redis:7
110+
docker pull traefik:v3.1.2
111+
docker pull dokploy/dokploy:latest
112+
113+
# Installation
114+
docker service create \
115+
--name dokploy \
116+
--replicas 1 \
117+
--network dokploy-network \
118+
--mount type=bind,source=/var/run/docker.sock,target=/var/run/docker.sock \
119+
--mount type=bind,source=/etc/dokploy,target=/etc/dokploy \
120+
--mount type=volume,source=dokploy-docker-config,target=/root/.docker \
121+
--publish published=3000,target=3000,mode=host \
122+
--update-parallelism 1 \
123+
--update-order stop-first \
124+
--constraint 'node.role == manager' \
125+
-e ADVERTISE_ADDR=$advertise_addr \
126+
dokploy/dokploy:latest
127+
128+
GREEN="\033[0;32m"
129+
YELLOW="\033[1;33m"
130+
BLUE="\033[0;34m"
131+
NC="\033[0m" # No Color
132+
133+
format_ip_for_url() {
134+
local ip="$1"
135+
if echo "$ip" | grep -q ':'; then
136+
# IPv6
137+
echo "[${ip}]"
138+
else
139+
# IPv4
140+
echo "${ip}"
141+
fi
142+
}
143+
144+
formatted_addr=$(format_ip_for_url "$advertise_addr")
145+
echo ""
146+
printf "${GREEN}Congratulations, Dokploy is installed!${NC}\n"
147+
printf "${BLUE}Wait 15 seconds for the server to start${NC}\n"
148+
printf "${YELLOW}Please go to http://${formatted_addr}:3000${NC}\n\n"
149+
}
150+
151+
update_dokploy() {
152+
echo "Updating Dokploy..."
153+
154+
# Pull the latest image
155+
docker pull dokploy/dokploy:latest
156+
157+
# Update the service
158+
docker service update --image dokploy/dokploy:latest dokploy
159+
160+
echo "Dokploy has been updated to the latest version."
161+
}
162+
163+
# Main script execution
164+
if [ "$1" = "update" ]; then
165+
update_dokploy
166+
else
167+
install_dokploy
168+
fi

0 commit comments

Comments
 (0)