bazel(ci): Rework Dockerfile

This commit is contained in:
Corentin Le Molgat
2023-10-20 14:44:59 +02:00
parent 06738a693d
commit bbf8089f9e
7 changed files with 56 additions and 41 deletions

View File

@@ -6,18 +6,12 @@ ENV PATH=/usr/local/bin:$PATH
RUN apk add --no-cache git build-base linux-headers zlib-dev
RUN apk add --no-cache -X http://dl-cdn.alpinelinux.org/alpine/edge/testing bazel6
# Install OpenJDK17
# note: default-jvm will now point to java-17-openjdk
RUN apk add --no-cache openjdk17 --repository=http://dl-cdn.alpinelinux.org/alpine/edge/testing/
# Remove infinite loop since jre point to the current directory
# otherwise bazel issue an error and stop...
RUN rm /usr/lib/jvm/default-jvm/jre
ENV JAVA_HOME=/usr/lib/jvm/default-jvm
ENV PATH=$JAVA_HOME/bin:$PATH
# Install Python
RUN apk add --no-cache python3-dev py3-pip
RUN apk add --no-cache python3-dev py3-pip \
py3-setuptools py3-wheel
FROM env AS devel
WORKDIR /home/project
@@ -25,17 +19,23 @@ COPY . .
FROM devel AS build
RUN bazel version
# --javabase=@local_jdk_11//:jdk \
# --host_javabase=@local_jdk_11//:jdk \
# --javabase=@bazel_tools//tools/jdk:local_jdk11 \
# --host_javabase=@bazel_tools//tools/jdk:local_jdk11 \
RUN bazel build \
--host_javabase=@local_jdk//:jdk \
-c opt \
--action_env=BAZEL_CXXOPTS="-std=c++17" \
--java_language_version=11 \
--java_runtime_version=local_jdk11 \
--tool_java_runtime_version=local_jdk11 \
--subcommands=true \
ortools/... examples/...
//ortools/... //examples/...
FROM build AS test
RUN bazel test \
--host_javabase=@local_jdk//:jdk \
-c opt \
--action_env=BAZEL_CXXOPTS="-std=c++17" \
--test_output=errors \
ortools/... examples/...
//ortools/... //examples/...

View File

@@ -16,13 +16,11 @@ FROM devel AS build
RUN bazel version
RUN bazel build \
-c opt \
--action_env=BAZEL_CXXOPTS="-std=c++17" \
--subcommands=true \
ortools/... examples/...
//ortools/... //examples/...
FROM build AS test
RUN bazel test \
-c opt \
--action_env=BAZEL_CXXOPTS="-std=c++17" \
--test_output=errors \
ortools/... examples/...
//ortools/... //examples/...

View File

@@ -18,6 +18,12 @@ https://github.com/bazelbuild/bazelisk/releases/download/v1.17.0/bazelisk-linux-
&& chmod +x bazelisk-linux-amd64 \
&& mv bazelisk-linux-amd64 /usr/local/bin/bazel
# Install Java
RUN dnf -y update \
&& dnf -y install java-1.8.0-openjdk java-1.8.0-openjdk-devel maven \
&& dnf clean all \
&& rm -rf /var/cache/dnf
# Install Python
RUN dnf -y update \
&& dnf -y install python3.11-devel \
@@ -32,13 +38,11 @@ FROM devel AS build
RUN bazel version
RUN bazel build \
-c opt \
--action_env=BAZEL_CXXOPTS="-std=c++17" \
--subcommands=true \
ortools/... examples/...
//ortools/... //examples/...
FROM build AS test
RUN bazel test \
-c opt \
--action_env=BAZEL_CXXOPTS="-std=c++17" \
--test_output=errors \
ortools/... examples/...
//ortools/... //examples/...

View File

