Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
# Disable deprecated starlark host transitions
common --incompatible_disable_starlark_host_transitions

# Enable Bzlmod for Bazel module support
common --enable_bzlmod
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
bazel-*
.ijwb
.idea/

.vscode/
42 changes: 42 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
"""Bazel module for rules_minidock - Minimal Docker/OCI container image rules."""

module(
name = "rules_minidock",
version = "0.1.0",
compatibility_level = 1,
)

# Required dependencies
bazel_dep(name = "platforms", version = "0.0.11")

# Test dependencies
bazel_dep(name = "rules_python", version = "0.40.0", dev_dependency = True)

python = use_extension("@rules_python//python/extensions:python.bzl", "python", dev_dependency = True)
python.toolchain(python_version = "3.10")
use_repo(python, "python_versions")

pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip", dev_dependency = True)
pip.parse(
hub_name = "pip",
python_version = "3.10",
requirements_lock = "//tests/simple_flow:requirements_lock_3_10.txt",
)
use_repo(pip, "pip")

# Test container repositories
test_repos = use_extension("//minidock/remote_tools:extensions.bzl", "test_repos", dev_dependency = True)
use_repo(test_repos, "bazel_320")

# Register the toolchain extension
minidock_tools = use_extension("//minidock/remote_tools:extensions.bzl", "minidock_tools")
use_repo(
minidock_tools,
"rules_minidock__merge_app_linux_x86_64",
"rules_minidock__merge_app_macos_aarch64",
"rules_minidock__merge_app_macos_x86_64",
"rules_minidock__puller_app",
"rules_minidock__pusher_app_linux_x86_64",
"rules_minidock__pusher_app_macos_aarch64",
"rules_minidock__pusher_app_macos_x86_64",
)
2,932 changes: 2,932 additions & 0 deletions MODULE.bazel.lock

Large diffs are not rendered by default.

30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,36 @@

These rules may not be suitable for you, they are not setup/designed to cover a huge set of use cases. Pull requests to add new features, especially those well factored to keep the core small will be accepted. For a far more broad set of support, and if in doubt, generally use: https://github.com/bazelbuild/rules_docker

## Setup

**Note:** This repository requires Bazel 6.0+ with Bzlmod enabled.

Add the following to your `MODULE.bazel` file:

```python
bazel_dep(name = "rules_minidock", version = "0.1.0")
Comment thread
adam-singer marked this conversation as resolved.

# Use git_override since rules_minidock is not published to the Bazel registry
git_override(
module_name = "rules_minidock",
remote = "https://github.com/bazeltools/rules_minidock",
commit = "<git_commit>",
)

# Load the minidock tools extension from extensions.bzl
minidock_tools = use_extension("@rules_minidock//minidock/remote_tools:extensions.bzl", "minidock_tools")
use_repo(
minidock_tools,
"rules_minidock__merge_app_linux_x86_64",
"rules_minidock__merge_app_macos_aarch64",
"rules_minidock__merge_app_macos_x86_64",
"rules_minidock__puller_app",
"rules_minidock__pusher_app_linux_x86_64",
"rules_minidock__pusher_app_macos_aarch64",
"rules_minidock__pusher_app_macos_x86_64",
)
```


### Why these rules?
Less dependencies, there is no need of any other support java/go/rust to use these rules. All tools are pre-built in the `rules_minidock_tools` repo, and are supplied for a few platforms. Generally if these tools don't meet your needs, we aim to have these rules setup so that it should be easy and reasonable to swap out these tools for others as you see fit. That is, primary tooling covers:
Expand Down
15 changes: 0 additions & 15 deletions WORKSPACE

This file was deleted.

4 changes: 2 additions & 2 deletions minidock/container_assemble.bzl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("@com_github_bazeltools_rules_minidock//minidock:providers.bzl", "ContainerInfo", "ManifestResult", "AssembledData", "ExternalContainerConfig", "container_info_struct")
load("@rules_minidock//minidock:providers.bzl", "ContainerInfo", "ManifestResult", "AssembledData", "ExternalContainerConfig", "container_info_struct")


