-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(images): Add gptscript image (#2319)
* feat(images): Add gptscript image Signed-off-by: RJ Sampson <[email protected]> * feat(gptscript): Add apk-tools and busybox Signed-off-by: RJ Sampson <[email protected]> * fix(gptscript): Run as root Needed for apk tools Signed-off-by: RJ Sampson <[email protected]> --------- Signed-off-by: RJ Sampson <[email protected]>
- Loading branch information
Showing
7 changed files
with
179 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<!--monopod:start--> | ||
# 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.* | ||
|
||
--- | ||
<!--monopod:end--> | ||
|
||
<!--overview:start--> | ||
Minimal [gptscript](https://github.com/gptscript-ai/gptscript) container image. | ||
<!--overview:end--> | ||
|
||
<!--getting:start--> | ||
## Download this Image | ||
The image is available on `cgr.dev`: | ||
|
||
``` | ||
docker pull cgr.dev/chainguard/gptscript:latest | ||
``` | ||
<!--getting:end--> | ||
|
||
<!--body:start--> | ||
|
||
## 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=<YOUR OPENAI API KEY>" cgr.dev/chainguard/gptscript:latest | ||
``` | ||
|
||
Azure OpenAI may also be used: | ||
|
||
```bash | ||
docker run \ | ||
-e "OPENAI_API_KEY=<YOUR API KEY>" \ | ||
-e "OPENAI_BASE_URL=<YOUR ENDPOINT>" \ | ||
-e "OPENAI_API_TYPE=AZURE" \ | ||
-e "OPENAI_AZURE_DEPLOYMENT=<YOUR DEPLOYMENT NAME>" \ | ||
cgr.dev/chainguard/gptscript:latest | ||
``` | ||
|
||
To run a basic hello world test, run the following: | ||
|
||
```bash | ||
docker run -e "OPENAI_API_KEY=<YOUR OPENAI API KEY>" cgr.dev/chainguard/gptscript:latest https://get.gptscript.ai/echo.gpt --input 'Hello, World!' | ||
``` | ||
|
||
<!--body:end--> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
} | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters