Skip to content

Commit

Permalink
feat(docker): Add Buildozer to the Docker image
Browse files Browse the repository at this point in the history
Buildozer is a command line tool that allows to rewrite multiple Bazel
BUILD files using standard commands. ORT is going to use it to extract
additional information from Bazel build files that is not available in the
lock file. See [1].

[1]: https://github.com/bazelbuild/buildtools/blob/main/buildozer/README.md#buildozer

Signed-off-by: Nicolas Nobelis <nicolas.nobelis@bosch.com>
  • Loading branch information
nnobelis authored and sschuberth committed Aug 19, 2024
1 parent fb36bec commit a53082f
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,7 @@ FROM base as bazelbuild
ARG BAZELISK_VERSION

ENV BAZEL_HOME=/opt/bazel
ENV GOBIN=/opt/go/bin

RUN mkdir -p $BAZEL_HOME/bin \
&& if [ "$(arch)" = "aarch64" ]; then \
Expand All @@ -416,8 +417,13 @@ RUN mkdir -p $BAZEL_HOME/bin \
fi \
&& chmod a+x $BAZEL_HOME/bin/bazel

COPY --from=gobuild /opt/go /opt/go

RUN $GOBIN/go install github.com/bazelbuild/buildtools/buildozer@latest && chmod a+x $GOBIN/buildozer

FROM scratch as bazel
COPY --from=bazelbuild /opt/bazel /opt/bazel
COPY --from=bazelbuild /opt/go/bin/buildozer /opt/go/bin/buildozer

#------------------------------------------------------------------------
# ORT
Expand Down Expand Up @@ -576,6 +582,7 @@ ENV BAZEL_HOME=/opt/bazel
ENV PATH=$PATH:$BAZEL_HOME/bin

COPY --from=bazel $BAZEL_HOME $BAZEL_HOME
COPY --from=bazel --chown=$USER:$USER /opt/go/bin/buildozer /opt/go/bin/buildozer

RUN syft $BAZEL_HOME -o spdx-json --output json=/usr/share/doc/ort/ort-bazel.spdx.json

Expand Down

0 comments on commit a53082f

Please sign in to comment.