Skip to content

feat(cli): add command to create custom OCI images from directories #5844

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 14, 2025

Conversation

mudler
Copy link
Owner

@mudler mudler commented Jul 13, 2025

Description

This PR introduces a new command, local-ai util create-oci-image , in the CLI to allow to create OCI images directly from source files or directory. this can be really handy to create backends for platforms that do not support docker natively such as macOS on arm64. This is required for #5790 in order to package the backend as OCI images (but the CI can't run docker on the first place).

How to use:

# Example usage: ./local-ai util create-oci-image <directory>
# Help
local-ai util create-oci-image --help

Usage: local-ai util create-image <input> ... [flags]

Create an OCI image from a file or a directory

Arguments:
  <input> ...    Input file or directory to create an OCI image from

Flags:
  -h, --help                      Show context-sensitive help.
      --log-level=LOG-LEVEL       Set the level of logs to output [error,warn,info,debug,trace] ($LOCALAI_LOG_LEVEL)

      --output="image.tar"        Output OCI image name
      --image-name="localai"      Image name
      --platform="linux/amd64"    Platform of the image

It includes the addition of a new command, CreateImageCMD, and its associated functionality. Below are the key changes:

New Feature: OCI Image Creation

  • Imports Added: Added new imports for os, path/filepath, strings, and the archiver/v3 and oci packages to support file handling and OCI image creation.
  • New Command Struct: Introduced the CreateImageCMD struct, which defines the input parameters for creating an OCI image, such as input files, output file name, image name, and platform.
  • Command Logic: Implemented the Run method for CreateImageCMD, which:
    • Creates a temporary directory.
    • Archives the input files or directories into a tar file.
    • Uses the oci.CreateTar function to generate the OCI image with the specified parameters.

Notes for Reviewers

Signed commits

  • Yes, I signed my commits.

Copy link

netlify bot commented Jul 13, 2025

Deploy Preview for localai ready!

Name Link
🔨 Latest commit 9a80600
🔍 Latest deploy log https://app.netlify.com/projects/localai/deploys/687417657986d00008fd9b77
😎 Deploy Preview https://deploy-preview-5844--localai.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@mudler mudler force-pushed the feat/create-image-command branch from 5dfbd0f to d322708 Compare July 13, 2025 16:51
@mudler mudler force-pushed the feat/create-image-command branch from d322708 to 9a80600 Compare July 13, 2025 20:30
@mudler mudler merged commit 354c0b7 into master Jul 14, 2025
28 checks passed
@mudler mudler deleted the feat/create-image-command branch July 14, 2025 06:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant