No description
- Dockerfile 100%
| .forgejo/workflows | ||
| .dockerignore | ||
| AGENTS.md | ||
| Containerfile | ||
| LICENSE | ||
| README.md | ||
OpenCode Container
This project provides a containerized setup for opencode, an AI-powered coding assistant.
Building the Image
podman build -t opencode .
# or
docker build -t opencode .
Running OpenCode in a Container
Add this function to your .bashrc or .zshrc:
opencode() {
local image="opencode"
local MOUNT_FILE=()
local opencode_data_dir="$HOME/.local/share/opencode"
if [ ! -d "$opencode_data_dir" ]; then
mkdir -p "$opencode_data_dir"
fi
for arg in "$@"; do
if [ -f "$arg" ] || [ -d "$arg" ]; then
MOUNT_FILE+=(-v "$arg:$arg:rw")
echo "Mounting $arg"
fi
done
if [ -z "${MOUNT_FILE[*]}" ]; then
local base_path="$(pwd)"
MOUNT_FILE=(--workdir "/data$base_path" -v "$base_path:/data$base_path:rw")
fi
MOUNT_FILE+=(-v "$opencode_data_dir:/root/.local/share/opencode:rw")
echo "Files mount options: "${MOUNT_FILE[*]}""
podman run --privileged -it --rm $PODMAN_FLAGS \
--log-driver none \
--shm-size=0 \
--init \
--network host \
"${MOUNT_FILE[@]}" \
"$image" \
"$@"
}
Usage
opencode --help
opencode "your prompt here"
opencode /path/to/file.py
opencode auth login
The function mounts your current working directory (or specific files) into the container, allowing opencode to access and edit files in your project.