@@ -5,8 +5,6 @@ FROM debian:latest AS env
ENV PATH=/usr/local/bin:$PATH
RUN apt-get update -qq \
&& apt-get install -yq git wget curl libssl-dev build-essential \
&& apt-get install -yq python3-dev python3-pip \
&& apt-get install -yq default-jdk \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Install Bazel
@@ -17,6 +15,12 @@ RUN apt-get update -qq \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Install Java
RUN apt-get update -qq \
&& apt-get install -yq default-jdk \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Install Python
RUN apt-get update -qq \
&& apt-get install -yq python3-dev python3-pip python3-venv \
@@ -31,13 +35,11 @@ FROM devel AS build
RUN bazel version
RUN bazel build \
-c opt \
--action_env=BAZEL_CXXOPTS="-std=c++17" \
--subcommands=true \
ortools/... examples/...
//ortools/... //examples/...
FROM build AS test
RUN bazel test \
-c opt \
--action_env=BAZEL_CXXOPTS="-std=c++17" \
--test_output=errors \
ortools/... examples/...
//ortools/... //examples/...

View File

@@ -19,6 +19,12 @@ https://github.com/bazelbuild/bazelisk/releases/download/v1.17.0/bazelisk-linux-
&& chmod +x bazelisk-linux-amd64 \
&& mv bazelisk-linux-amd64 /usr/local/bin/bazel
# Install Java
RUN dnf -y update \
&& dnf -y install java-11-openjdk java-11-openjdk-devel maven \
&& dnf clean all
ENV JAVA_HOME=/usr/lib/jvm/java-openjdk
# Install Python
RUN dnf -y update \
&& dnf -y install python3 python3-devel python3-pip \
@@ -32,13 +38,11 @@ FROM devel AS build
RUN bazel version
RUN bazel build \
-c opt \
--action_env=BAZEL_CXXOPTS="-std=c++17" \
--subcommands=true \
ortools/... examples/...
//ortools/... //examples/...
FROM build AS test
RUN bazel test \
-c opt \
--action_env=BAZEL_CXXOPTS="-std=c++17" \
--test_output=errors \
ortools/... examples/...
//ortools/... //examples/...

View File

@@ -29,13 +29,11 @@ FROM devel AS build
RUN bazel6 version
RUN bazel6 build \
-c opt \
--action_env=BAZEL_CXXOPTS="-std=c++17" \
--subcommands=true \
ortools/... examples/...
//ortools/... //examples/...
FROM build AS test
RUN bazel6 test \
-c opt \
--action_env=BAZEL_CXXOPTS="-std=c++17" \
--test_output=errors \
ortools/... examples/...
//ortools/... //examples/...

View File

@@ -8,10 +8,9 @@ RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
# Install system build dependencies
RUN apt-get update -qq \
&& apt-get install -yq git wget curl libssl-dev build-essential \
&& apt-get install -yq python3-dev python3-pip \
&& apt-get install -yq default-jdk \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Install Bazel
RUN curl https://bazel.build/bazel-release.pub.gpg | apt-key add -
RUN echo "deb [arch=amd64] https://storage.googleapis.com/bazel-apt stable jdk1.8" | tee /etc/apt/sources.list.d/bazel.list
@@ -20,6 +19,18 @@ RUN apt-get update -qq \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Install Java
RUN apt-get update -qq \
&& apt-get install -yq default-jdk \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Install Python
RUN apt-get update -qq \
&& apt-get install -yq python3-dev python3-pip \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
FROM env AS devel
WORKDIR /home/project
COPY . .
@@ -28,13 +39,11 @@ FROM devel AS build
RUN bazel version
RUN bazel build \
-c opt \
--action_env=BAZEL_CXXOPTS="-std=c++17" \
--subcommands=true \
ortools/... examples/...
//ortools/... //examples/...
FROM build AS test
RUN bazel test \
-c opt \
--action_env=BAZEL_CXXOPTS="-std=c++17" \
--test_output=errors \
ortools/... examples/...
//ortools/... //examples/...