|
16 | 16 |
|
17 | 17 | # build from the root of this repo:
|
18 | 18 | # docker build -t gcr.io/repo-automation-bots/owlbot-nodejs-mono-repo -f docker/owlbot/nodejs_mono_repo/Dockerfile .
|
19 |
| -FROM python:3.10.12-bookworm |
| 19 | +FROM marketplace.gcr.io/google/debian12:latest |
20 | 20 |
|
21 | 21 | WORKDIR /
|
22 | 22 |
|
23 |
| -###################### Install nodejs. |
24 |
| -RUN curl https://nodejs.org/dist/v18.17.0/node-v18.17.0-linux-x64.tar.xz > /tmp/nodejs.tar.xz |
25 |
| -RUN tar -C /usr/local --strip-components=1 -xJf /tmp/nodejs.tar.xz |
26 |
| -RUN rm -f /tmp/nodejs.tar.xz |
27 |
| -ENV PATH "$PATH:/usr/local/bin" |
| 23 | +## Install Essential Tools, Python 3.11, and xz-utils |
28 | 24 |
|
29 |
| -###################### Install git and update image to latest. |
30 |
| -RUN apt-get update && apt-get install -y git && apt-get upgrade -y |
| 25 | +# Update apt and install core tools. |
| 26 | +# This includes git, curl, and 'xz-utils' (needed for Node.js tarball decompression). |
| 27 | +# python3, python3-pip, and python3-venv are installed to provide Python 3.11 and |
| 28 | +# the tools for creating virtual environments. |
| 29 | +RUN apt-get update && \ |
| 30 | + apt-get install -y --no-install-recommends \ |
| 31 | + ca-certificates \ |
| 32 | + git \ |
| 33 | + curl \ |
| 34 | + xz-utils \ |
| 35 | + python3 \ |
| 36 | + python3-pip \ |
| 37 | + python3-venv && \ |
| 38 | + rm -rf /var/lib/apt/lists/* |
31 | 39 |
|
32 |
| -###################### Install synthtool's requirements. |
| 40 | +# Verify Python installation and ensure pip is available. |
| 41 | +# 'python3' command will now point to Python 3.11. |
| 42 | +RUN python3 --version |
| 43 | +RUN python3 -m pip --version |
| 44 | + |
| 45 | +## Install Node.js from apt-get |
| 46 | + |
| 47 | +# Add NodeSource APT repository for Node.js v18 |
| 48 | +RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash - && \ |
| 49 | + apt-get install -y nodejs && \ |
| 50 | + rm -rf /var/lib/apt/lists/* |
| 51 | + |
| 52 | +# Verify Node.js and npm installations |
| 53 | +RUN node --version |
| 54 | +RUN npm --version |
| 55 | + |
| 56 | +## Install Synthtool and Dependencies |
| 57 | + |
| 58 | +# Create a Python virtual environment for synthtool's dependencies. |
| 59 | +# This isolates your Python packages from the system Python, preventing conflicts. |
| 60 | +ENV VIRTUAL_ENV=/opt/venv/synthtool |
| 61 | +RUN python3 -m venv $VIRTUAL_ENV |
| 62 | +# Add the virtual environment's bin directory to the PATH. This effectively "activates" |
| 63 | +# the venv for all subsequent commands in this and future RUN layers. |
| 64 | +ENV PATH="$VIRTUAL_ENV/bin:$PATH" |
| 65 | + |
| 66 | +# Copy requirements.txt and install Python dependencies into the virtual environment. |
| 67 | +# Since we're in the venv, 'pip' directly refers to the venv's pip. |
33 | 68 | COPY requirements.txt /synthtool/requirements.txt
|
34 | 69 | RUN pip install --require-hashes -r /synthtool/requirements.txt
|
35 | 70 |
|
36 |
| -# Put synthtool in the PYTHONPATH so owlbot.py scripts will find it. |
37 |
| -ENV PYTHONPATH="/synthtool" |
| 71 | +# Set PYTHONPATH to ensure synthtool can be found by Python scripts. |
| 72 | +# Include the virtual environment's site-packages for completeness. |
| 73 | +ENV PYTHONPATH="/synthtool:$VIRTUAL_ENV/lib/python3.11/site-packages" |
38 | 74 |
|
39 |
| -# Tell synthtool to pull templates from this docker image instead of from |
40 |
| -# the live repo. |
| 75 | +# Configure synthtool to use templates from this image. |
41 | 76 | ENV SYNTHTOOL_TEMPLATES="/synthtool/synthtool/gcp/templates"
|
42 | 77 |
|
43 |
| -# Copy synthtool. |
| 78 | +# Copy synthtool source code and associated Docker files. |
44 | 79 | COPY synthtool /synthtool/synthtool
|
45 | 80 | COPY docker /synthtool/docker
|
46 | 81 | COPY post-processor-changes.txt /post-processor-changes.txt
|
47 | 82 |
|
48 |
| -# Update permissions so non-root users won't see errors. |
49 |
| -RUN find /synthtool -exec chmod a+r {} \; |
50 |
| -RUN find /synthtool -type d -exec chmod a+x {} \; |
| 83 | +# Update file permissions to prevent errors for non-root users. |
| 84 | +RUN find /synthtool -exec chmod a+r {} \; && \ |
| 85 | + find /synthtool -type d -exec chmod a+x {} \; |
51 | 86 |
|
52 |
| -# Install dependencies used for post processing: |
53 |
| -# * gts/typescript are used for linting. |
54 |
| -# * google-gax and gapic-tools are used for compiling protos. |
55 |
| -RUN cd /synthtool && mkdir node_modules && npm i [email protected] [email protected] \ |
56 |
| - |
| 87 | +# Install Node.js dependencies for post-processing. |
| 88 | +RUN cd /synthtool && mkdir node_modules && npm i [email protected] [email protected] \ |
| 89 | + |
57 | 90 |
|
58 | 91 | ENTRYPOINT [ "/bin/bash", "/synthtool/docker/owlbot/nodejs_mono_repo/entrypoint.sh" ]
|
0 commit comments