Bazel Docker Install Sqlite

May 4, 2021

Some time ago the bazel docker rules did not allow the use of RUN because of two main reasons:

  1. Virtually everything folks do in RUN isn’t reproducible.
  2. The way the Docker daemon evaluates RUN is never reproducible.

Fortunately that changed, now they provide rules not only to RUN (and create commits/layers) but also specific rules to download & install system packages.

Here an example on how to install sqlite into a ubuntu base image

download_pkgs(
    name = "sqlite_pkgs",
    image_tar = "@ubuntu1604//image",
    packages = [
        "libsqlite3-dev",
        "sqlite3",
    ],
)

install_pkgs(
    name = "sqlite_pkgs_image",
    image_tar = "@ubuntu1604//image",
    installables_tar = ":sqlite_pkgs.tar",
    installation_cleanup_commands = "rm -rf /var/lib/apt/lists/*",
    output_image_name = "sqlite_pkgs_image",
)

more examples:


Do you want to know something?→Click!