Skip to content

Commit e6fccc6

Browse files
authored
feat: Add support for docker-swss-layer and docker-orchagent (sonic-net#2)
* fix: Adjust paths of local path overrides * fix: s:target_release:suiltes: * fix: Add bazelignore to ignore internal modules * feat(swss): Wire swss and sairedis to MODULE.bazel * fix(swss): Add libdashapi pkg * checkpoint: Almost all the rdeps of docker-swss-layer-bookworm * fix: Almost there, need cfggen * cleanup: Upgrade rules_py, remove patch * fix(cfggen): Add libyang as a dep of cfggen bin * WIP: Almost all of docker-orchagent * cleanup: Upgrade tar.bzl * fix(sdist_build_from_src): Add repository name to sdist package * fix(sonic-cfggen-bin): Pipe in more dependencies for cfggen CLI * checkpoint: Can run configgen without crashing * checkpoint(orchagent): create docker-init.sh * checkpoint: clean paths * cleanup: remove TODOs * fix: Path to supervisord * cleanup
1 parent 9c66e0c commit e6fccc6

22 files changed

Lines changed: 13672 additions & 3144 deletions

File tree

.bazelignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Projects that have their own MODULE.bazel files
2+
src/sonic-py-common
3+
src/sonic-supervisord-utilities
4+
src/libyang3
5+
src/sonic-yang-mgmt
6+
src/libyang3-py3
7+
src/sonic-config-engine
8+

BUILD.bazel

Whitespace-only changes.

MODULE.bazel

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,15 @@ bazel_dep(name = "platforms", version = "1.0.0")
66
bazel_dep(name = "bazel_skylib", version = "1.8.2")
77
bazel_dep(name = "rules_python", version = "1.6.3")
88
bazel_dep(name = "rules_oci", version = "2.2.6")
9-
bazel_dep(name = "tar.bzl", version = "0.5.5")
9+
bazel_dep(name = "tar.bzl", version = "0.8.1")
1010

1111
bazel_dep(name = "rules_distroless", version = "0.0.0", repo_name = "rules_deb")
1212
local_path_override(
1313
module_name = "rules_distroless",
1414
path = "../rules_distroless"
1515
)
1616

17-
bazel_dep(name = "aspect_rules_py", version = "1.7.1")
18-
single_version_override(
19-
module_name = "aspect_rules_py",
20-
patch_strip = 1,
21-
patches = [
22-
"//patches:aspect_rules_py.patch",
23-
],
24-
)
17+
bazel_dep(name = "aspect_rules_py", version = "1.8.4")
2518

2619
python = use_extension("@rules_python//python/extensions:python.bzl", "python")
2720
python.toolchain(python_version = "3.11.6")
@@ -158,3 +151,33 @@ local_path_override(
158151
module_name = "sonic-platform-daemons",
159152
path = "../sonic-platform-daemons",
160153
)
154+
155+
# Needed for swss.
156+
157+
bazel_dep(name = "rules_shell", version = "0.6.1")
158+
bazel_dep(name = "bazel_lib", version = "3.1.1")
159+
160+
bazel_dep(name = "sonic-swss", version = "0.0.0", repo_name = "sonic_swss")
161+
local_path_override(
162+
module_name = "sonic-swss",
163+
path = "../sonic-swss"
164+
)
165+
166+
bazel_dep(name = "sonic-sairedis", version = "0.0.0", repo_name = "sonic_sairedis")
167+
local_path_override(
168+
module_name = "sonic-sairedis",
169+
path = "../sonic-sairedis",
170+
)
171+
172+
bazel_dep(name = "sai", version = "0.0.0")
173+
local_path_override(
174+
module_name = "sai",
175+
path = "../sonic-sairedis/SAI",
176+
)
177+
178+
bazel_dep(name = "sonic-dash-api", version = "0.0.0", repo_name = "sonic_dash_api")
179+
local_path_override(
180+
module_name = "sonic-dash-api",
181+
path = "../sonic-dash-api",
182+
)
183+

MODULE.bazel.lock

Lines changed: 5837 additions & 3109 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dockers/docker-base-bookworm/base_bookworm.MODULE.bazel

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ apt.sources_list(
1616

1717
apt.install(
1818
dependency_set = "bookworm",
19-
target_release = "bookworm",
19+
suites = ["bookworm", "bookworm-updates", "bookworm-security"],
2020
packages = [
2121
"base-files",
2222
"ca-certificates",
@@ -60,9 +60,31 @@ apt.install(
6060
"libgmpxx4ldbl",
6161
"libpcre2-8-0",
6262
"libyang2-dev",
63-
]
63+
64+
65+
# from rules/libteam.mk
66+
"libteam5",
67+
"libteam-dev",
68+
"libteamdctl0",
69+
70+
# from docker-orchagent/Dockerfile.j2
71+
"ifupdown",
72+
"arping",
73+
# "iproute2", # Already here
74+
"ndisc6",
75+
"tcpdump",
76+
"bridge-utils",
77+
"conntrack",
78+
"ndppd",
79+
"python3-protobuf",
80+
"pciutils",
81+
"python3-netifaces",
82+
],
6483
)
6584

85+
apt.lock(
86+
into = "packages.lock",
87+
)
6688
use_repo(apt, "bookworm")
6789

6890

dockers/docker-base-bookworm/pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,7 @@ dependencies = [
2525
"cffi",
2626
"build",
2727
"setuptools",
28+
29+
# dockers-orchagent deps
30+
"scapy==2.4.5",
2831
]

dockers/docker-base-bookworm/uv.lock

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
load("@rules_oci//oci:defs.bzl", "oci_image", "oci_load")
2+
load("@rules_deb//distroless:defs.bzl", "flatten", "group", "passwd")
3+
load("@tar.bzl", "tar", "mutate")
4+
load("//dockers/docker-base-bookworm:site_packages.bzl", "site_packages")
5+
load("@bazel_lib//lib:run_binary.bzl", "run_binary")
6+
7+
8+
flatten(
9+
name = "apt_deps",
10+
tars = [
11+
"@bookworm//ifupdown-ng",
12+
"@bookworm//arping",
13+
"@bookworm//iproute2",
14+
"@bookworm//ndisc6",
15+
"@bookworm//tcpdump",
16+
"@bookworm//bridge-utils",
17+
"@bookworm//conntrack",
18+
"@bookworm//ndppd",
19+
"@bookworm//python3-protobuf",
20+
"@bookworm//pciutils",
21+
"@bookworm//python3-netifaces",
22+
],
23+
deduplicate = True,
24+
)
25+
26+
site_packages(
27+
name = "site-packages",
28+
srcs = [
29+
"@pip//scapy",
30+
],
31+
mutate = mutate(
32+
strip_prefix = "install",
33+
package_dir = "./usr",
34+
awk_script = "//dockers/docker-base-bookworm:mutate.awk",
35+
)
36+
)
37+
38+
# TODO: Unported, we don't support arm64 yet
39+
#
40+
# {% if ( CONFIGURED_ARCH == "armhf" or CONFIGURED_ARCH == "arm64" ) %}
41+
# # Fix for gcc/python/iputils-ping not found in arm docker
42+
# RUN apt-get install -y \
43+
# gcc \
44+
# iputils-ping
45+
# {% endif %}
46+
#
47+
# # Dependencies of restore_neighbors.py
48+
# RUN pip3 install pyroute2==0.5.14
49+
#
50+
# {% if ( CONFIGURED_ARCH == "armhf" or CONFIGURED_ARCH == "arm64" ) %}
51+
# # Remove installed gcc
52+
# RUN apt-get remove -y gcc
53+
# {% endif %}
54+
55+
# Debs and python wheels
56+
filegroup(
57+
name = "docker_orchagent_depends",
58+
srcs = [
59+
"//dockers/docker-swss-layer-bookworm:swss_runtime",
60+
],
61+
62+
)
63+
64+
# # TODO: enable asan when we figure out what dbg is going to look like
65+
# ifeq ($(ENABLE_ASAN), y)
66+
# $(DOCKER_ORCHAGENT)_DEPENDS += $(SWSS_DBG)
67+
# endif
68+
69+
# # Clean up
70+
# RUN apt-get purge -y build-essential python3-dev
71+
72+
tar(
73+
name = "source_files",
74+
srcs = [
75+
"arp_update.conf",
76+
"ndppd.conf",
77+
"tunnel_packet_handler.conf",
78+
"enable_counters.py",
79+
"tunnel_packet_handler.py",
80+
"orchagent.sh",
81+
"swssconfig.sh",
82+
"buffermgrd.sh",
83+
"//files:scripts/arp_update",
84+
"//files:build_templates/arp_update_vars.j2",
85+
# TODO: Not sure if these files are meant to be from here
86+
"//files:image_config/constants/constants.yml",
87+
"@sonic_swss_common//sonic-db-cli:sonic-db-cli",
88+
],
89+
mtree = [
90+
"./usr/share/sonic/templates/arp_update.conf type=file content=$(location :arp_update.conf)",
91+
"./usr/share/sonic/templates/ndppd.conf type=file content=$(location :ndppd.conf)",
92+
"./usr/share/sonic/templates/tunnel_packet_handler.conf type=file content=$(location :tunnel_packet_handler.conf)",
93+
"./usr/bin/enable_counters.py type=file content=$(location :enable_counters.py)",
94+
"./usr/bin/tunnel_packet_handler.py type=file content=$(location :tunnel_packet_handler.py)",
95+
"./usr/bin/orchagent.sh type=file content=$(location :orchagent.sh)",
96+
"./usr/bin/swssconfig.sh type=file content=$(location :swssconfig.sh)",
97+
"./usr/bin/buffermgrd.sh type=file content=$(location :buffermgrd.sh)",
98+
"./usr/bin/arp_update type=file content=$(location //files:scripts/arp_update)",
99+
"./usr/share/sonic/templates/arp_update_vars.j2 type=file content=$(location //files:build_templates/arp_update_vars.j2)",
100+
101+
# TODO: Not sure if these files are meant to be from here
102+
"./etc/sonic/constants.yml type=file content=$(location //files:image_config/constants/constants.yml)",
103+
"./usr/bin/sonic-db-cli type=file content=$(location @sonic_swss_common//sonic-db-cli:sonic-db-cli)",
104+
],
105+
)
106+
107+
tar(
108+
name = "jinja_templates",
109+
srcs = glob(
110+
["*.j2"],
111+
exclude = ["docker-init.j2"],
112+
),
113+
mutate = mutate(
114+
strip_prefix = package_name(),
115+
package_dir = "/usr/share/sonic/templates",
116+
)
117+
)
118+
119+
# TODO: handle asan enablement
120+
genrule(
121+
name = "run_cfggen",
122+
tools = ["@sonic_config_engine//:sonic-cfggen-bin"],
123+
srcs = [":docker-init.j2"],
124+
outs = ["docker-init.sh"],
125+
cmd = """
126+
$(execpath @sonic_config_engine//:sonic-cfggen-bin) \
127+
-a '{"ENABLE_ASAN": "y"}' \
128+
-t "$(execpath :docker-init.j2)" > $(OUTS)
129+
""",
130+
)
131+
132+
tar(
133+
name = "docker_init",
134+
srcs = [":run_cfggen"],
135+
mtree = [
136+
"./usr/bin/docker-init.sh mode=755 type=file contents=$(location :run_cfggen)"
137+
],
138+
)
139+
140+
# TODO: We probably wnat to represent this with an alias and a `select`,
141+
# and allow the individual implementations to live in `//platforms`.
142+
tar(
143+
name = "per_platform_files",
144+
srcs = [
145+
"//platform:vs/docker-sonic-vs/database_config.json",
146+
],
147+
mtree = [
148+
"./var/run/redis/sonic-db/database_config.json type=file contents=$(location //platform:vs/docker-sonic-vs/database_config.json)",
149+
],
150+
)
151+
152+
oci_image(
153+
name = "docker-orchagent",
154+
base = "//dockers/docker-swss-layer-bookworm",
155+
tars = [
156+
":apt_deps",
157+
":site-packages",
158+
":docker_orchagent_depends",
159+
":source_files",
160+
":jinja_templates",
161+
":docker_init",
162+
":per_platform_files",
163+
],
164+
env = {
165+
"DEBIAN_FRONTEND": "noninteractive",
166+
"SUPERVISORD_LOCATION": "/usr/bin/supervisord",
167+
},
168+
entrypoint = ["/usr/bin/docker-init.sh"],
169+
visibility = ["//visibility:public"]
170+
)
171+
172+
# $(DOCKER_ORCHAGENT)_BASE_IMAGE_FILES += swssloglevel:/usr/bin/swssloglevel
173+
# $(DOCKER_ORCHAGENT)_FILES += $(ARP_UPDATE_SCRIPT) $(ARP_UPDATE_VARS_TEMPLATE)
174+
175+
oci_load(
176+
name = "load",
177+
image = ":docker-orchagent",
178+
repo_tags = ["docker-orchagent:latest"]
179+
)
180+

dockers/docker-orchagent/docker-init.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,4 @@ if [ -f "$IS_SUPERVISOR" ]; then
7272
fi
7373
fi
7474

75-
exec /usr/local/bin/supervisord
75+
exec "${SUPERVISORD_LOCATION:-/usr/local/bin/supervisord}"
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
load("@rules_oci//oci:defs.bzl", "oci_image", "oci_load")
2+
load("@tar.bzl", "tar")
3+
load("@rules_deb//distroless:defs.bzl", "flatten")
4+
5+
# TODO BL: These I haven't found yet
6+
# $(SWSS)_RDEPENDS += $(PROTOBUF) $(PROTOBUF_LITE) $(PYTHON3_PROTOBUF)
7+
filegroup(
8+
name = "rdeps",
9+
srcs = [
10+
"@sonic_sairedis//meta:libsaimetadata_dev_pkg",
11+
"@sonic_sairedis//lib:libsairedis_dev_pkg",
12+
# TODO: Port libswsscommon if swsscommon_dist is not enough
13+
# # $(LIBSWSSCOMMON)
14+
# "@sonic_swss_common//:libswsscommon",
15+
"@sonic_dash_api//:libdashapi_dev_pkg",
16+
"@sonic_swss_common//pyext:swsscommon_dist",
17+
"@bookworm//libteam5:data",
18+
"@bookworm//libteamdctl0:data",
19+
],
20+
)
21+
22+
flatten(
23+
name = "swss_runtime",
24+
tars = [
25+
"@sonic_swss//:debian-data",
26+
":rdeps",
27+
],
28+
visibility = [
29+
"//dockers/docker-swss-layer-bookworm:__subpackages__",
30+
"//dockers/docker-orchagent:__subpackages__",
31+
],
32+
)
33+
34+
35+
# TODO: We may need to port this:
36+
# RUN apt-get install iputils-ping
37+
oci_image(
38+
name = "docker-swss-layer-bookworm",
39+
base = "//dockers/docker-config-engine-bookworm",
40+
tars = [
41+
":swss_runtime",
42+
],
43+
env = {
44+
"DEBIAN_FRONTEND": "noninteractive"
45+
},
46+
entrypoint = ["/usr/bin/supervisord"],
47+
visibility = [
48+
"//dockers/docker-swss-layer-bookworm:__subpackages__",
49+
"//dockers/docker-orchagent:__subpackages__",
50+
],
51+
)
52+
53+
oci_load(
54+
name = "load",
55+
image = ":docker-swss-layer-bookworm",
56+
repo_tags = ["docker-swss-layer-bookworm:latest"]
57+
)
58+

0 commit comments

Comments
 (0)