Combine Dockerfiles (existing and examples)

This commit is contained in:
Stanley Cheung 2018-02-22 01:47:07 -08:00
parent 6aaaad5604
commit ef7f640f4e
4 changed files with 191 additions and 59 deletions

View File

@ -1,58 +0,0 @@
# BUILD:
# docker build \
# -t grpc-web \
# -f ~/github-pr/grpc-web/net/grpc/gateway/docker/container_build/Dockerfile .
#
# RUN:
# start the container:
# $ docker run -itp 8080:8080 -p 9091:9091 --name grpc-web grpc-web /bin/bash
# $ cd /grpc-web/gConnector && ./nginx.sh
#
# start the grpc server:
# docker exec -it grpc-web /grpc-web/net/grpc/gateway/examples/echo/echo_server
#
# Once the nginx server and the echo server are both running in different terminals, you
# can point a web browser to
# http://localhost:8080/net/grpc/gateway/examples/echo/echotest.html
FROM ubuntu:latest as install
COPY ./ /grpc-web
RUN apt-get update && apt-get install -y \
autoconf \
automake \
build-essential \
curl \
git \
default-jdk \
default-jre \
libtool \
libpcre3 \
libpcre3-dev \
libssl-dev \
make \
python-software-properties \
software-properties-common \
zip
# Stage 2 init git submodules
RUN cd /grpc-web && \
./scripts/init_submodules.sh
# Stage 3 build the libraries
RUN cd /grpc-web/third_party/grpc/third_party/protobuf && \
./autogen.sh && ./configure && make && make install
RUN cd /grpc-web/third_party/grpc && \
ldconfig && \
EMBED_OPENSSL=false make && \
EMBED_OPENSSL=false make install
# Stage 4: closure compiler and build example
RUN cd /grpc-web && \
curl http://dl.google.com/closure-compiler/compiler-latest.zip -o compiler-latest.zip && \
unzip -p -qq -o compiler-latest.zip *.jar > closure-compiler.jar && \
make example && \
make install-example

View File

@ -1,4 +1,59 @@
# Copyright 2018 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
#
# https://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.
# BUILD
#
# Option 1: Only the Nginx gateway
#
# $ docker build \
# -t grpc-web \
# -f ~/grpc-web/net/grpc/gateway/docker/ubuntu_14_04/Dockerfile .
#
# Option 2: With end-to-end example
#
# $ docker build \
# -t grpc-web \
# --build-arg build_examples=true \
# -f ~/grpc-web/net/grpc/gateway/docker/ubuntu_14_04/Dockerfile .
#
# RUN
#
# 1. Nginx gateway:
#
# $ docker run -itp 8080:8080 -p 9091:9091 --name grpc-web grpc-web /bin/bash
# $ cd /github/grpc-web/gConnector && ./nginx.sh
#
# 2. Backend gRPC server:
# (if you had built the end-to-end example with Option 2 in the BUILD section)
#
# $ docker exec -it grpc-web \
# /github/grpc-web/net/grpc/gateway/examples/echo/echo_server
#
# 3. Browser example:
# (if you had built the end-to-end example with Option 2 in the BUILD section)
#
# Once the Nginx gateway and the Echo server are both running in different
# terminals, you can point a web browser to
#
# http://localhost:8080/net/grpc/gateway/examples/echo/echotest.html
FROM ubuntu:14.04
ARG build_examples=false
ENV build_examples $build_examples
ENV EMBED_OPENSSL false
RUN apt-get update && apt-get install -y \
autoconf \
automake \
@ -13,8 +68,22 @@ RUN apt-get update && apt-get install -y \
python-software-properties \
software-properties-common \
zip
RUN add-apt-repository ppa:openjdk-r/ppa && \
apt-get update && apt-get install -y \
openjdk-8-jdk \
openjdk-8-jre
COPY . /github/grpc-web
RUN cd /github/grpc-web && \
./scripts/init_submodules.sh
RUN cd /github/grpc-web/third_party/grpc && \
make
make && make install && ldconfig
RUN cd /github/grpc-web && \
make
RUN cd /github/grpc-web/ && \
./scripts/build_examples.sh

View File

@ -0,0 +1,87 @@
# Copyright 2018 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
#
# https://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.
# BUILD
#
# Option 1: Only the Nginx gateway
#
# $ docker build \
# -t grpc-web \
# -f ~/grpc-web/net/grpc/gateway/docker/ubuntu_16_04/Dockerfile .
#
# Option 2: With end-to-end example
#
# $ docker build \
# -t grpc-web \
# --build-arg build_examples=true \
# -f ~/grpc-web/net/grpc/gateway/docker/ubuntu_16_04/Dockerfile .
#
# RUN
#
# 1. Nginx gateway:
#
# $ docker run -itp 8080:8080 -p 9091:9091 --name grpc-web grpc-web /bin/bash
# $ cd /github/grpc-web/gConnector && ./nginx.sh
#
# 2. Backend gRPC server:
# (if you had built the end-to-end example with Option 2 in the BUILD section)
#
# $ docker exec -it grpc-web \
# /github/grpc-web/net/grpc/gateway/examples/echo/echo_server
#
# 3. Browser example:
# (if you had built the end-to-end example with Option 2 in the BUILD section)
#
# Once the Nginx gateway and the Echo server are both running in different
# terminals, you can point a web browser to
#
# http://localhost:8080/net/grpc/gateway/examples/echo/echotest.html
FROM ubuntu:16.04
ARG build_examples=false
ENV build_examples $build_examples
ENV EMBED_OPENSSL false
RUN apt-get update && apt-get install -y \
autoconf \
automake \
build-essential \
curl \
git \
default-jdk \
default-jre \
libtool \
libpcre3 \
libpcre3-dev \
libssl-dev \
make \
python-software-properties \
software-properties-common \
zip
COPY . /github/grpc-web
RUN cd /github/grpc-web && \
./scripts/init_submodules.sh
RUN cd /github/grpc-web/third_party/grpc && \
make && make install && ldconfig
RUN cd /github/grpc-web && \
make
RUN cd /github/grpc-web/ && \
./scripts/build_examples.sh

34
scripts/build_examples.sh Executable file
View File

@ -0,0 +1,34 @@
#!/bin/bash
# Copyright 2018 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
#
# https://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.
cd "$(dirname "$0")"
pwd=$(pwd)
# This environment variable is being set by the Dockerfile
if [[ "$build_examples" = false ]]; then
exit 0;
fi
# Install Protobuf
cd "$pwd"/../third_party/grpc/third_party/protobuf && \
./autogen.sh && ./configure && make && make install && ldconfig
# Download closure-compiler.jar and build the example
cd "$pwd"/../ && \
curl http://dl.google.com/closure-compiler/compiler-latest.zip \
-o compiler-latest.zip && \
unzip -p -qq -o compiler-latest.zip *.jar > closure-compiler.jar && \
make example && \
make install-example