Dockerfile 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. # Dockerfile to build protoc and plugins for inclusion in a release.
  15. FROM grpc/base
  16. # Add the file containing the gRPC version
  17. ADD version.txt version.txt
  18. # Install tools needed for building protoc.
  19. RUN apt-get update && apt-get -y install libgtest-dev
  20. # Get the protobuf source from GitHub.
  21. RUN mkdir -p /var/local/git
  22. RUN git clone https://github.com/protocolbuffers/protobuf.git /var/local/git/protobuf
  23. # Build the protobuf library statically and install to /tmp/protoc_static.
  24. WORKDIR /var/local/git/protobuf
  25. RUN ./autogen.sh && \
  26. ./configure --disable-shared --prefix=/tmp/protoc_static \
  27. LDFLAGS="-lgcc_eh -static-libgcc -static-libstdc++" && \
  28. make -j12 && make check && make install
  29. # Build the protobuf library dynamically and install to /usr/local.
  30. WORKDIR /var/local/git/protobuf
  31. RUN ./autogen.sh && \
  32. ./configure --prefix=/usr/local && \
  33. make -j12 && make check && make install
  34. # Build the grpc plugins.
  35. RUN git clone https://github.com/google/grpc.git /var/local/git/grpc
  36. WORKDIR /var/local/git/grpc
  37. RUN LDFLAGS=-static make plugins
  38. # Create an archive containing all the generated binaries.
  39. RUN mkdir /tmp/proto-bins_$(cat /version.txt)_linux-$(uname -m)
  40. RUN cp -v bins/opt/* /tmp/proto-bins_$(cat /version.txt)_linux-$(uname -m)
  41. RUN cp -v /tmp/protoc_static/bin/protoc /tmp/proto-bins_$(cat /version.txt)_linux-$(uname -m)
  42. RUN cd /tmp && \
  43. tar -czf proto-bins_$(cat /version.txt)_linux-$(uname -m).tar.gz proto-bins_$(cat /version.txt)_linux-$(uname -m)
  44. # List the tar contents: provides a way to visually confirm that the contents
  45. # are correct.
  46. RUN echo 'proto-bins_$(cat /version.txt)_linux-tar-$(uname -m) contents:' && \
  47. tar -ztf /tmp/proto-bins_$(cat /version.txt)_linux-$(uname -m).tar.gz