-
Notifications
You must be signed in to change notification settings - Fork 1
/
BUILD
83 lines (73 loc) · 1.74 KB
/
BUILD
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_docker//container:container.bzl",
"container_image", "container_push",
container_repositories = "repositories",
)
load("@io_bazel_rules_docker//contrib:passwd.bzl", "passwd_entry", "passwd_tar")
load("@io_bazel_rules_docker//contrib:group.bzl", "group_entry", "group_file")
load("@bazel_tools//tools/build_defs/pkg:pkg.bzl", "pkg_tar")
load("@io_bazel_rules_docker//go:image.bzl", "go_image")
# Create /etc/passwd with the root user
passwd_entry(
name = "root_user",
gid = 0,
uid = 0,
username = "root",
)
passwd_tar(
name = "passwd",
entries = [
":root_user",
],
passwd_file_pkg_dir = "etc",
)
# Create /etc/group with the root group
group_entry(
name = "root_group",
gid = 0,
groupname = "root",
)
group_file(
name = "group",
entries = [
":root_group",
],
)
pkg_tar(
name = "group_tar",
srcs = [":group"],
mode = "0644",
package_dir = "etc",
)
container_image(
name = "fedora_distroless",
rpms = ["@glibc//file", "@ca_certificates//file"],
tars = [
":group_tar",
":passwd",
":nsswitch.tar",
":tmp.tar",
],
env = {
"PATH": "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
},
)
go_image(
name = "go_image",
srcs = ["test.go"],
importpath = "github.com/your/path/here",
goarch = "amd64",
goos = "linux",
pure = "off",
base = ":fedora_distroless",
)
container_push(
name = "publish",
format = "Docker",
registry = "index.docker.io",
repository = "rmohr/fedora-distroless",
image = ":fedora_distroless",
# Trigger stamping.
stamp = True,
)