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"
|
workspace="$HOME/ai_workspace"
|
||||||
app="opencode"
|
app="opencode"
|
||||||
|
env=""
|
||||||
rebuild=false
|
rebuild=false
|
||||||
|
|
||||||
while [[ $# -gt 0 ]]; do
|
while [[ $# -gt 0 ]]; do
|
||||||
|
|
@ -14,12 +15,16 @@ while [[ $# -gt 0 ]]; do
|
||||||
app="$2"
|
app="$2"
|
||||||
shift 2
|
shift 2
|
||||||
;;
|
;;
|
||||||
|
-e|--env)
|
||||||
|
env="$2"
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
--rebuild)
|
--rebuild)
|
||||||
rebuild=true
|
rebuild=true
|
||||||
shift
|
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
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
@ -52,20 +57,39 @@ case "$app" in
|
||||||
;;
|
;;
|
||||||
esac
|
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
|
if $rebuild || ! docker image inspect "$image_name" &>/dev/null; then
|
||||||
echo "Building $image_name..."
|
echo "Building $image_name..."
|
||||||
docker build --pull -t "$image_name" - <<EOF
|
dockerfile="FROM node:24-bullseye
|
||||||
FROM node:24-bullseye
|
${env_layer}
|
||||||
RUN npm install -g $npm_pkg
|
RUN npm install -g $npm_pkg
|
||||||
WORKDIR /workspace
|
WORKDIR /workspace
|
||||||
CMD ["$cmd"]
|
CMD [\"$cmd\"]"
|
||||||
EOF
|
docker build --pull -t "$image_name" - <<< "$dockerfile"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
clear
|
clear
|
||||||
|
|
||||||
docker run -it --rm \
|
docker run -it --rm \
|
||||||
--name "${app}-chat" \
|
--name "${image_name}-container" \
|
||||||
-v "$workspace:/workspace" \
|
-v "$workspace:/workspace" \
|
||||||
"${extra_volumes[@]}" \
|
"${extra_volumes[@]}" \
|
||||||
-w /workspace \
|
-w /workspace \
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue