From 7de78f30dfa26b3f0dcf6519efdc3d6c1e0581a3 Mon Sep 17 00:00:00 2001 From: RJ Sampson Date: Mon, 6 May 2024 16:18:05 -0600 Subject: [PATCH] feat(images): Add MLflow Signed-off-by: RJ Sampson --- generated.tf | 9 ++++++ images/mlflow/README.md | 29 +++++++++++++++++++ images/mlflow/config/main.tf | 34 +++++++++++++++++++++++ images/mlflow/generated.tf | 13 +++++++++ images/mlflow/main.tf | 38 +++++++++++++++++++++++++ images/mlflow/metadata.yaml | 13 +++++++++ images/mlflow/tests/check-mlflow.sh | 5 ++++ images/mlflow/tests/main.tf | 43 +++++++++++++++++++++++++++++ 8 files changed, 184 insertions(+) create mode 100644 images/mlflow/README.md create mode 100644 images/mlflow/config/main.tf create mode 100644 images/mlflow/generated.tf create mode 100644 images/mlflow/main.tf create mode 100644 images/mlflow/metadata.yaml create mode 100755 images/mlflow/tests/check-mlflow.sh create mode 100644 images/mlflow/tests/main.tf diff --git a/generated.tf b/generated.tf index 5914ca004d..27d397926a 100644 --- a/generated.tf +++ b/generated.tf @@ -865,6 +865,11 @@ module "ml-metadata-store-server" { target_repository = "${var.target_repository}/ml-metadata-store-server" } +module "mlflow" { + source = "./images/mlflow" + target_repository = "${var.target_repository}/mlflow" +} + module "mongodb" { source = "./images/mongodb" target_repository = "${var.target_repository}/mongodb" @@ -2215,6 +2220,10 @@ output "summary_ml-metadata-store-server" { value = module.ml-metadata-store-server.summary } +output "summary_mlflow" { + value = module.mlflow.summary +} + output "summary_mongodb" { value = module.mongodb.summary } diff --git a/images/mlflow/README.md b/images/mlflow/README.md new file mode 100644 index 0000000000..5f6f2cdcd9 --- /dev/null +++ b/images/mlflow/README.md @@ -0,0 +1,29 @@ + +# mlflow +| | | +| - | - | +| **OCI Reference** | `cgr.dev/chainguard/mlflow` | + + +* [View Image in Chainguard Academy](https://edu.chainguard.dev/chainguard/chainguard-images/reference/mlflow/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.* + +--- + + + +A minimal, [Wolfi](https://github.com/wolfi-dev)-based image for MLflow, an open source platform for the machine learning lifecycle. + + + + +## Download this Image +The image is available on `cgr.dev`: + +``` +docker pull cgr.dev/chainguard/mlflow:latest +``` + + + diff --git a/images/mlflow/config/main.tf b/images/mlflow/config/main.tf new file mode 100644 index 0000000000..7a8afecb9b --- /dev/null +++ b/images/mlflow/config/main.tf @@ -0,0 +1,34 @@ +terraform { + required_providers { + apko = { source = "chainguard-dev/apko" } + } +} + +variable "extra_packages" { + description = "Additional packages to install." + type = list(string) + default = ["mlflow"] +} + +variable "environment" { + default = {} +} + +module "accts" { + source = "../../../tflib/accts" +} + +output "config" { + value = jsonencode({ + contents = { + packages = var.extra_packages + } + accounts = module.accts.block + environment = merge({ + "PATH" : "/usr/share/mlflow/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", + }, var.environment) + entrypoint = { + command = "/usr/share/mlflow/bin/python3" + } + }) +} diff --git a/images/mlflow/generated.tf b/images/mlflow/generated.tf new file mode 100644 index 0000000000..e59873f1c5 --- /dev/null +++ b/images/mlflow/generated.tf @@ -0,0 +1,13 @@ +# DO NOT EDIT - this file is autogenerated by tfgen + +output "summary" { + value = merge( + { + basename(path.module) = { + "ref" = module.latest.image_ref + "config" = module.latest.config + "tags" = ["latest"] + } + }) +} + diff --git a/images/mlflow/main.tf b/images/mlflow/main.tf new file mode 100644 index 0000000000..ba93c4b5a6 --- /dev/null +++ b/images/mlflow/main.tf @@ -0,0 +1,38 @@ +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" +} + +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/mlflow/metadata.yaml b/images/mlflow/metadata.yaml new file mode 100644 index 0000000000..d956407c62 --- /dev/null +++ b/images/mlflow/metadata.yaml @@ -0,0 +1,13 @@ +name: mlflow +image: cgr.dev/chainguard/mlflow +logo: https://storage.googleapis.com/chainguard-academy/logos/mlflow.svg +endoflife: "" +console_summary: "" +short_description: | + A minimal, [Wolfi](https://github.com/wolfi-dev)-based image for MLflow, an open source platform for the machine learning lifecycle. +compatibility_notes: "" +readme_file: README.md +upstream_url: https://mlflow.org/ +keywords: + - ai + - python diff --git a/images/mlflow/tests/check-mlflow.sh b/images/mlflow/tests/check-mlflow.sh new file mode 100755 index 0000000000..fa89a28b90 --- /dev/null +++ b/images/mlflow/tests/check-mlflow.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +set -o errexit -o nounset -o errtrace -o pipefail -x + +cwd=$(cd "${0%/*}" && pwd) diff --git a/images/mlflow/tests/main.tf b/images/mlflow/tests/main.tf new file mode 100644 index 0000000000..b8c09d7ca2 --- /dev/null +++ b/images/mlflow/tests/main.tf @@ -0,0 +1,43 @@ +terraform { + required_providers { + oci = { source = "chainguard-dev/oci" } + imagetest = { source = "chainguard-dev/imagetest" } + } +} + +variable "digest" { + description = "The image digest to run tests over." +} + +data "imagetest_inventory" "this" {} + +resource "imagetest_container_volume" "volume" { + name = "scratch-volume" + inventory = data.imagetest_inventory.this +} + +resource "imagetest_harness_docker" "this" { + name = "jre" + inventory = data.imagetest_inventory.this + + mounts = [{ + source = path.module + destination = "/tests" + }] + + envs = { + "IMAGE_NAME" : var.digest + } +} + +resource "imagetest_feature" "basic" { + name = "Test MLflow" + harness = imagetest_harness_docker.this + + steps = [{ + name = "Import test" + cmd = <