Skip to content

Commit b0085bf

Browse files
author
adnan wahab
committed
yay
1 parent 1416483 commit b0085bf

File tree

9 files changed

+315
-388
lines changed

9 files changed

+315
-388
lines changed

scripts/_bootstrap.sh

+66-88
Original file line numberDiff line numberDiff line change
@@ -3,79 +3,80 @@
33

44
# Symlink each category into a data folder in the root of this git repo
55
#chmod +x scripts/*
6-
ln -s ~/derp/actions ~/homelab_status_page/data/actions
7-
ln -s ~/derp/cartoons ~/homelab_status_page/data/cartoons
8-
ln -s ~/derp/comics ~/homelab_status_page/data/comics
9-
ln -s ~/derp/embeddings ~/homelab_status_page/data/embeddings
10-
ln -s ~/derp/intermediate_representation ~/homelab_status_page/data/intermediate_representation
11-
ln -s ~/derp/logs ~/homelab_status_page/data/logs
6+
# ln -s ~/derp/actions ~/homelab_status_page/data/actions
7+
# ln -s ~/derp/cartoons ~/homelab_status_page/data/cartoons
8+
# ln -s ~/derp/comics ~/homelab_status_page/data/comics
9+
# ln -s ~/derp/embeddings ~/homelab_status_page/data/embeddings
10+
# ln -s ~/derp/intermediate_representation ~/homelab_status_page/data/intermediate_representation
11+
# ln -s ~/derp/logs ~/homelab_status_page/data/logs
1212

13-
ln -s ~/derp/sensor_data ~/homelab_status_page/data/sensor_data
13+
# ln -s ~/derp/sensor_data ~/homelab_status_page/data/sensor_data
1414

1515
#!/bin/bash
1616

1717
# Script to clone and build specified Jetson containers
1818

1919
# Check if Git is installed
20-
if ! command -v git &> /dev/null
21-
then
22-
echo "Git is not installed. Please install Git before running this script."
23-
exit
24-
fi
25-
26-
# Check if Docker is installed
27-
if ! command -v docker &> /dev/null
28-
then
29-
echo "Docker is not installed. Please install Docker before running this script."
30-
exit
31-
fi
32-
33-
# Clone or update the jetson-containers repository
34-
if [ ! -d "jetson-containers" ]; then
35-
echo "Cloning jetson-containers repository..."
36-
git clone https://github.com/dusty-nv/jetson-containers.git
37-
else
38-
echo "Updating jetson-containers repository..."
39-
cd jetson-containers
40-
git pull
41-
cd ..
42-
fi
43-
44-
cd jetson-containers
20+
# if ! command -v git &> /dev/null
21+
# then
22+
# echo "Git is not installed. Please install Git before running this script."
23+
# exit
24+
# fi
25+
26+
# # Check if Docker is installed
27+
# if ! command -v docker &> /dev/null
28+
# then
29+
# echo "Docker is not installed. Please install Docker before running this script."
30+
# exit
31+
# fi
32+
33+
# # Clone or update the jetson-containers repository
34+
# if [ ! -d "jetson-containers" ]; then
35+
# echo "Cloning jetson-containers repository..."
36+
# git clone https://github.com/dusty-nv/jetson-containers.git
37+
# else
38+
# echo "Updating jetson-containers repository..."
39+
# cd jetson-containers
40+
# git pull
41+
# cd ..
42+
# fi
43+
44+
45+
#cd jetson-containers
4546

4647
# List of package paths
47-
packages=(
48-
"packages/llm/ollama"
49-
"packages/llm/llama_cpp"
50-
"packages/llm/llama-factory"
51-
"packages/llm/exllama"
52-
"packages/vlm/llama-vision"
53-
)
54-
55-
# Build each container
56-
for package in "${packages[@]}"; do
57-
echo "-----------------------------------------"
58-
echo "Building container for $package"
59-
cd "$package"
60-
61-
# Check if a build script exists
62-
if [ -f "build.sh" ]; then
63-
echo "Found build.sh, executing..."
64-
chmod +x build.sh
65-
./build.sh
66-
elif [ -f "Dockerfile" ]; then
67-
# Build the Docker image
68-
image_name="${package##*/}"
69-
echo "No build.sh found. Building Docker image: $image_name"
70-
docker build -t "$image_name" .
71-
else
72-
echo "No build script or Dockerfile found in $package. Skipping..."
73-
fi
74-
75-
cd - > /dev/null
76-
done
77-
78-
echo "All containers have been built."
48+
# packages=(
49+
# "packages/llm/ollama"
50+
# "packages/llm/llama_cpp"
51+
# "packages/llm/llama-factory"
52+
# "packages/llm/exllama"
53+
# "packages/vlm/llama-vision"
54+
# )
55+
56+
# # Build each container
57+
# for package in "${packages[@]}"; do
58+
# echo "-----------------------------------------"
59+
# echo "Building container for $package"
60+
# cd "$package"
61+
62+
# # Check if a build script exists
63+
# if [ -f "build.sh" ]; then
64+
# echo "Found build.sh, executing..."
65+
# chmod +x build.sh
66+
# ./build.sh
67+
# elif [ -f "Dockerfile" ]; then
68+
# # Build the Docker image
69+
# image_name="${package##*/}"
70+
# echo "No build.sh found. Building Docker image: $image_name"
71+
# docker build -t "$image_name" .
72+
# else
73+
# echo "No build script or Dockerfile found in $package. Skipping..."
74+
# fi
75+
76+
# cd - > /dev/null
77+
# done
78+
79+
# echo "All containers have been built."
7980

