Coder Social home page Coder Social logo

smndtrl / rules_oci Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bazel-contrib/rules_oci

0.0 0.0 0.0 1.06 MB

Bazel rules for building OCI containers

License: Apache License 2.0

Shell 11.21% Go 1.06% Rust 0.03% Smarty 0.90% Starlark 86.49% jq 0.32%

rules_oci's Introduction

Bazel rules for OCI containers

This is a "barebones" alternative to rules_docker.

We start from first principles and avoided some pitfalls we learned in maintaining that repo:

  • Use a toolchain consisting of off-the-shelf, pre-built layer and container manipulation tools.
  • Don't write language-specific rules, as we cannot be experts on all languages, nor can users deal with the versioning issues that come with dependencies we would be forced to take on the rules for those languages.
  • Don't be docker-specific, now that it has a commercial license and other container runtimes exist (podman for example).
  • Use our toolchain hermetically: don't assume there is a docker pre-installed on the machine.
  • Keep a tight complexity budget for the project so we are able to commit to effective maintenance.

Need help? This ruleset has support provided by https://aspect.dev.

Installation

To use a commit rather than a release, you can point at any SHA of the repo.

For example to use commit abc123:

  1. Replace url = "https://github.com/bazel-contrib/rules_oci/releases/download/v0.1.0/rules_oci-v0.1.0.tar.gz" with a GitHub-provided source archive like url = "https://github.com/bazel-contrib/rules_oci/archive/abc123.tar.gz"
  2. Replace strip_prefix = "rules_oci-0.1.0" with strip_prefix = "rules_oci-abc123"
  3. Update the sha256. The easiest way to do this is to comment out the line, then Bazel will print a message with the correct value.

Note that GitHub source archives don't have a strong guarantee on the sha256 stability, see https://github.blog/2023-02-21-update-on-the-future-stability-of-source-code-archives-and-hashes

Usage

rules_oci does not contain language-specific rules, but we do have limited documentation on how to accomplish typical tasks, and how to migrate from the language-specific rules in rules_docker.

Your language not listed above? Please contribute engineering resources or financially through our Sponsor link!

There are some generic examples of usage in the examples folder. Note that these examples rely on the setup code in the /WORKSPACE file in the root of this repo.

Choosing between zot or crane as the local registry

rules_oci supports two different registry implementation for the temporary storage within actions spawned by bazel.

  1. By default we recommend using zot as it stores blobs on disk, however it doesn't support Docker-format images.
  2. crane is memory hungry as it stores blobs in memory, leading to high memory usage. However it supports both OCI and Docker formats which is quite useful for using Docker images pulled from the registries such as DockerHub.

Public API Docs

Construct image layers

  • oci_image Build an OCI compatible container image.
  • oci_image_index Build a multi-architecture OCI compatible container image.
  • oci_tarball Creates tarball from oci_image that can be loaded by runtimes.

Pull and Push

  • oci_pull Pulls image layers using Bazel's downloader.
  • oci_push Push an oci_image or oci_image_index to a remote registry.

Testing

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.