-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bazel on Alpine Linux #1492
Comments
I don't think anyone's tried it, but we'd love to hear how it goes. |
So I tried running it with this Dockerfile and get the below error. My best guess is that FROM alpine:3.4
RUN apk add --no-cache \
bash=4.3.42-r3 \
bash-completion=2.1-r2 \
ca-certificates=20160104-r4 \
g++=5.3.0-r0 \
openjdk8=8.92.14-r1 \
pkgconf=0.9.12-r0 \
unzip=6.0-r1 \
wget=1.17.1-r1 \
zip=3.0-r4 \
zlib-dev=1.2.8-r2
ENV JAVA_HOME /usr/lib/jvm/default-jvm
RUN wget -O bazel-installer.sh -q \
https://github.com/bazelbuild/bazel/releases/download/0.3.0/bazel-0.3.0-installer-linux-x86_64.sh \
&& bash bazel-installer.sh \
&& rm bazel-installer.sh bash-4.3$ bazel
/usr/local/bin/bazel: line 86: /usr/local/lib/bazel/bin/bazel-real: No such file or directory |
I did some digging into this today, specifically to see why bazel can't build under alpine, and I believe it's failing in the protoc step, because the grpc protoc plugin isn't statically compiled, so it's failing to find a shared object it needs. However I can't be sure, because it just dies instantly after printing "Building bazel from scratch." |
You can add set -x to compile.sh and it'll print each line as it executes. |
Yup, added that to compile.sh and can confirm it'e dying in the protoc step. Full log can be uploaded if wanted. |
Is there a way to ensure the shared object is in the Alpine container? |
On my glibc (Debian Jessie amd64 if anybody cares) system, <linux/unistd.h> is a strict subset of <sys/sycall.h>, which the file is already including. musl libc doesn't provide this file, and with this change all the C++ tests pass with musl libc. This came up in bazelbuild/bazel#1492.
I have no experience with Alpine Linux or Docker, but I thought this looked interesting and got it working. I think using the installer built for a different libc is pretty hopeless, but I did get building from scratch working with just a few tweaks. I assume you tried to compile an older Bazel version before 168031d, because I didn't see any issues with protoc shared libraries.
I've sent out a few fixes, and there's something else going on that I think is busybox I submitted grpc/grpc#7730 and I2bd5ec198522ea1ea19df0aaa1eb7c6977217eb3 to fix a few musl libc incompatibilities. |
Noticing that https://bazel-review.googlesource.com/#/q/I2bd5ec198522ea1ea19df0aaa1eb7c6977217eb3 never got merged, would love to see that land, support musl/libc would be great. |
@bsilver8192 How did you get |
I am trying to build bazel-4.3 on alpine-3.5. I am running into the following compile error I believe is connected to libc compatibility:
Any ideas? |
* JDK 8, Python 3.6-dev packages are readily available, but Google's Bazel seems not working on Alpine yet. ref) bazelbuild/bazel#1492 Let's come back after some time here.
It looks like mode_t is defined in a different header than on other systems. Maybe try grepping to find where mode_t is defined in /usr/include. third_party/ijar/platform_utils.cc is already including all of the places I'd expect to find it. Maybe sys/file.h? |
@r351574nc3 , you can see a workaround in this Dockerfile which builds Bazel and TF with |
It seems, that those workarounds are not needed any more. Here is the working Dockerfile that is building Bazel on Alpine Linux. Moreover, I'm looking in creating native bazel package for Alpine Linux, so that something like that:
just work. |
Thanks! This should mean lighter docker containers for all |
Native Bazel package for Alpine Linux is here. |
NICE!!
…On Wed, Nov 8, 2017 at 2:08 PM David Ostrovsky ***@***.***> wrote:
Moreover, I'm looking in creating native bazel package for Alpine Linux,
so that something like that:
Native Bazel package for Alpine Linux is here
<https://github.com/davido/bazel-alpine-package/blob/master/APKBUILD>.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#1492 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AABQdpi9JEVlBlXxjreV7659ebqSI4d5ks5s0iZfgaJpZM4JITQG>
.
|
Hello all, |
Sure, but why are you worried about this diff line: In the end users should be able to just say:
BTW, the Bazel 0.8.0 native package for Alpine Linux is here: https://github.com/davido/bazel-alpine-package/releases/tag/0.8.0. |
Closing since this is not really an issue anymore? |
[F.Y.I.] For those who're looking for the latest Bazel Alpine package (apk file like I do), check: https://github.com/davido/bazel-alpine-package/releases
[LOG] Alpine:latest(3.10.2) @ macOS$ # Host Env Infos
$ sw_vers
ProductName: Mac OS X
ProductVersion: 10.13.6
BuildVersion: 17G7024
$
$ docker version
Client: Docker Engine - Community
Version: 18.09.1
API version: 1.39
Go version: go1.10.6
Git commit: 4c52b90
Built: Wed Jan 9 19:33:12 2019
OS/Arch: darwin/amd64
Experimental: false
Server: Docker Engine - Community
Engine:
Version: 18.09.1
API version: 1.39 (minimum version 1.12)
Go version: go1.10.6
Git commit: 4c52b90
Built: Wed Jan 9 19:41:49 2019
OS/Arch: linux/amd64
Experimental: false
$
$ docker run --rm -it alpine:latest /bin/sh
/ #
/ # cat /etc/os-release
NAME="Alpine Linux"
ID=alpine
VERSION_ID=3.10.2
PRETTY_NAME="Alpine Linux v3.10"
HOME_URL="https://alpinelinux.org/"
BUG_REPORT_URL="https://bugs.alpinelinux.org/"
/ #
/ # # Install Bazel
/ # # See: https://github.com/davido/bazel-alpine-package
/ # apk --no-cache add ca-certificates wget
...
/ # wget -q -O /etc/apk/keys/david@ostrovsky.org-5a0369d6.rsa.pub \
> https://raw.githubusercontent.com/davido/bazel-alpine-package/master/david@ostrovsky.org-5a0369d6.rsa.pub
/ #
/ # wget https://github.com/davido/bazel-alpine-package/releases/download/0.26.1/bazel-0.26.1-r0.apk
...
/ #
/ # apk add bazel-0.26.1-r0.apk && rm bazel-0.26.1-r0.apk
...
/ #
/ # bazel version
Extracting Bazel installation...
WARNING: --batch mode is deprecated. Please instead explicitly shut down your Bazel server using the command "bazel shutdown".
Build label: 0.26.1- (@non-git)
Build target: bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Sat Jun 8 20:32:26 2019 (1560025946)
Build timestamp: 1560025946
Build timestamp as int: 1560025946
/ #
/ # # Build C++ sample
/ # # See: https://docs.bazel.build/versions/master/tutorial/cpp.html
/ #
/ # apk --no-cache add git g++
/ # git clone https://github.com/bazelbuild/examples/
...
/ # cd examples/cpp-tutorial/stage1
/ # bazel build //main:hello-world
INFO: Analyzed target //main:hello-world (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
Target //main:hello-world up-to-date:
bazel-bin/main/hello-world
INFO: Elapsed time: 0.450s, Critical Path: 0.32s
INFO: 1 process: 1 processwrapper-sandbox.
INFO: Build completed successfully, 2 total actions
/ #
/ # ./bazel-bin/main/hello-world
Hello world
Wed Sep 4 02:40:06 2019
/ #
/ # ldd ./bazel-bin/main/hello-world
/lib/ld-musl-x86_64.so.1 (0x7fc58ae7d000)
libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x7fc58ad23000)
libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x7fc58ad0f000)
libc.musl-x86_64.so.1 => /lib/ld-musl-x86_64.so.1 (0x7fc58ae7d000) |
Just to anyone landing here from Google Search, you can't add bazel like that anymore. |
The last month I was using bazel binary downloaded from releases and it worked in Alpine container. Now I'm getting weird errors:
|
@findmyname666 FYI: I'm new to docker, but I've got a RBE container image working with this
|
Thanks @yesudeep! I was able to use this to set up Bazel 6.0.0 on Alpine 3.17 for both amd64 and arm64 with a slightly more minimal Dockerfile as follows:
I noticed there are packages for Alpine edge testing, but 4.2.2 suffers from this bug which probably won't be fixed, and 5.3.2 is not available for aarch64, so building bazel from source using the above steps is the only way I know to be able to use it in QEMU. |
Hi @strophy, thank you for the instructions! I am trying to build bazel in alpine on arm64 and was wondering how long you build roughly takes. While i can get the container to build, it takes ages, while building bazel on the host machine (M2 Air) takes 3-4 minutes. |
Hi @mowoe actually I'm unable to reliably build Bazel 6 for ARM64 on Alpine either on native AWS Graviton 2 CPUs or an emulator running on my x86_64 laptop. The build hangs forever as described here: #17220 I ended up packaging bazel6 for alpine but was unable to release an ARM binary for this reason. You might be having more success due to using a different filesystem in the base OS? It's a complicated bug, beyond my understanding unfortunately. |
Thank you @strophy, I came across these glibc builds build for alpine, which unfourtunately do not include arm64 ones, however there is a fork which does (being behind 1 minor version). While certainly not optimal (you definetely notice the libc issues and i would not use it for production stuff), i got it to work in the end and for what im trying to do, it is working fine. Here is the Dockerfile: FROM python:3.10-alpine
RUN wget https://github.com/SatoshiPortal/alpine-pkg-glibc/releases/download/2.31-r0/glibc-bin-2.31-r0-aarch64.apk
RUN wget https://github.com/SatoshiPortal/alpine-pkg-glibc/releases/download/2.31-r0/glibc-2.31-r0-aarch64.apk
RUN apk add --force-overwrite --allow-untrusted glibc-2.31-r0-aarch64.apk
RUN apk add --force-overwrite --allow-untrusted glibc-bin-2.31-r0-aarch64.apk
RUN wget https://github.com/bazelbuild/bazel/releases/download/4.2.4/bazel-4.2.4-linux-arm64
RUN chmod +x ./bazel-4.2.4-linux-arm64
RUN apk add libstdc++6 libstdc++-dev libstdc++
CMD ["./bazel-4.2.4-linux-arm64","--version"] $ docker build . -t bazel-arm
$ docker run --rm bazel-arm
./bazel-4.2.4-linux-arm64: /usr/lib/libstdc++.so.6: no version information available (required by ./bazel-4.2.4-linux-arm64)
bazel 4.2.4
$ The error about libstdc++ is described here, i havent had time to really look into it, but as far as i can see, everything seems to work fine anyway. |
I've been thinking about developing with Bazel inside of docker containers so that way I can have sandboxing on Mac. Is it possible to use Bazel with Alpine Linux or is Ubuntu required?
The text was updated successfully, but these errors were encountered: