Skip to content

Instantly share code, notes, and snippets.

@nij4t
Last active September 8, 2021 23:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nij4t/7e53f99d8d909baede3cd22123aa4f80 to your computer and use it in GitHub Desktop.
Save nij4t/7e53f99d8d909baede3cd22123aa4f80 to your computer and use it in GitHub Desktop.
Bazel Commands
# `services` is a directory with application services that are packages as docker containers.
# It has source codes as well as BUILD.bazel files that define container images for each service.
# We ask git to give us a list of changed files in services directory which is then piped into
# bazel query comand that will give you all container image targets that should be rebuild.
git diff --name-only services ${PREVIOUS_REVISION} | xargs -I{dep} bazel query 'kind("_app_layer", rdeps(//services, {dep}))'
# building changed packages
bazelisk build `git diff --name-only ${PREVIOUS_REVISION} | xargs -I{dep} -P8 bazelisk query 'rdeps(//..., {dep})' --output package`
# publishing docker container image with current revision
bazelisk run //fizzbuzz:publish --define VERSION=$(git rev-parse HEAD | head -c8) --define SERVICE=fizzbuzz
# publishing docker container image with git tag
bazelisk run //fizzbuzz:publish --define VERSION=$(git describe) --define SERVICE=fizzbuzz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment