Skip to content

Commit ed93400

Browse files
authored
Add devcontainer support (#8)
1 parent 6e2177e commit ed93400

File tree

3 files changed

+19
-35
lines changed

3 files changed

+19
-35
lines changed

.devcontainer/devcontainer.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"name": "JetKVM",
3+
"image": "mcr.microsoft.com/devcontainers/go:1-1.23-bookworm",
4+
"features": {
5+
"ghcr.io/devcontainers/features/node:1": {
6+
// Should match what is defined in ui/package.json
7+
"version": "21.1.0"
8+
}
9+
}
10+
}

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ build_dev: hash_resource
99
GOOS=linux GOARCH=arm GOARM=7 go build -ldflags="-s -w -X kvm.builtAppVersion=$(VERSION_DEV)" -o bin/jetkvm_app cmd/main.go
1010

1111
frontend:
12-
cd ui && npm run build:device
12+
cd ui && npm ci && npm run build:device
1313

1414
dev_release: build_dev
1515
@echo "Uploading release..."

dev_deploy.sh

Lines changed: 8 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3,35 +3,28 @@ set -e
33

44
# Function to display help message
55
show_help() {
6-
echo "Usage: $0 [options] -h <host_ip> -r <remote_ip>"
6+
echo "Usage: $0 [options] -r <remote_ip>"
77
echo
88
echo "Required:"
9-
echo " -h, --host <host_ip> Local host IP address"
109
echo " -r, --remote <remote_ip> Remote host IP address"
1110
echo
1211
echo "Optional:"
1312
echo " -u, --user <remote_user> Remote username (default: root)"
14-
echo " -p, --port <port> Python server port (default: 8000)"
1513
echo " --help Display this help message"
1614
echo
1715
echo "Example:"
18-
echo " $0 -h 192.168.0.13 -r 192.168.0.17"
19-
echo " $0 -h 192.168.0.13 -r 192.168.0.17 -u admin -p 8080"
16+
echo " $0 -r 192.168.0.17"
17+
echo " $0 -r 192.168.0.17 -u admin"
2018
exit 0
2119
}
2220

2321
# Default values
24-
PYTHON_PORT=8000
2522
REMOTE_USER="root"
2623
REMOTE_PATH="/userdata/jetkvm/bin"
2724

2825
# Parse command line arguments
2926
while [[ $# -gt 0 ]]; do
3027
case $1 in
31-
-h|--host)
32-
HOST_IP="$2"
33-
shift 2
34-
;;
3528
-r|--remote)
3629
REMOTE_HOST="$2"
3730
shift 2
@@ -40,10 +33,6 @@ while [[ $# -gt 0 ]]; do
4033
REMOTE_USER="$2"
4134
shift 2
4235
;;
43-
-p|--port)
44-
PYTHON_PORT="$2"
45-
shift 2
46-
;;
4736
--help)
4837
show_help
4938
exit 0
@@ -57,8 +46,8 @@ while [[ $# -gt 0 ]]; do
5746
done
5847

5948
# Verify required parameters
60-
if [ -z "$HOST_IP" ] || [ -z "$REMOTE_HOST" ]; then
61-
echo "Error: Host IP and Remote IP are required parameters"
49+
if [ -z "$REMOTE_HOST" ]; then
50+
echo "Error: Remote IP is a required parameter"
6251
show_help
6352
fi
6453

@@ -69,12 +58,8 @@ make build_dev
6958
# Change directory to the binary output directory
7059
cd bin
7160

72-
# Start a Python HTTP server in the background to serve files
73-
python3 -m http.server "$PYTHON_PORT" &
74-
PYTHON_SERVER_PID=$!
75-
76-
# Ensure that the Python server is terminated if the script exits unexpectedly
77-
trap "echo 'Terminating Python server...'; kill $PYTHON_SERVER_PID" EXIT
61+
# Copy the binary to the remote host
62+
cat jetkvm_app | ssh "${REMOTE_USER}@${REMOTE_HOST}" "cat > $REMOTE_PATH/jetkvm_app_debug"
7863

7964
# Deploy and run the application on the remote host
8065
ssh "${REMOTE_USER}@${REMOTE_HOST}" ash <<EOF
@@ -90,23 +75,12 @@ killall jetkvm_app_debug || true
9075
# Navigate to the directory where the binary will be stored
9176
cd "$REMOTE_PATH"
9277
93-
# Remove any old binary
94-
rm -f jetkvm_app
95-
96-
# Download the new binary from the host
97-
wget ${HOST_IP}:${PYTHON_PORT}/jetkvm_app
98-
9978
# Make the new binary executable
100-
chmod +x jetkvm_app
101-
102-
# Rename the binary to jetkvm_app_debug
103-
mv jetkvm_app jetkvm_app_debug
79+
chmod +x jetkvm_app_debug
10480
10581
# Run the application in the background
10682
./jetkvm_app_debug
10783
10884
EOF
10985

110-
# Once the SSH session finishes, shut down the Python server
111-
kill "$PYTHON_SERVER_PID"
11286
echo "Deployment complete."

0 commit comments

Comments
 (0)