Skip to content

added docker example#42

Open
JohnRudolfLewis wants to merge 2 commits intomvukov:mainfrom
JohnRudolfLewis:docker-example
Open

added docker example#42
JohnRudolfLewis wants to merge 2 commits intomvukov:mainfrom
JohnRudolfLewis:docker-example

Conversation

@JohnRudolfLewis
Copy link

added example of packing up in to a docker container using rules_oci and rules_pkg

closes GH-10

@JohnRudolfLewis
Copy link
Author

@hofbi Ready for re-review

@JohnRudolfLewis
Copy link
Author

@mvukov Please review

Copy link
Owner

@mvukov mvukov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left a couple of comments, mostly about possible optimizations. Please review those and lemme know what you think.

Comment on lines +148 to +150
symlinks = {
"/chatter/chatter.runfiles/_main/external": "/chatter/chatter.runfiles",
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you specify the workdir down below, you shoudn't need this symlink. Please double-check.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without the symlink, an error occurs:

RLException: Invalid roslaunch XML syntax: [Errno 2] No such file or directory: 'external/rules_ros~/third_party/ros/roslaunch/roscore.xml'
The traceback for the exception was written to the log file

Something is expecting all the runfiles to be in an 'external' directory below the working directory.

)


# packages up the nodes, launch file, and all the other required runfiles.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rules_oci have a good example for to structure python apps, see https://github.com/aspect-build/bazel-examples/tree/main/oci_python_image, py_layer.bzl file in particular. Maybe not for this PR, but it's a nice optimization.

oci = use_extension("@rules_oci//oci:extensions.bzl", "oci")
oci.pull(
name = "rules_ros_base_image",
image = "python:3.10-bookworm",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO this is an overkill, as we need system python (-like app) to bootstrap the Bazel-managed Python. You could fetch https://raw.githubusercontent.com/buildbarn/bb-remote-execution/96c4fdce659fabfaba7ee2a60fd4e2ffab8352e2/cmd/fake_python/main.go with http_file, compile it using rules_go and inject it into the output image as e.g. /usr/bin/python3 (using ubuntu:22.04 image in this case should be sufficient).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps overkill.... but needing to replicate your suggestion in each and every repo feels way to repetitive. Could we bake this into rules_ros or better yet, rules_python?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not use ubuntu:22.04 as base image?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think ubuntu:22.04 includes a python.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really? I thought it comes with 3.10

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does not appear that the image does.

oci = use_extension("@rules_oci//oci:extensions.bzl", "oci")
oci.pull(
    name = "rules_ros_base_image",
    image = "ubuntu:22.04",
    platforms = ["linux/amd64"],
)
use_repo(oci, "rules_ros_base_image", "rules_ros_base_image_linux_amd64")
$ docker run -ti --rm chatter:latest
/usr/bin/env: 'python3': No such file or directory

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add back examples for archiving binaries and assembling Docker images

3 participants