Monorepo for Aesthetic.Computer
aesthetic.computer
1#!/usr/bin/env fish
2# apple-container.fish
3# Helper script to build, run, and manage Apple Container for aesthetic-computer
4# Usage: ./apple-container.fish [build|run|start|stop|exec|delete|status]
5
6set -l script_dir (dirname (status filename))
7set -l containerfile "$script_dir/Containerfile.apple"
8set -l container_name "ac-dev"
9set -l image_name "ac-dev"
10
11# Detect workspace path on macOS
12set -l workspace_path ""
13if test -d ~/Desktop/code/aesthetic-computer
14 set workspace_path ~/Desktop/code/aesthetic-computer
15else if test -d ~/aesthetic-computer
16 set workspace_path ~/aesthetic-computer
17else if test -d /workspaces/aesthetic-computer
18 set workspace_path /workspaces/aesthetic-computer
19else
20 echo "❌ Could not find aesthetic-computer workspace"
21 echo " Looked in: ~/Desktop/code/aesthetic-computer, ~/aesthetic-computer, /workspaces/aesthetic-computer"
22 exit 1
23end
24
25function show_help
26 echo "🍎 Apple Container Helper for Aesthetic Computer"
27 echo ""
28 echo "Usage: ./apple-container.fish <command>"
29 echo ""
30 echo "Commands:"
31 echo " build Build the container image from Containerfile.apple"
32 echo " run Create and start a new container (removes existing)"
33 echo " start Start an existing stopped container"
34 echo " stop Stop the running container"
35 echo " exec Execute fish shell in the running container"
36 echo " delete Delete the container"
37 echo " status Show container status"
38 echo " logs Show container logs"
39 echo " generate Regenerate Containerfile.apple from Dockerfile"
40 echo ""
41 echo "Workspace: $workspace_path"
42end
43
44function cmd_build
45 echo "🔨 Building Apple Container image..."
46 container build -t $image_name -f $containerfile $script_dir
47end
48
49function cmd_run
50 echo "🚀 Creating and starting container..."
51
52 # Stop and remove existing container if it exists
53 if container ls -a | grep -q $container_name
54 echo " Removing existing container..."
55 container stop $container_name 2>/dev/null
56 container rm $container_name 2>/dev/null
57 end
58
59 container create --name $container_name -it --ssh \
60 -v $workspace_path:/workspaces/aesthetic-computer \
61 -p 8888:8888 -p 8889:8889 -p 8111:8111 -p 3000:3000 \
62 -p 8083:8083 -p 8084:8084 -p 8085:8085 \
63 -w /workspaces/aesthetic-computer \
64 --cpus 4 --memory 8G \
65 $image_name /usr/bin/fish
66
67 container start $container_name
68 echo "✅ Container started! Run './apple-container.fish exec' to enter."
69end
70
71function cmd_start
72 echo "▶️ Starting container..."
73 container start $container_name
74end
75
76function cmd_stop
77 echo "⏹️ Stopping container..."
78 container stop $container_name
79end
80
81function cmd_exec
82 echo "🐚 Entering container shell..."
83 container exec -it $container_name /usr/bin/fish
84end
85
86function cmd_delete
87 echo "🗑️ Deleting container..."
88 container stop $container_name 2>/dev/null
89 container rm $container_name
90end
91
92function cmd_status
93 echo "📊 Container status:"
94 container ls -a | head -1
95 container ls -a | grep $container_name; or echo " No container named '$container_name' found"
96 echo ""
97 if container ls | grep -q $container_name
98 echo "📈 Resource usage:"
99 container stats $container_name --no-stream
100 end
101end
102
103function cmd_logs
104 container logs $container_name
105end
106
107function cmd_generate
108 fish $script_dir/generate-apple-container.fish
109end
110
111# Main
112switch $argv[1]
113 case build
114 cmd_build
115 case run
116 cmd_run
117 case start
118 cmd_start
119 case stop
120 cmd_stop
121 case exec
122 cmd_exec
123 case delete
124 cmd_delete
125 case status
126 cmd_status
127 case logs
128 cmd_logs
129 case generate
130 cmd_generate
131 case help -h --help ""
132 show_help
133 case "*"
134 echo "❌ Unknown command: $argv[1]"
135 show_help
136 exit 1
137end