@@ -19,6 +19,12 @@ load("@rules_ros//ros:launch.bzl", "ros_launch")
1919load ("@rules_ros//ros:test.bzl" , "ros_test" )
2020load ("@rules_ros//ros:topic.bzl" , "ros_topic" )
2121load ("@rules_ros//third_party:expand_template.bzl" , "expand_template" )
22+ load (
23+ "@rules_oci//oci:defs.bzl" ,
24+ "oci_image" ,
25+ "oci_load"
26+ )
27+ load ("@rules_pkg//pkg:pkg.bzl" , "pkg_tar" )
2228
2329# Handling of ROS messages & services resembles to some extent Bazel's rules for
2430# handling protobuf messages (e.g. proto_library and cc_proto_library).
@@ -127,3 +133,37 @@ ros_topic(
127133 name = "rostopic" ,
128134 deps = [":chatter" ],
129135)
136+
137+
138+ # packages up the nodes, launch file, and all the other required runfiles.
139+ # Note the symlink is required in order to place the files where ros_launch is
140+ # expecting them to be.
141+ pkg_tar (
142+ name = "chatter_tar" ,
143+ srcs = [
144+ ":chatter" ,
145+ ],
146+ include_runfiles = True ,
147+ package_dir = "chatter" ,
148+ symlinks = {
149+ "/chatter/chatter.runfiles/_main/external" : "/chatter/chatter.runfiles" ,
150+ }
151+ )
152+
153+ # builds the oci image on top of the @rules_ros_base_image defined at the MODULE level.
154+ oci_image (
155+ name = "chatter_oci_image" ,
156+ base = "@rules_ros_base_image" ,
157+ tars = [":chatter_tar" ],
158+ workdir = "/chatter/chatter.runfiles/_main" ,
159+ entrypoint = ["/chatter/chatter" ],
160+ )
161+
162+ # loads the oci image into the docker daemon.
163+ # Example usage: `bazel run //chatter:chatter_oci_load`
164+ # Then to run the container: `docker run -it --rm chatter:latest`
165+ oci_load (
166+ name = "chatter_oci_load" ,
167+ image = ":chatter_oci_image" ,
168+ repo_tags = ["chatter:latest" ],
169+ )
0 commit comments