Skip to content

Commit 7a86c99

Browse files
committed
modified yaml deploy script
1 parent 87d6bce commit 7a86c99

1 file changed

Lines changed: 18 additions & 4 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,27 @@ jobs:
1818
key: ${{ secrets.SSH_PRIVATE_KEY }}
1919
script: |
2020
echo "[INFO] Stopping and removing running container (if exists)..."
21+
docker stop codeboxes-server || true
2122
docker rm -f codeboxes-server || true
2223
23-
echo "[INFO] Killing any process using port 8080..."
24-
if command -v fuser >/dev/null 2>&1; then
25-
fuser -k 8080/tcp || true
24+
echo "[INFO] Killing any process explicitly using port 8080 (as a fallback)..."
25+
# Use 'lsof' which is generally more reliable and available on Ubuntu
26+
if command -v lsof >/dev/null 2>&1; then
27+
sudo lsof -t -i:8080 | xargs -r kill -9 || true
2628
else
27-
apk add --no-cache psmisc && fuser -k 8080/tcp || true
29+
# Fallback for systems without lsof, though Ubuntu usually has it
30+
if command -v fuser >/dev/null 2>&1; then
31+
fuser -k 8080/tcp || true
32+
else
33+
# Install psmisc if fuser is not found (for Alpine-like systems, less common on Ubuntu)
34+
sudo apt-get update && sudo apt-get install -y psmisc || true
35+
fuser -k 8080/tcp || true
36+
fi
2837
fi
2938
3039
echo "[INFO] Pruning unused Docker networks..."
3140
docker network prune -f
41+
docker image prune -f
3242
3343
echo "[INFO] Cloning latest code..."
3444
rm -rf codeboxes-server
@@ -45,5 +55,9 @@ jobs:
4555
4656
echo "[INFO] Starting updated codeboxes-server container..."
4757
docker run -d --name codeboxes-server \
58+
--restart unless-stopped \
4859
-v /var/run/docker.sock:/var/run/docker.sock \
4960
-p 8080:8080 codeboxes-server
61+
62+
echo "[INFO] Deployment complete."
63+

0 commit comments

Comments
 (0)