Skip to content

Instantly share code, notes, and snippets.

@dberstein
Created May 18, 2025 17:23
Show Gist options
  • Save dberstein/0c50ff7f6e44f8b0b32885543a022a83 to your computer and use it in GitHub Desktop.
Save dberstein/0c50ff7f6e44f8b0b32885543a022a83 to your computer and use it in GitHub Desktop.
Aider-wrap
#!/usr/bin/env bash
set -eux
IMG="aider-wrap"
GEMINI_API_KEY="..."
tmpfile=$(mktemp)
trap 'rm -f "$tmpfile"' EXIT
exists() {
return $(echo 0==$(docker images -q "$1" 2>/dev/null | wc -l) | bc)
}
cat <<EOF > "$tmpfile"
FROM alpine
RUN apk update && apk add git make curl python3 python3-dev gcc musl-dev linux-headers
RUN git config --global --add safe.directory /app && curl -LsSf https://aider.chat/install.sh | sh
WORKDIR /app
RUN git init .
ENTRYPOINT ["/root/.local/bin/aider"]
EOF
build() {
mktm
docker build -t "$IMG" -f "$tmpfile" .
}
run() {
# Run the container with the given environment variable
docker run --rm -it \
-e GEMINI_API_KEY="$GEMINI_API_KEY" \
-v "$PWD:/app" \
"$IMG" "$@"
}
# Check if the Docker image exists, and build it if it doesn't
exists "$IMG" || build "$IMG" && run "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment