Tutorial how to build a docker image with rules_conda and bazel #41
Replies: 3 comments 1 reply
-
I need to research further how to use Assuming that:
then you can use the following # Using debian, because I can't get it to work on Alpine, probably because of lack of glibc
FROM debian:bullseye-slim
# Install required packages
RUN apt-get update && \
apt-get install -y ca-certificates openssl gcc git python
# Get certificate from "releases.bazel.build"
RUN mkdir /usr/local/share/ca-certificates/extra && \
openssl s_client -showcerts -connect releases.bazel.build:443 </dev/null 2>/dev/null | openssl x509 -outform PEM > /usr/local/share/ca-certificates/extra/releases.bazel.crt && \
update-ca-certificates
WORKDIR /app/
COPY ./ ./
# A little trick here, mount cache from your machine and then copy it to some container directory
RUN --mount=type=cache,target=/root/.cache \
./bazelw build app && \
mkdir ./.cache/ && \
mv /root/.cache/bazel/ ./.cache/bazel/ && \
mv /root/.cache/bazelisk/ ./.cache/bazelisk/
# And then copy back to container cache
RUN mv ./.cache/bazel/ /root/.cache/bazel/ && \
mv ./.cache/bazelisk/ /root/.cache/bazelisk/
# Run directly from bazel-bin (not with bazel run) to get rid of Bazel messages
ENTRYPOINT [ "./bazel-bin/app/main" ] and the following
And then run: DOCKER_BUILDKIT=1 docker build -t rules_conda/example . && docker run -it rules_conda/example This way you can benefit from both |
Beta Was this translation helpful? Give feedback.
-
I think I figured it out with Let's assume you are in
./bazelw run --spawn_strategy=local app If you don't want to pass
docker run bazel/app:main |
Beta Was this translation helpful? Give feedback.
-
Thank you for putting together And thank you for taking the time to look into how It seems like a Docker ImageLayer is having trouble with getting the conda environement bin and is returning an I/O error:
I was hoping that the If this I/O issue turns out to be a snag on the Thanks again! Here is my setup:Tail of my
|
Beta Was this translation helpful? Give feedback.
-
Hi,
thank you for providing this nice rules! I am a newbie with bazel and would like to ask for help building a py3_image instead of a py_binary.
Thanks you!
Beta Was this translation helpful? Give feedback.
All reactions