8081
# https://github.com/dusty-nv/jetson-inference
8182

@@ -508,30 +509,7 @@ echo "All containers have been built."
508509

509510

510511
# Function to install and run Portainer
511-
install_portainer() {
512-
# Update package list and install dependencies
513-
sudo apt-get update
514-
sudo apt-get install -y docker.io
515-
516-
# Pull the latest Portainer image
517-
sudo docker pull portainer/portainer-ce:latest
518-
519-
# Create a Docker volume for Portainer data
520-
sudo docker volume create portainer_data
521-
522-
# Run Portainer container
523-
sudo docker run -d \
524-
--name=portainer \
525-
--restart=always \
526-
-p 8000:8000 \
527-
-p 9443:9443 \
528-
-v /var/run/docker.sock:/var/run/docker.sock \
529-
-v portainer_data:/data \
530-
portainer/portainer-ce:latest
531-
532-
echo "Portainer installation and setup completed."
533-
}
534-
512+
# l
535513

536514

537515
# Call the functions to install Portainer and configure Caddy

scripts/infra/caddy/Caddyfile

+1-3
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,9 @@ hashirama.blog {
1717
}
1818

1919
route /* {
20-
reverse_proxy localhost:8080
20+
reverse_proxy localhost:3333
2121
}
2222

23-
/
24-
2523
# Add logging for this site
2624
log {
2725
output file /home/adnan/derp/log/caddy/hashirama.blog.log {

scripts/init_containers.sh

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/bin/bash
2+
3+
# List of package paths
4+
packages=(
5+
"packages/llm/ollama"
6+
"packages/llm/llama_cpp"
7+
"packages/llm/llama-factory"
8+
"packages/llm/exllama"
9+
"packages/vlm/llama-vision"
10+
)
11+
12+
# Store the initial directory
13+
initial_dir=$(pwd)
14+
15+
# Build each container
16+
for package in "${packages[@]}"; do
17+
echo "-----------------------------------------"
18+
echo "Building container for $package"
19+
20+
# Check if the directory exists
21+
if [ ! -d "$package" ]; then
22+
echo "Error: Directory $package does not exist. Skipping..."
23+
continue
24+
fi
25+
26+
# Change to the package directory
27+
cd "$initial_dir/$package" || { echo "Error: Unable to change to directory $package. Skipping..."; continue; }
28+
29+
# Check if a build script exists
30+
if [ -f "build.sh" ]; then
31+
echo "Found build.sh, executing..."
32+
chmod +x build.sh
33+
./build.sh
34+
elif [ -f "Dockerfile" ]; then
35+
# Build the Docker image
36+
image_name="${package##*/}"
37+
echo "No build.sh found. Building Docker image: $image_name"
38+
docker build -t "$image_name" .
39+
else
40+
echo "No build script or Dockerfile found in $package. Skipping..."
41+
fi
42+
43+
# Return to the initial directory
44+
cd "$initial_dir" || { echo "Error: Unable to return to initial directory. Exiting..."; exit 1; }
45+
done
46+
47+
echo "-----------------------------------------"
48+
echo "Container build process completed."
+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import fs from "fs";
2+
3+
async function runOllamaCommand(prompt) {
4+
try {
5+
const command = `ollama run llama2 "${prompt}"`;
6+
7+
const result = await Bun.spawn(["sh", "-c", command]).text();
8+
9+
const logEntry = {
10+
timestamp: new Date().toISOString(),
11+
prompt: prompt,
12+
result: result
13+
};
14+
15+
const logDir = "/derp/log";
16+
const logFile = path.join(logDir, "llama.json");
17+
18+
if (!fs.existsSync(logDir)) {
19+
fs.mkdirSync(logDir, { recursive: true });
20+
}
21+
22+
let logData = [];
23+
if (fs.existsSync(logFile)) {
24+
const existingLog = fs.readFileSync(logFile, "utf-8");
25+
logData = JSON.parse(existingLog);
26+
}
27+
28+
logData.push(logEntry);
29+
fs.writeFileSync(logFile, JSON.stringify(logData, null, 2));
30+
return result.trim();
31+
} catch (error) {
32+
console.error("Error running Ollama command:", error);
33+
throw error;
34+
}
35+
}
36+
37+
export async function handleOllamaRequest(req) {
38+
if (req.method !== 'POST') {
39+
return new Response('Method not allowed', { status: 405 });
40+
}
41+
42+
try {
43+
const { prompt } = await req.json();
44+
45+
if (!prompt) {
46+
return new Response(JSON.stringify({ error: 'Prompt is required' }), {
47+
status: 400,
48+
headers: { 'Content-Type': 'application/json' }
49+
});
50+
}
51+
52+
const result = await runOllamaCommand(prompt);
53+
54+
return new Response(JSON.stringify({ result }), {
55+
status: 200,
56+
headers: { 'Content-Type': 'application/json' }
57+
});
58+
} catch (error) {
59+
console.error('Error in handleOllamaRequest:', error);
60+
return new Response(JSON.stringify({ error: 'Internal server error' }), {
61+
status: 500,
62+
headers: { 'Content-Type': 'application/json' }
63+
});
64+
}
65+
}

web-ui/js/bun_main_server.tsx

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11

22
// proxy-server.
33

4-
const port = 8000;
5-
6-
4+
const port = 3333;
75
/// bun - dockerized + system or whateer
86
// --- this proxies to vite for app
97
//// --- this proxies to another bun or deno server for iteration /sanit
@@ -34,3 +32,4 @@ Bun.serve({
3432
}
3533
},
3634
});
35+
console.log("server running on port", port);

0 commit comments

Comments
 (0)