| 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. |
| 16 |
FROM grpc/base |
| 17 |
|
| 18 |
# Add the file containing the gRPC version |
| 19 |
ADD version.txt version.txt |
| 20 |
|
| 21 |
# Install tools needed for building protoc. |
| 22 |
RUN apt-get update && apt-get -y install libgtest-dev |
| 23 |
|
| 24 |
# Get the protobuf source from GitHub. |
| 25 |
RUN mkdir -p /var/local/git |
| 26 |
RUN git clone https://github.com/protocolbuffers/protobuf.git /var/local/git/protobuf |
| 27 |
|
| 28 |
# Build the protobuf library statically and install to /tmp/protoc_static. |
| 29 |
WORKDIR /var/local/git/protobuf |
| 30 |
RUN ./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. |
| 36 |
WORKDIR /var/local/git/protobuf |
| 37 |
RUN ./autogen.sh && \ |
| 38 |
./configure --prefix=/usr/local && \ |
| 39 |
make -j12 && make check && make install |
| 40 |
|
| 41 |
# Build the grpc plugins. |
| 42 |
RUN git clone https://github.com/google/grpc.git /var/local/git/grpc |
| 43 |
WORKDIR /var/local/git/grpc |
| 44 |
RUN LDFLAGS=-static make plugins |
| 45 |
|
| 46 |
# Create an archive containing all the generated binaries. |
| 47 |
RUN mkdir /tmp/proto-bins_$(cat /version.txt)_linux-$(uname -m) |
| 48 |
RUN cp -v bins/opt/* /tmp/proto-bins_$(cat /version.txt)_linux-$(uname -m) |
| 49 |
RUN cp -v /tmp/protoc_static/bin/protoc /tmp/proto-bins_$(cat /version.txt)_linux-$(uname -m) |
| 50 |
RUN 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. |
| 55 |
RUN 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 |
|