1# Copyright 2015 gRPC authors. 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14 15# Dockerfile to build protoc and plugins for inclusion in a release. 16FROM grpc/base 17 18# Add the file containing the gRPC version 19ADD version.txt version.txt 20 21# Install tools needed for building protoc. 22RUN apt-get update && apt-get -y install libgflags-dev libgtest-dev 23 24# Get the protobuf source from GitHub. 25RUN mkdir -p /var/local/git 26RUN git clone https://github.com/google/protobuf.git /var/local/git/protobuf 27 28# Build the protobuf library statically and install to /tmp/protoc_static. 29WORKDIR /var/local/git/protobuf 30RUN ./autogen.sh && \ 31 ./configure --disable-shared --prefix=/tmp/protoc_static \ 32 LDFLAGS="-lgcc_eh -static-libgcc -static-libstdc++" && \ 33 make -j12 && make check && make install 34 35# Build the protobuf library dynamically and install to /usr/local. 36WORKDIR /var/local/git/protobuf 37RUN ./autogen.sh && \ 38 ./configure --prefix=/usr/local && \ 39 make -j12 && make check && make install 40 41# Build the grpc plugins. 42RUN git clone https://github.com/google/grpc.git /var/local/git/grpc 43WORKDIR /var/local/git/grpc 44RUN LDFLAGS=-static make plugins 45 46# Create an archive containing all the generated binaries. 47RUN mkdir /tmp/proto-bins_$(cat /version.txt)_linux-$(uname -m) 48RUN cp -v bins/opt/* /tmp/proto-bins_$(cat /version.txt)_linux-$(uname -m) 49RUN cp -v /tmp/protoc_static/bin/protoc /tmp/proto-bins_$(cat /version.txt)_linux-$(uname -m) 50RUN cd /tmp && \ 51 tar -czf proto-bins_$(cat /version.txt)_linux-$(uname -m).tar.gz proto-bins_$(cat /version.txt)_linux-$(uname -m) 52 53# List the tar contents: provides a way to visually confirm that the contents 54# are correct. 55RUN echo 'proto-bins_$(cat /version.txt)_linux-tar-$(uname -m) contents:' && \ 56 tar -ztf /tmp/proto-bins_$(cat /version.txt)_linux-$(uname -m).tar.gz 57 58 59 60 61 62