diff --git a/blueprints/opencode/docker-compose.yml b/blueprints/opencode/docker-compose.yml new file mode 100644 index 000000000..d7912acc6 --- /dev/null +++ b/blueprints/opencode/docker-compose.yml @@ -0,0 +1,44 @@ +version: "3.8" + +services: + opencode: + image: ghcr.io/anomalyco/opencode:1.18.32 + restart: unless-stopped + entrypoint: [] + # The official image is minimal (no git/node). Provision a toolchain on + # start-up so the agent can clone repos and run project commands. + # Set TOOLCHAIN_PACKAGES to "" to skip it, or to e.g. "git go" for another stack. + command: + - sh + - -c + - | + set -e + apk add --no-cache $${TOOLCHAIN_PACKAGES} >/dev/null 2>&1 || true + if [ -n "$${GIT_TOKEN}" ] && [ -n "$${GIT_REPO_URL}" ]; then + host=$$(printf '%s' "$${GIT_REPO_URL}" | sed -E 's#^https?://([^/]+)/.*#\1#') + git config --global credential.helper store + printf 'https://x-access-token:%s@%s\n' "$${GIT_TOKEN}" "$$host" > /root/.git-credentials + fi + if [ -n "$${GIT_REPO_URL}" ]; then + dir="/workspace/$$(basename "$${GIT_REPO_URL}" .git)" + [ -d "$$dir/.git" ] || git clone "$${GIT_REPO_URL}" "$$dir" || true + fi + exec opencode serve --hostname 0.0.0.0 --port 4096 + working_dir: /workspace + expose: + - 4096 + environment: + - OPENCODE_SERVER_USERNAME=${OPENCODE_SERVER_USERNAME} + - OPENCODE_SERVER_PASSWORD=${OPENCODE_SERVER_PASSWORD} + - TOOLCHAIN_PACKAGES=${TOOLCHAIN_PACKAGES} + - GIT_REPO_URL=${GIT_REPO_URL} + - GIT_TOKEN=${GIT_TOKEN} + volumes: + - opencode-data:/root/.local/share/opencode + - opencode-config:/root/.config/opencode + - opencode-workspace:/workspace + +volumes: + opencode-data: + opencode-config: + opencode-workspace: diff --git a/blueprints/opencode/meta.json b/blueprints/opencode/meta.json new file mode 100644 index 000000000..9eee2dcda --- /dev/null +++ b/blueprints/opencode/meta.json @@ -0,0 +1,19 @@ +{ + "id": "opencode", + "name": "OpenCode", + "version": "1.18.32", + "description": "OpenCode is an open source AI coding agent. This template runs its password-protected web UI; optionally set a repository URL to clone on start-up, then chat with, edit and run your code from the browser.", + "logo": "opencode.svg", + "links": { + "github": "https://github.com/anomalyco/opencode", + "website": "https://opencode.ai", + "docs": "https://opencode.ai/v2/docs" + }, + "tags": [ + "ai", + "coding", + "agent", + "development", + "self-hosted" + ] +} diff --git a/blueprints/opencode/opencode.svg b/blueprints/opencode/opencode.svg new file mode 100644 index 000000000..157edc4d7 --- /dev/null +++ b/blueprints/opencode/opencode.svg @@ -0,0 +1,7 @@ + + + + + \ No newline at end of file diff --git a/blueprints/opencode/template.toml b/blueprints/opencode/template.toml new file mode 100644 index 000000000..87a5991da --- /dev/null +++ b/blueprints/opencode/template.toml @@ -0,0 +1,21 @@ +[variables] +main_domain = "${domain}" +opencode_password = "${password:32}" + +[config] +[[config.domains]] +serviceName = "opencode" +port = 4096 +host = "${main_domain}" +https = true + +[config.env] +OPENCODE_SERVER_USERNAME = "opencode" +OPENCODE_SERVER_PASSWORD = "${opencode_password}" +# Packages installed in the container at start-up (Alpine apk). +# Set to "" to keep the minimal image, or adapt to your stack (e.g. "git go"). +TOOLCHAIN_PACKAGES = "git nodejs npm python3" +# Optional: clone a repository into /workspace on start-up. +# Leave GIT_REPO_URL empty to skip. Set GIT_TOKEN (GitHub PAT, Contents: read) for private repos. +GIT_REPO_URL = "" +GIT_TOKEN = ""