wip docker/alpine

main
Motiejus Jakštys 2021-05-24 00:11:58 +03:00
parent c63e2aef29
commit 82c2d77d04
2 changed files with 22 additions and 4 deletions

13
BUILD
View File

@ -1,5 +1,7 @@
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
load("//src/undocker:rules.bzl", "rootfs") load("//src/undocker:rules.bzl", "rootfs")
load("@io_bazel_rules_docker//container:container.bzl", "container_bundle",
)
go_library( go_library(
name = "go_default_library", name = "go_default_library",
@ -18,3 +20,14 @@ go_binary(
embed = [":go_default_library"], embed = [":go_default_library"],
visibility = ["//visibility:public"], visibility = ["//visibility:public"],
) )
container_bundle(
name="alpine",
images={"base": "@alpine//image"},
)
rootfs(
name="alpine-rootfs1",
src=":alpine.tar",
output="alpine-rootfs.tar",
)

View File

@ -1,22 +1,27 @@
def _rootfs_impl(ctx): def _rootfs_impl(ctx):
output = ctx.outputs.output
ctx.actions.run( ctx.actions.run(
executable = ctx.files._undocker, outputs = [output],
executable = ctx.files._undocker[0],
arguments = [ arguments = [
ctx.attr.src, ctx.attr.src.path,
ctx.output, output.path,
], ],
) )
rootfs = rule( rootfs = rule(
doc = "Generate a rootfs from a docker container image", doc = "Generate a rootfs from a docker container image",
implementation = _rootfs_impl, implementation = _rootfs_impl,
outputs = {
"out": "%{name}.tar",
},
attrs = { attrs = {
"src": attr.label( "src": attr.label(
doc = "Input container tarball", doc = "Input container tarball",
mandatory = True, mandatory = True,
allow_single_file = [".tar"], allow_single_file = [".tar"],
), ),
"out": attr.output( "output": attr.output(
doc = "Output rootfs tarball", doc = "Output rootfs tarball",
mandatory = True, mandatory = True,
), ),