|
14 | 14 |
|
15 | 15 | # install gapic-generator-java in a separate layer so we don't overload the image |
16 | 16 | # with the transferred source code and jars |
17 | | -FROM gcr.io/cloud-devrel-public-resources/java21@sha256:2ceff5eeea72260258df56d42e44ed413e52ee421c1b77393c5f2c9c4d7c41da AS ggj-build |
| 17 | + |
| 18 | +# 3.9.9-eclipse-temurin-11-alpine |
| 19 | +FROM docker.io/library/maven@sha256:006d25558f9d5244ed55b5d2bd8eaf34d883e447d0c4b940e67b9f44d21167bf AS ggj-build |
18 | 20 |
|
19 | 21 | WORKDIR /sdk-platform-java |
20 | 22 | COPY . . |
21 | 23 | # {x-version-update-start:gapic-generator-java:current} |
22 | | -ENV DOCKER_GAPIC_GENERATOR_VERSION="2.49.1-SNAPSHOT" |
| 24 | +ENV DOCKER_GAPIC_GENERATOR_VERSION="2.49.1-SNAPSHOT" |
23 | 25 | # {x-version-update-end} |
24 | 26 |
|
25 | 27 | RUN mvn install -B -ntp -DskipTests -Dclirr.skip -Dcheckstyle.skip |
26 | 28 | RUN cp "/root/.m2/repository/com/google/api/gapic-generator-java/${DOCKER_GAPIC_GENERATOR_VERSION}/gapic-generator-java-${DOCKER_GAPIC_GENERATOR_VERSION}.jar" \ |
27 | 29 | "./gapic-generator-java.jar" |
28 | 30 |
|
29 | | -# build from the root of this repo: |
30 | | -FROM gcr.io/cloud-devrel-public-resources/python@sha256:9c5ea427632f195ad164054831968389d86fdde4a15abca651f3fcb2a71268cb |
| 31 | +# alpine:3.20.3 |
| 32 | +FROM docker.io/library/alpine@sha256:beefdbd8a1da6d2915566fde36db9db0b524eb737fc57cd1367effd16dc0d06d as glibc-compat |
| 33 | + |
| 34 | +RUN apk add git sudo |
| 35 | +# This SHA is the latest known-to-work version of this binary compatibility tool |
| 36 | +ARG GLIB_MUS_SHA=7717dd4dc26377dd9cedcc92b72ebf35f9e68a2d |
| 37 | +WORKDIR /home |
| 38 | + |
| 39 | +# Install compatibility layer to run glibc-based programs (such as the |
| 40 | +# grpc plugin). |
| 41 | +# Alpine, by default, only supports musl-based binaries, and there is no public |
| 42 | +# downloadable distribution of the grpc plugin that is Alpine (musl) compatible. |
| 43 | +# This is one of the recommended approaches to ensure glibc-compatibility |
| 44 | +# as per https://wiki.alpinelinux.org/wiki/Running_glibc_programs |
| 45 | +RUN git clone https://gitlab.com/manoel-linux1/GlibMus-HQ.git |
| 46 | +WORKDIR /home/GlibMus-HQ |
| 47 | +# We lock the tool to the latest known-to-work version |
| 48 | +RUN git checkout "${GLIB_MUS_SHA}" |
| 49 | +RUN chmod a+x compile-x86_64-alpine-linux.sh |
| 50 | +RUN sh compile-x86_64-alpine-linux.sh |
| 51 | + |
| 52 | +# python:3.12.7-alpine3.20 |
| 53 | +FROM docker.io/library/python@sha256:38e179a0f0436c97ecc76bcd378d7293ab3ee79e4b8c440fdc7113670cb6e204 as final |
31 | 54 |
|
32 | | -SHELL [ "/bin/bash", "-c" ] |
33 | 55 |
|
34 | 56 |
|
35 | 57 | ARG OWLBOT_CLI_COMMITTISH=38fe6f89a2339ee75c77739b31b371f601b01bb3 |
@@ -40,9 +62,24 @@ ENV HOME=/home |
40 | 62 | ENV OS_ARCHITECTURE="linux-x86_64" |
41 | 63 |
|
42 | 64 | # install OS tools |
43 | | -RUN apt-get update && apt-get install -y \ |
44 | | - unzip openjdk-17-jdk rsync maven jq \ |
45 | | - && apt-get clean |
| 65 | +RUN apk update && apk add unzip curl rsync openjdk11 jq bash nodejs npm git |
| 66 | + |
| 67 | +SHELL [ "/bin/bash", "-c" ] |
| 68 | + |
| 69 | +# Copy glibc shared objects to enable execution of the grpc plugin. |
| 70 | +# This list was obtained via `libtree -pvvv /grpc/*` in the final container as |
| 71 | +# well as inspecting the modifications done by compile-x86_64-alpine-linux.sh |
| 72 | +# in the glibc-compat stage using the `dive` command. |
| 73 | +COPY --from=glibc-compat /etc/libgcc* /etc/ |
| 74 | +COPY --from=glibc-compat /lib64/ld-linux-x86-64.so.2 /lib64/ |
| 75 | +COPY --from=glibc-compat /lib/GLIBCFAKE.so.0 /lib/ |
| 76 | +COPY --from=glibc-compat /lib/ld-linux-x86-64.so.2 /lib/ |
| 77 | +COPY --from=glibc-compat /lib/libpthread* /lib/ |
| 78 | +COPY --from=glibc-compat /lib/libucontext* /lib/ |
| 79 | +COPY --from=glibc-compat /lib/libc.* /lib/ |
| 80 | +COPY --from=glibc-compat /usr/lib/libgcc* /usr/lib/ |
| 81 | +COPY --from=glibc-compat /usr/lib/libstdc* /usr/lib/ |
| 82 | +COPY --from=glibc-compat /usr/lib/libobstack* /usr/lib/ |
46 | 83 |
|
47 | 84 | # copy source code |
48 | 85 | COPY hermetic_build/common /src/common |
@@ -72,10 +109,6 @@ ENV DOCKER_GRPC_VERSION="${GRPC_VERSION}" |
72 | 109 | COPY --from=ggj-build "/sdk-platform-java/gapic-generator-java.jar" "${HOME}/.library_generation/gapic-generator-java.jar" |
73 | 110 | RUN chmod 755 "${HOME}/.library_generation/gapic-generator-java.jar" |
74 | 111 |
|
75 | | -# use python 3.12 (the base image has several python versions; here we define the default one) |
76 | | -RUN rm $(which python3) |
77 | | -RUN ln -s $(which python3.12) /usr/local/bin/python |
78 | | -RUN ln -s $(which python3.12) /usr/local/bin/python3 |
79 | 112 | RUN python -m pip install --upgrade pip |
80 | 113 |
|
81 | 114 | # install main scripts as a python package |
@@ -85,25 +118,14 @@ RUN python -m pip install src/common |
85 | 118 | RUN python -m pip install --require-hashes -r src/library_generation/requirements.txt |
86 | 119 | RUN python -m pip install src/library_generation |
87 | 120 |
|
88 | | -# Install nvm with node and npm |
89 | | -ENV NODE_VERSION 20.12.0 |
90 | | -WORKDIR /home |
91 | | -RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash |
92 | | -RUN chmod o+rx /home/.nvm |
93 | | -ENV NODE_PATH=/home/.nvm/versions/node/v${NODE_VERSION}/bin |
94 | | -ENV PATH=${PATH}:${NODE_PATH} |
95 | | -RUN node --version |
96 | | -RUN npm --version |
97 | | - |
98 | 121 | # install the owl-bot CLI |
99 | 122 | WORKDIR /tools |
100 | 123 | RUN git clone https://github.com/googleapis/repo-automation-bots |
101 | 124 | WORKDIR /tools/repo-automation-bots/packages/owl-bot |
102 | 125 | RUN git checkout "${OWLBOT_CLI_COMMITTISH}" |
103 | 126 | RUN npm i && npm run compile && npm link |
104 | 127 | RUN owl-bot copy-code --version |
105 | | -RUN chmod -R o+rx ${NODE_PATH} |
106 | | -RUN ln -sf ${NODE_PATH}/* /usr/local/bin |
| 128 | +RUN chmod o+rx $(which owl-bot) |
107 | 129 |
|
108 | 130 | # download the Java formatter |
109 | 131 | ADD https://maven-central.storage-download.googleapis.com/maven2/com/google/googlejavaformat/google-java-format/${JAVA_FORMAT_VERSION}/google-java-format-${JAVA_FORMAT_VERSION}-all-deps.jar \ |
@@ -120,7 +142,6 @@ RUN git config --system user.name "Cloud Java Bot" |
120 | 142 |
|
121 | 143 | # allow read-write for /home and execution for binaries in /home/.nvm |
122 | 144 | RUN chmod -R a+rw /home |
123 | | -RUN chmod -R a+rx /home/.nvm |
124 | 145 |
|
125 | 146 | WORKDIR /workspace |
126 | 147 | ENTRYPOINT [ "python", "/src/library_generation/cli/entry_point.py", "generate" ] |