launcher_template = """
Expand Down Expand Up @@ -83,7 +83,7 @@ container_assemble = rule(
doc = "The label of the image to push.",
),
"merger": attr.label(
default = "@com_github_bazeltools_rules_minidock//minidock/remote_tools:merge_app",
default = "@rules_minidock//minidock/remote_tools:merge_app",
cfg = "exec",
executable = True,
),
Expand Down
6 changes: 3 additions & 3 deletions minidock/container_binary.bzl
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
load(
"@com_github_bazeltools_rules_minidock//minidock:container_data.bzl",
"@rules_minidock//minidock:container_data.bzl",
"container_data",
)
load(
"@com_github_bazeltools_rules_minidock//minidock:container_compose.bzl",
"@rules_minidock//minidock:container_compose.bzl",
"container_compose",
)

Expand Down Expand Up @@ -104,7 +104,7 @@ def container_binary(
name,
binary,
binary_name = None,
app_launch_template_script = "@com_github_bazeltools_rules_minidock//minidock:app_launch_template"):
app_launch_template_script = "@rules_minidock//minidock:app_launch_template"):
if binary_name == None:
binary_name = name
launcher_name = "%s.launcher" % name
Expand Down
2 changes: 1 addition & 1 deletion minidock/container_compose.bzl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("@com_github_bazeltools_rules_minidock//minidock:providers.bzl", "ContainerInfo", "ExternalContainerConfig")
load("@rules_minidock//minidock:providers.bzl", "ContainerInfo", "ExternalContainerConfig")


def __copy_provider_with(current, parent):
Expand Down
2 changes: 1 addition & 1 deletion minidock/container_config.bzl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("@com_github_bazeltools_rules_minidock//minidock:providers.bzl", "ContainerInfo")
load("@rules_minidock//minidock:providers.bzl", "ContainerInfo")

def __expand_env(ctx, env):
env_lst = None
Expand Down
2 changes: 1 addition & 1 deletion minidock/container_data.bzl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("@com_github_bazeltools_rules_minidock//minidock:providers.bzl", "ContainerInfo")
load("@rules_minidock//minidock:providers.bzl", "ContainerInfo")

# Probably should nuke these/include them in whatever app produces the tar ball? -- these are from rules_docker
def _join_path(directory, path):
Expand Down
4 changes: 2 additions & 2 deletions minidock/container_push.bzl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("@com_github_bazeltools_rules_minidock//minidock:providers.bzl", "AssembledData")
load("@rules_minidock//minidock:providers.bzl", "AssembledData")


launcher_template = """
Expand Down Expand Up @@ -143,7 +143,7 @@ container_push = rule(
doc = "The label of the file with tag values, added to tag. Can use multiple tags separated by , or whitespace",
),
"pusher": attr.label(
default = "@com_github_bazeltools_rules_minidock//minidock/remote_tools:pusher_app",
default = "@rules_minidock//minidock/remote_tools:pusher_app",
cfg = "exec",
executable = True,
allow_files = True,
Expand Down
2 changes: 1 addition & 1 deletion minidock/external_container_repo.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def ___external_container_repo(repository_ctx):
fail("Failed to fetch metadata: %s\nSTDOUT: %s\nSTDERR: %s" % (fetch_args, result.stdout,result.stderr))

repository_ctx.file("BUILD", """package(default_visibility = ["//visibility:public"])
load("@com_github_bazeltools_rules_minidock//minidock/internal:external_metadata.bzl", "external_metadata")
load("@rules_minidock//minidock/internal:external_metadata.bzl", "external_metadata")
external_metadata(
name = "metadata",
config = "config.json",
Expand Down
2 changes: 1 addition & 1 deletion minidock/internal/external_metadata.bzl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("@com_github_bazeltools_rules_minidock//minidock:providers.bzl", "ContainerInfo")
load("@rules_minidock//minidock:providers.bzl", "ContainerInfo")

def __external_metadata_impl(ctx):
manifest = ctx.files.manifest[0]
Expand Down
92 changes: 92 additions & 0 deletions minidock/remote_tools/extensions.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
"""Module extension for rules_minidock tooling."""

load("//minidock/remote_tools:load_tool.bzl", "load_tool")
load("//minidock/remote_tools:repo_rule_load_tool.bzl", "repo_rule_load_tool")
load("//minidock:external_container_repo.bzl", "external_container_repo")

def _minidock_tools_impl(module_ctx):
"""Implementation of the minidock_tools module extension.

This extension loads all the platform-specific tools needed by rules_minidock,
including the merge and pusher applications for various platforms.
"""

# RUST_BINARIES_AUTO_GEN_REPLACE_SECTION_START
load_tool(
name = "rules_minidock__merge_app_linux_x86_64",
sha256 = "ec36e90e1dfd4ab486647715acb20c404ed5e1427ec51fc6bcd0fa2d471fbf6c",
packaged = False,
binary_path = "merge-app-linux-x86_64",
urls = ["https://github.com/bazeltools/rules_minidock_tools/releases/download/v0.0.75/merge-app-linux-x86_64"],
)

load_tool(
name = "rules_minidock__merge_app_macos_x86_64",
sha256 = "633065d4f5199c20fe0fc9a750fc41f2b5bf0b28d4f51d5d4dab9bc3f1a56c97",
packaged = False,
binary_path = "merge-app-macos-x86_64",
urls = ["https://github.com/bazeltools/rules_minidock_tools/releases/download/v0.0.75/merge-app-macos-x86_64"],
)

load_tool(
name = "rules_minidock__merge_app_macos_aarch64",
sha256 = "110d44df10c495d972533cb4db134dd1a95db7c436180655b1258e1f17c9154b",
packaged = False,
binary_path = "merge-app-macos-aarch64",
urls = ["https://github.com/bazeltools/rules_minidock_tools/releases/download/v0.0.75/merge-app-macos-aarch64"],
)

load_tool(
name = "rules_minidock__pusher_app_linux_x86_64",
sha256 = "6448bb16191cb4e0f8750003c43ab158df58ecc1cd0644179e60fbf0556638c7",
packaged = False,
binary_path = "pusher-app-linux-x86_64",
urls = ["https://github.com/bazeltools/rules_minidock_tools/releases/download/v0.0.75/pusher-app-linux-x86_64"],
)

load_tool(
name = "rules_minidock__pusher_app_macos_x86_64",
sha256 = "da24d3a25d46c7561bcdb21fa21c938cac20862a26d62f774f46e8b38ed68a32",
packaged = False,
binary_path = "pusher-app-macos-x86_64",
urls = ["https://github.com/bazeltools/rules_minidock_tools/releases/download/v0.0.75/pusher-app-macos-x86_64"],
)

load_tool(
name = "rules_minidock__pusher_app_macos_aarch64",
sha256 = "449fbbe83f680138143ace22f02d980197ddcd8c94dbf293f448833e403e37e1",
packaged = False,
binary_path = "pusher-app-macos-aarch64",
urls = ["https://github.com/bazeltools/rules_minidock_tools/releases/download/v0.0.75/pusher-app-macos-aarch64"],
)

repo_rule_load_tool(
name = "rules_minidock__puller_app",
platform_to_sha_pairs = {
"linux__x86_64": ["9a28cd949268a397e57c4faf106a942f3053438c84b70077072452d83971060a", "https://github.com/bazeltools/rules_minidock_tools/releases/download/v0.0.75/puller-app-linux-x86_64"],
"macos__x86_64": ["70bc80d0f1e098a6d2f522a4f907011f54ce15e5a8bd300ee3442a777f75eafb", "https://github.com/bazeltools/rules_minidock_tools/releases/download/v0.0.75/puller-app-macos-x86_64"],
"macos__aarch64": ["950d2192cc23ff4dd44d7dc7b942b6ec02b425a03d648924136449ff0702002d", "https://github.com/bazeltools/rules_minidock_tools/releases/download/v0.0.75/puller-app-macos-aarch64"],
},
)
# RUST_BINARIES_AUTO_GEN_REPLACE_SECTION_END

minidock_tools = module_extension(
implementation = _minidock_tools_impl,
)

def _test_repos_impl(module_ctx):
"""Implementation of the test_repos module extension.

This extension sets up external container repositories for testing.
"""
# Set up the bazel_320 container for tests
external_container_repo(
name = "bazel_320",
digest = "sha256:08434856d8196632b936dd082b8e03bae0b41346299aedf60a0d481ab427a69f",
registry = "gcr.io",
repository = "bazel-public/bazel",
)

test_repos = module_extension(
implementation = _test_repos_impl,
)
2 changes: 1 addition & 1 deletion minidock/remote_tools/load_tool.bzl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
build_file_template = """
load("@com_github_bazeltools_rules_minidock//minidock/remote_tools:wrap_executable.bzl", "wrap_executable")
load("@rules_minidock//minidock/remote_tools:wrap_executable.bzl", "wrap_executable")

wrap_executable(
name = "{name}",
Expand Down
2 changes: 1 addition & 1 deletion minidock/remote_tools/repo_rule_load_tool.bzl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
build_file_template = """
load("@com_github_bazeltools_rules_minidock//minidock/remote_tools:wrap_executable.bzl", "wrap_executable")
load("@rules_minidock//minidock/remote_tools:wrap_executable.bzl", "wrap_executable")
exports_files(["exe"])
wrap_executable(
name = "{name}",
Expand Down
70 changes: 0 additions & 70 deletions minidock/remote_tools/repositories.bzl

This file was deleted.

14 changes: 7 additions & 7 deletions minidock/remote_tools/update_remote_tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ TEMPDIR="$(mktemp -d "${TMPDIR:-/tmp}/tmpupdate.XXXXXXXX")"
trap 'rm -rf "$TEMPDIR"' EXIT

URL_BASE="https://github.com/${CI_UPDATE_GITHUB_ORG_AND_REPO_NAME}/releases/download/${RELEASE_TAG}"
cat minidock/remote_tools/repositories.bzl | sed '/RUST_BINARIES_AUTO_GEN_REPLACE_SECTION_START/,$d' > $TEMPDIR/prelude.txt
cat minidock/remote_tools/repositories.bzl | sed '1,/RUST_BINARIES_AUTO_GEN_REPLACE_SECTION_END/ d' > $TEMPDIR/suffix.txt
cat minidock/remote_tools/extensions.bzl | sed '/RUST_BINARIES_AUTO_GEN_REPLACE_SECTION_START/,$d' > $TEMPDIR/prelude.txt
cat minidock/remote_tools/extensions.bzl | sed '1,/RUST_BINARIES_AUTO_GEN_REPLACE_SECTION_END/ d' > $TEMPDIR/suffix.txt

TOOLS="merge-app pusher-app"
PLATFORM_OS="linux-x86_64 macos-x86_64 macos-aarch64"
Expand Down Expand Up @@ -100,8 +100,8 @@ cat << EOM >>$TMP_OUTPUT
EOM


cat $TEMPDIR/prelude.txt > minidock/remote_tools/repositories.bzl
echo " # RUST_BINARIES_AUTO_GEN_REPLACE_SECTION_START" >> minidock/remote_tools/repositories.bzl
cat $TEMPDIR/result.bzl >> minidock/remote_tools/repositories.bzl
echo " # RUST_BINARIES_AUTO_GEN_REPLACE_SECTION_END" >> minidock/remote_tools/repositories.bzl
cat $TEMPDIR/suffix.txt >> minidock/remote_tools/repositories.bzl
cat $TEMPDIR/prelude.txt > minidock/remote_tools/extensions.bzl
echo " # RUST_BINARIES_AUTO_GEN_REPLACE_SECTION_START" >> minidock/remote_tools/extensions.bzl
cat $TEMPDIR/result.bzl >> minidock/remote_tools/extensions.bzl
echo " # RUST_BINARIES_AUTO_GEN_REPLACE_SECTION_END" >> minidock/remote_tools/extensions.bzl
cat $TEMPDIR/suffix.txt >> minidock/remote_tools/extensions.bzl
Loading