add Rust env support
This commit is contained in:
parent
b883c61cd0
commit
af1a8b3f76
1 changed files with 30 additions and 6 deletions
36
agent
36
agent
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
workspace="$HOME/ai_workspace"
|
||||
app="opencode"
|
||||
env=""
|
||||
rebuild=false
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
|
|
@ -14,12 +15,16 @@ while [[ $# -gt 0 ]]; do
|
|||
app="$2"
|
||||
shift 2
|
||||
;;
|
||||
-e|--env)
|
||||
env="$2"
|
||||
shift 2
|
||||
;;
|
||||
--rebuild)
|
||||
rebuild=true
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 [-p /path/to/workspace] [-a claude|opencode] [--rebuild]" >&2
|
||||
echo "Usage: $0 [-p /path/to/workspace] [-a claude|opencode] [-e rust] [--rebuild]" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
|
@ -52,20 +57,39 @@ case "$app" in
|
|||
;;
|
||||
esac
|
||||
|
||||
env_suffix=""
|
||||
env_layer=""
|
||||
|
||||
case "$env" in
|
||||
"")
|
||||
;;
|
||||
rust)
|
||||
env_suffix="-rust"
|
||||
env_layer='RUN curl --proto '"'"'=https'"'"' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
|
||||
ENV PATH="/root/.cargo/bin:${PATH}"'
|
||||
;;
|
||||
*)
|
||||
echo "Unknown env '$env'. Supported: rust" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
image_name="${image_name}${env_suffix}"
|
||||
|
||||
if $rebuild || ! docker image inspect "$image_name" &>/dev/null; then
|
||||
echo "Building $image_name..."
|
||||
docker build --pull -t "$image_name" - <<EOF
|
||||
FROM node:24-bullseye
|
||||
dockerfile="FROM node:24-bullseye
|
||||
${env_layer}
|
||||
RUN npm install -g $npm_pkg
|
||||
WORKDIR /workspace
|
||||
CMD ["$cmd"]
|
||||
EOF
|
||||
CMD [\"$cmd\"]"
|
||||
docker build --pull -t "$image_name" - <<< "$dockerfile"
|
||||
fi
|
||||
|
||||
clear
|
||||
|
||||
docker run -it --rm \
|
||||
--name "${app}-chat" \
|
||||
--name "${image_name}-container" \
|
||||
-v "$workspace:/workspace" \
|
||||
"${extra_volumes[@]}" \
|
||||
-w /workspace \
|
||||
|
|
|
|||
Loading…
Reference in a new issue