diff --git a/images/gptscript/README.md b/images/gptscript/README.md new file mode 100644 index 0000000000..495ef3d634 --- /dev/null +++ b/images/gptscript/README.md @@ -0,0 +1,57 @@ + +# gptscript +| | | +| - | - | +| **OCI Reference** | `cgr.dev/chainguard/gptscript` | + + +* [View Image in Chainguard Academy](https://edu.chainguard.dev/chainguard/chainguard-images/reference/gptscript/overview/) +* [View Image Catalog](https://console.enforce.dev/images/catalog) for a full list of available tags. +* [Contact Chainguard](https://www.chainguard.dev/chainguard-images) for enterprise support, SLAs, and access to older tags.* + +--- + + + +Minimal [gptscript](https://github.com/gptscript-ai/gptscript) container image. + + + +## Download this Image +The image is available on `cgr.dev`: + +``` +docker pull cgr.dev/chainguard/gptscript:latest +``` + + + + +## Usage + +Before using our gptscript image, you'll need an [OpenAI API key](https://platform.openai.com/api-keys). + +After retrieving your key, run the container with the following command: + +```bash +docker run -e "OPENAI_API_KEY=" cgr.dev/chainguard/gptscript:latest +``` + +Azure OpenAI may also be used: + +```bash +docker run \ + -e "OPENAI_API_KEY=" \ + -e "OPENAI_BASE_URL=" \ + -e "OPENAI_API_TYPE=AZURE" \ + -e "OPENAI_AZURE_DEPLOYMENT=" \ + cgr.dev/chainguard/gptscript:latest +``` + +To run a basic hello world test, run the following: + +```bash +docker run -e "OPENAI_API_KEY=" cgr.dev/chainguard/gptscript:latest https://get.gptscript.ai/echo.gpt --input 'Hello, World!' +``` + + diff --git a/images/gptscript/config/main.tf b/images/gptscript/config/main.tf new file mode 100644 index 0000000000..9d0130af5b --- /dev/null +++ b/images/gptscript/config/main.tf @@ -0,0 +1,35 @@ +terraform { + required_providers { + apko = { source = "chainguard-dev/apko" } + } +} + +variable "extra_packages" { + description = "The additional packages to install (e.g. gptscript)." + default = ["gptscript"] +} + +variable "environment" { + default = {} +} + +module "accts" { + source = "../../../tflib/accts" + run-as = 0 + uid = 65532 + gid = 65532 + name = "nonroot" +} + +output "config" { + value = jsonencode({ + contents = { + packages = var.extra_packages + } + accounts = module.accts.block + environment = var.environment + entrypoint = { + command = "gptscript" + } + }) +} diff --git a/images/gptscript/main.tf b/images/gptscript/main.tf new file mode 100644 index 0000000000..8b5c79b459 --- /dev/null +++ b/images/gptscript/main.tf @@ -0,0 +1,40 @@ +terraform { + required_providers { + oci = { source = "chainguard-dev/oci" } + } +} + +variable "target_repository" { + description = "The docker repo into which the image and attestations should be published." +} + +module "config" { + source = "./config" + extra_packages = ["apk-tools", "busybox", "gptscript"] +} + +module "latest" { + source = "../../tflib/publisher" + name = basename(path.module) + target_repository = var.target_repository + config = module.config.config + build-dev = true +} + +module "test" { + source = "./tests" + + digest = module.latest.image_ref +} + +resource "oci_tag" "latest" { + depends_on = [module.test] + digest_ref = module.latest.image_ref + tag = "latest" +} + +resource "oci_tag" "latest-dev" { + depends_on = [module.test] + digest_ref = module.latest.dev_ref + tag = "latest-dev" +} diff --git a/images/gptscript/metadata.yaml b/images/gptscript/metadata.yaml new file mode 100644 index 0000000000..a9770568ff --- /dev/null +++ b/images/gptscript/metadata.yaml @@ -0,0 +1,12 @@ +name: gptscript +image: cgr.dev/chainguard/gptscript +logo: https://storage.googleapis.com/chainguard-academy/logos/gptscript.svg +endoflife: "" +console_summary: "" +short_description: Minimal [gptscript](https://github.com/gptscript-ai/gptscript) container image. +compatibility_notes: "" +readme_file: README.md +upstream_url: https://github.com/gptscript-ai/gptscript +keywords: + - ai + - languages diff --git a/images/gptscript/tests/main.tf b/images/gptscript/tests/main.tf new file mode 100644 index 0000000000..cd9c084286 --- /dev/null +++ b/images/gptscript/tests/main.tf @@ -0,0 +1,16 @@ +terraform { + required_providers { + oci = { source = "chainguard-dev/oci" } + } +} + +variable "digest" { + description = "The image digest to run tests over." +} + +data "oci_string" "ref" { input = var.digest } + +data "oci_exec_test" "smoke" { + digest = var.digest + script = "${path.module}/smoke.sh" +} diff --git a/images/gptscript/tests/smoke.sh b/images/gptscript/tests/smoke.sh new file mode 100755 index 0000000000..49d6ffa65d --- /dev/null +++ b/images/gptscript/tests/smoke.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +set -o errexit -o nounset -o errtrace -o pipefail -x + +CONTAINER_NAME="gptscript-$(uuidgen)" + +# Start container +docker run \ + -d --rm \ + --name "${CONTAINER_NAME}" \ + "${IMAGE_NAME}" + +# Stop container when script exits +trap "docker stop ${CONTAINER_NAME}" EXIT diff --git a/main.tf b/main.tf index d1171dedb3..5e403441f9 100644 --- a/main.tf +++ b/main.tf @@ -490,6 +490,11 @@ module "google-cloud-sdk" { target_repository = "${var.target_repository}/google-cloud-sdk" } +module "gptscript" { + source = "./images/gptscript" + target_repository = "${var.target_repository}/gptscript" +} + module "graalvm-native" { source = "./images/graalvm-native" target_repository = "${var.target_repository}/graalvm-native"