Skip to content

Commit dd96066

Browse files
fixed protoc-plugin build failure (#1483)
* fixed protoc-plugin build failure * fixed protoc-plugin build failure and docker compose build. --------- Co-authored-by: Stanley Cheung <[email protected]>
1 parent 70f2b59 commit dd96066

File tree

3 files changed

+54
-31
lines changed

3 files changed

+54
-31
lines changed

net/grpc/gateway/docker/prereqs/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ RUN git clone https://github.com/grpc/grpc-web .
4545
COPY ./scripts/init_submodules.sh ./scripts/
4646
RUN ./scripts/init_submodules.sh
4747

48+
# Add this to ensure abseil-cpp is available
49+
RUN git clone --depth 1 https://github.com/abseil/abseil-cpp.git third_party/abseil-cpp
4850

4951
######################################
5052
# Stage 2: Copy source files and build

net/grpc/gateway/docker/protoc_plugin/Dockerfile

Lines changed: 40 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,26 +15,48 @@
1515
FROM grpcweb/prereqs
1616

1717
ARG MAKEFLAGS=-j8
18+
ARG PROTOBUF_VERSION=v27.1
1819

19-
RUN apt-get -qq update && apt-get -qq install -y \
20-
autoconf \
21-
automake \
22-
build-essential \
23-
curl \
24-
git \
25-
libtool \
26-
libssl-dev \
27-
make \
28-
zip
20+
# Install required build tools and libraries
21+
RUN apt-get update && apt-get install -y \
22+
cmake ninja-build \
23+
pkg-config zlib1g-dev \
24+
libtool autoconf automake \
25+
curl unzip git build-essential && \
26+
rm -rf /var/lib/apt/lists/*
2927

28+
# Set working directory for build context
3029
WORKDIR /github/grpc-web
3130

32-
RUN cd ./third_party/protobuf && \
33-
./autogen.sh && \
34-
./configure && \
35-
make && \
36-
make install && \
37-
ldconfig
31+
# Copy full grpc-web source including third_party
32+
COPY . /github/grpc-web
3833

39-
RUN cd ./javascript/net/grpc/web/generator && \
40-
make protoc-gen-grpc-web
34+
# Clean existing Abseil install (if rebuilding)
35+
RUN rm -rf /usr/local/include/absl /usr/local/lib/libabsl*
36+
37+
# Build Abseil
38+
WORKDIR /github/grpc-web/third_party/abseil-cpp
39+
RUN cmake -S . -B cmake/build \
40+
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
41+
-DCMAKE_BUILD_TYPE=Release && \
42+
cmake --build cmake/build --target install
43+
44+
# Clone full Protobuf source manually (not shallow)
45+
WORKDIR /github/grpc-web/third_party
46+
RUN rm -rf protobuf && \
47+
git clone https://github.com/protocolbuffers/protobuf.git && \
48+
cd protobuf && \
49+
git checkout ${PROTOBUF_VERSION} && \
50+
git submodule update --init --recursive
51+
52+
# Build and install Protobuf using CMake
53+
WORKDIR /github/grpc-web/third_party/protobuf
54+
RUN cmake -S . -B build \
55+
-DCMAKE_BUILD_TYPE=Release \
56+
-Dprotobuf_BUILD_TESTS=OFF \
57+
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
58+
-DCMAKE_CXX_STANDARD=17 && \
59+
cmake --build build --target install
60+
61+
# Optional: Debug CMake errors (if build fails)
62+
# RUN cat build/CMakeFiles/CMakeError.log || true
Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,27 @@
11
FROM selenium/standalone-chrome:112.0.5615.165
22

3-
# Matching the node version used in the node:20.0.0-bullseye image.
43
ARG NODE_VERSION=20.0.0
5-
64
USER root
75

8-
RUN apt-get update && \
9-
apt-get install -y nodejs npm
6+
# Install Node.js dependencies
7+
RUN apt-get update && apt-get install -y nodejs npm curl
108

11-
# Install nvm (See https://github.com/creationix/nvm#install-script) and nodejs version per
12-
# specified in NODE_VERSION
9+
# Install nvm and set up Node.js
1310
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
1411
ENV NVM_DIR=$HOME/.nvm
15-
RUN . $NVM_DIR/nvm.sh \
16-
&& nvm install $NODE_VERSION \
17-
&& nvm alias default $NODE_VERSION \
18-
&& nvm use default
12+
RUN . $NVM_DIR/nvm.sh && \
13+
nvm install $NODE_VERSION && \
14+
nvm alias default $NODE_VERSION && \
15+
nvm use default
1916
ENV PATH $NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH
2017

2118
WORKDIR /grpc-web
2219

20+
# Copy all needed files before running npm install or compiler
2321
COPY ./packages ./packages
24-
RUN cd ./packages/grpc-web && \
25-
npm install
26-
2722
COPY ./javascript ./javascript
2823
COPY ./scripts ./scripts
24+
25+
# Install npm dependencies and build the JS library
26+
WORKDIR /grpc-web/packages/grpc-web
27+
RUN npm install

0 commit comments

Comments
 (0)