[JAVA] Build bazel with alpine

background

Docker image for compilation

There was a git repository compiled with ./compile.sh, so I borrowed and excerpted a part for reference dockerfile.

bazel-build


FROM python:3.8-alpine3.11

ARG bazel_ver=3.1.0
ENV JAVA_HOME=/usr/lib/jvm/default-jvm \
    PATH="$JAVA_HOME/bin:${PATH}" \
    BAZEL_VERSION=3.1.0

RUN apk add --virtual .bazel_build --no-cache g++ gcc \
  bash zip unzip cmake make linux-headers openjdk8 && \
  wget -q "https://github.com/bazelbuild/bazel/releases/download/${BAZEL_VERSION}/bazel-${BAZEL_VERSION}-dist.zip" \
  -O bazel.zip && \
  mkdir "bazel-${BAZEL_VERSION}" && \
  unzip -qd "bazel-${BAZEL_VERSION}" bazel.zip && \
  rm bazel.zip && \
  cd "bazel-${BAZEL_VERSION}" && \
  sed -i -e 's/-classpath/-J-Xmx6096m -J-Xms128m -classpath/g' \
  scripts/bootstrap/compile.sh && \
  EXTRA_BAZEL_ARGS=--host_javabase=@local_jdk//:jdk ./compile.sh && \
  cp -p output/bazel /usr/bin/ && \
  cd ../ && rm -rf "bazel-${BAZEL_VERSION}" && \
  bazel version && \
  apk del --purge .bazel_build

All you have to do is docker build and push

important point

  1. When compiling from source, openjdk8 is not supported because it does not support openjdk11.

  2. The part replaced with sed specifies the size of Java heap memory. If not specified, the memory may be exhausted and the memory may drop on the way.

The system is out of resources.
Consult the following stack trace for details.
java.lang.OutOfMemoryError: Java heap space

References

Recommended Posts

Build bazel with alpine
Build Doma1 with Ant
Build Growai with Centos7
Build Java with Wercker
Build GitLab / Mattermost with DockerForWindows
Build softether VPN with Centos7.
Build docker environment with WSL
Build Ubuntu 18.04.5 with dual boot
[Introduction] Build MVC with Scala
Build DynamoDB local with Docker
Build Couchbase local environment with Docker
Build a Java project with Gradle
Build a Node.js environment with Docker
Build a Tomcat 8.5 environment with Pleiades 4.8
Build PlantUML environment with VSCode + Docker
Build environment with vue.js + rails + docker
Build Rails environment with Docker Compose
Build a web application with Javalin
How to use mssql-tools with alpine
Java build with mac vs code
Build jooby development environment with Eclipse
Build docker + laravel environment with laradock
Build WebRTC Janus with Docker container
Spring Boot gradle build with Docker
Build a PureScript development environment with Docker
Build and manage RStudio environment with Docker-compose
Build REST API with Apache2 + Passenger + Sinatra.
Build DNS server with CentOS8 and bind
De-cron! Build a job scheduler with Rundeck
CICS-Run Java applications-(2) Build management with Maven
Build OpenCV with Java Wrapper on Ubuntu 18.04
[Docker] Build Jupyter Lab execution environment with Docker
Build an environment with Docker on AWS
Build TensorFlow operation check environment with Docker
Use ZStandard with .NET Core + Docker (Alpine)
How to build Rails 6 environment with Docker