-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·105 lines (85 loc) · 2.92 KB
/
install.sh
File metadata and controls
executable file
·105 lines (85 loc) · 2.92 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/bin/bash
set -e # Exit immediately if a command exits with non-zero status
# Remove the existing /runbox if it exists
if [ -d "/tmp/code-sandbox-server" ]; then
echo "Found existing /tmp/code-sandbox-server directory. Removing it..."
sudo rm -rf /tmp/code-sandbox-server
fi
sudo mkdir -p /runbox
# Change /runbox ownership to the current user
sudo chown -R "$USER":"$USER" /runbox
# Set full permissions for the user recursively in /runbox
chmod -R 700 /runbox
sudo apt update
sudo apt install nginx -y
sudo apt install git -y
sudo nginx -v
git clone https://github.com/11cafe/code-sandbox-server.git /tmp/code-sandbox-server
# install nodejs
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
sudo apt-get install -y nodejs
sudo apt-get install -y build-essential # for npm install node-pty to work
# build the project
mkdir -p /runbox/container_manager
rm -rf /runbox/container_manager/* # Add this line to clear existing contents
cp -r /tmp/code-sandbox-server/container_manager/* /runbox/container_manager/
cd /runbox/container_manager
npm install
npm run build
sudo mv /tmp/code-sandbox-server/nginx.conf /etc/nginx/nginx.conf
mv /tmp/code-sandbox-server/start.sh /runbox/start.sh
mkdir -p /runbox/nginx/dynamics
# Set full permissions for the user recursively in /data
sudo mkdir -p /data/workspaces
sudo chown -R "$USER":"$USER" /data
chmod -R 700 /data
# install docker
# Add Docker's official GPG key:
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
# Add the repository to Apt sources:
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
# make docker cmd avaialable to current user without sudo
echo "Adding current user to docker group"
sudo usermod -aG docker $USER
# newgrp docker # this will stuck and hang the script here since it creates new shell
docker --version
docker pull weixuanf/runbox
# adding more ips to default address pool otherwise it will consume all ips
sudo tee /etc/docker/daemon.json > /dev/null << 'EOF'
{
"default-address-pools": [
{
"base": "172.17.0.0/16",
"size": 24
},
{
"base": "172.18.0.0/16",
"size": 24
},
{
"base": "172.19.0.0/16",
"size": 24
}
]
}
EOF
# Restart Docker to apply the changes
echo "Restarting docker"
sudo systemctl restart docker
sudo npm install -g pm2
# install https
# sudo apt update
# sudo apt install certbot python3-certbot-nginx -y
# START SCRIPT
echo "Starting runbox"
cd /runbox
chmod +x start.sh
./start.sh