-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild-and-run.sh
More file actions
executable file
·38 lines (33 loc) · 1.28 KB
/
Copy pathbuild-and-run.sh
File metadata and controls
executable file
·38 lines (33 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# !/bin/bash
# Stop and remove the running codeboxes-server container (if it exists)
echo "[INFO] Performing an existing codeboxes-server docker container cleanup..."
docker stop codeboxes-server || true
docker rm -f codeboxes-server || true
# Free up port 8080 (if still in use) (fallback)
echo "[INFO] Freeing up port 8080 (if still in use)..."
# Use 'lsof' which is generally more reliable and available on Ubuntu
if command -v lsof >/dev/null 2>&1; then
sudo lsof -t -i:8080 | xargs -r kill -9 || true
else
# Fallback for systems without lsof, though Ubuntu usually has it
if command -v fuser >/dev/null 2>&1; then
fuser -k 8080/tcp || true
else
# Install psmisc if fuser is not found (for Alpine-like systems, less common on Ubuntu)
sudo apt-get update && sudo apt-get install -y psmisc || true
fuser -k 8080/tcp || true
fi
fi
sleep 5
# Build the containers
echo "[INFO] Building codeboxes-server..."
docker build -t codeboxes-server ./server
echo "[INFO] Building code-runner..."
docker build -t code-runner ./code-runner
# start codeboxes-server container
echo "[INFO] Starting codeboxes-server container..."
docker run -d \
--name codeboxes-server \
-v /var/run/docker.sock:/var/run/docker.sock \
-p 8080:8080 codeboxes-server
echo "[INFO] Deployment complete."