Refactor Dockerfiles (#6)

This commit is contained in:
Takashi Matsuo 2019-07-12 10:12:30 -07:00 committed by GitHub
parent aefb8c98b0
commit d6e90be651
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 109 additions and 85 deletions

View file

@ -1,81 +0,0 @@
# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
ARG DISTRO_VERSION=18.04
FROM ubuntu:${DISTRO_VERSION}
RUN apt update && \
apt install -y \
build-essential \
clang \
cmake \
curl \
doxygen \
gawk \
git \
gcc \
golang \
g++ \
libc-ares-dev \
libc-ares2 \
libssl-dev \
make \
ninja-build \
pkg-config \
python-pip \
shellcheck \
tar \
unzip \
wget \
zlib1g-dev
# Install newer c-ares on Ubuntu 16.04.
RUN if grep -q 16.04 /etc/lsb-release; then \
apt remove libc-ares-dev libc-ares2; \
apt install -y automake libtool; \
mkdir -p /var/tmp/Downloads; \
cd /var/tmp/Downloads; \
wget -q https://github.com/c-ares/c-ares/archive/cares-1_15_0.tar.gz; \
tar -xf cares-1_15_0.tar.gz; \
cd /var/tmp/Downloads/c-ares-cares-1_15_0; \
./buildconf && ./configure && make -j $(nproc); \
make install; \
ldconfig; \
fi
# By default, Ubuntu 18.04 does not install the alternatives for clang-format
# and clang-tidy, so we need to manually install those.
RUN if grep -q 18.04 /etc/lsb-release; then \
apt update && apt install -y clang-tidy clang-format-7; \
update-alternatives --install /usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-6.0 100; \
update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-7 100; \
fi
# Install the the buildifier tool, which does not compile with the default
# golang compiler for Ubuntu 16.04 and Ubuntu 18.04.
RUN wget -q -O /usr/bin/buildifier https://github.com/bazelbuild/buildtools/releases/download/0.17.2/buildifier
RUN chmod 755 /usr/bin/buildifier
# Install cmake_format to automatically format the CMake list files.
# https://github.com/cheshirekow/cmake_format
# Pin this to an specific version because the formatting changes when the
# "latest" version is updated, and we do not want the builds to break just
# because some third party changed something.
RUN pip install --upgrade pip
RUN pip install numpy cmake_format==0.5.2
# Install grpc from source
WORKDIR /var/tmp/ci
COPY install-grpc.sh /var/tmp/ci
RUN /var/tmp/ci/install-grpc.sh

View file

@ -0,0 +1,53 @@
# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
FROM ubuntu:16.04
RUN apt update && \
apt install -y \
automake \
build-essential \
clang \
cmake \
curl \
doxygen \
gawk \
git \
gcc \
golang \
g++ \
libssl-dev \
libtool \
make \
ninja-build \
pkg-config \
python-pip \
shellcheck \
tar \
unzip \
wget \
zlib1g-dev
WORKDIR /var/tmp/Downloads
RUN wget -q https://github.com/c-ares/c-ares/archive/cares-1_15_0.tar.gz && \
tar -xf cares-1_15_0.tar.gz && \
cd /var/tmp/Downloads/c-ares-cares-1_15_0 && \
./buildconf && ./configure && make -j $(nproc) && \
make install && \
ldconfig
# Install grpc from source
WORKDIR /var/tmp/ci
COPY install-grpc.sh /var/tmp/ci
RUN /var/tmp/ci/install-grpc.sh

View file

@ -0,0 +1,45 @@
# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
FROM ubuntu:18.04
RUN apt update && \
apt install -y \
build-essential \
clang \
cmake \
curl \
doxygen \
gawk \
git \
gcc \
golang \
g++ \
libc-ares-dev \
libc-ares2 \
libssl-dev \
make \
ninja-build \
pkg-config \
python-pip \
shellcheck \
tar \
unzip \
wget \
zlib1g-dev
# Install grpc from source
WORKDIR /var/tmp/ci
COPY install-grpc.sh /var/tmp/ci
RUN /var/tmp/ci/install-grpc.sh

View file

@ -23,6 +23,13 @@ fi
source "${PROJECT_ROOT}/ci/kokoro/define-docker-variables.sh" source "${PROJECT_ROOT}/ci/kokoro/define-docker-variables.sh"
cd "${PROJECT_ROOT}" cd "${PROJECT_ROOT}"
# If there's a version specific Dockerfile, we use it.
if [[ -f "ci/kokoro/Dockerfile.${DISTRO}-${DISTRO_VERSION}" ]]; then
sudo docker build -t "${IMAGE}:tip" \
-f "ci/kokoro/Dockerfile.${DISTRO}-${DISTRO_VERSION}" ci
else
sudo docker build -t "${IMAGE}:tip" \ sudo docker build -t "${IMAGE}:tip" \
--build-arg DISTRO_VERSION="${DISTRO_VERSION}" \ --build-arg DISTRO_VERSION="${DISTRO_VERSION}" \
-f "ci/kokoro/Dockerfile.${DISTRO}" ci -f "ci/kokoro/Dockerfile.${DISTRO}" ci
fi

View file

@ -47,7 +47,7 @@ fi
if [[ "${BUILD_NAME}" = "clang-tidy" ]]; then if [[ "${BUILD_NAME}" = "clang-tidy" ]]; then
# Compile with clang-tidy(1) turned on. The build treats clang-tidy warnings # Compile with clang-tidy(1) turned on. The build treats clang-tidy warnings
# as errors. # as errors.
export DISTRO=fedora-install export DISTRO=fedora
export DISTRO_VERSION=30 export DISTRO_VERSION=30
export CC=clang export CC=clang
export CXX=clang++ export CXX=clang++