GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — chore(hermetic-build): use secure base image hosted in docker.com by diegomarquezp · Pull Request #3324 · googleapis/sdk-platform-java

This repository was archived by the owner on Oct 29, 2026. It is now read-only.

Conversation

@diegomarquezp

@diegomarquezp diegomarquezp commented Oct 29, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

This PR switches the base images of all the Hermetic Build Docker image stages to publicly hosted docker images.

The chosen images are mirrored by Airlock or are at least in process of incorporation.

The choice of OS family is alpine for its security-oriented setup. 0 vulnerabilities were found in the public image scan reports (example).

Although several optimizations are possible (see #3196 and its intermediate commits), this PR is restricted to the minimal changes to have a secure base image.

Notes:

  • Since the UNIX tools are from FreeBSD, the -d flag in the rm command is not supported. This is why we removed its usage in the scripts
  • A few downstream checks are failing in other PRs as well. I raised ci: downstream checks are failing #3325 to track this.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
diegomarquezp added 3 commits October 29, 2024 19:17
@diegomarquezp
chore(hermetic-build): use secure base image hosted in docker.com
89bd3c5
@diegomarquezp
update rm to use FreeBSD flags
b1e61eb
@diegomarquezp
fix comment
10b176b
@product-auto-label product-auto-label Bot added the size: m Pull request size is medium. label Oct 29, 2024
@diegomarquezp diegomarquezp mentioned this pull request Oct 29, 2024
ci: downstream checks are failing #3325
Closed
@diegomarquezp
diegomarquezp marked this pull request as ready for review October 29, 2024 19:54
@diegomarquezp
diegomarquezp requested review from JoeWang1127 and blakeli0 October 29, 2024 19:54
blakeli0
blakeli0 reviewed Oct 29, 2024
View reviewed changes
Comment thread .cloudbuild/library_generation/library_generation.Dockerfile

# install gapic-generator-java in a separate layer so we don't overload the image
# with the transferred source code and jars
FROM gcr.io/cloud-devrel-public-resources/java21@sha256:2ceff5eeea72260258df56d42e44ed413e52ee421c1b77393c5f2c9c4d7c41da AS ggj-build

@blakeli0 blakeli0 Oct 29, 2024

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is gcr.io/cloud-devrel-public-resources/java21 coming from? Basically I'm trying to understand what is the base image for it eventually.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@diegomarquezp diegomarquezp Oct 29, 2024

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed it's based on eclipse-temurin-21

https://github.com/googleapis/testing-infra-docker/blob/main/java/java21/Dockerfile#L15

https://github.com/googleapis/testing-infra-docker/blob/main/java/cloudbuild.yaml#L163

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

blakeli0 reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
Comment thread .cloudbuild/library_generation/library_generation.Dockerfile Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread .cloudbuild/library_generation/library_generation.Dockerfile
WORKDIR /home

# Install compatibility layer to run glibc-based programs (such as the
# grpc plugin).

@blakeli0 blakeli0 Oct 29, 2024

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess protoc/gapic plugins as well?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@diegomarquezp diegomarquezp Oct 29, 2024

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

protoc can run without the compatibility layer. The java runtime is enabled via apk add, so the necessary shared objects (if any) will be brought by the package manager.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@diegomarquezp diegomarquezp Oct 29, 2024

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At least only the grpc plugin gave me trouble due to missing shared objects.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

blakeli0 reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
Comment thread .cloudbuild/library_generation/library_generation.Dockerfile
# downloadable distribution of the grpc plugin that is Alpine (musl) compatible.
# This is one of the recommended approaches to ensure glibc-compatibility
# as per https://wiki.alpinelinux.org/wiki/Running_glibc_programs
RUN git clone https://gitlab.com/manoel-linux1/GlibMus-HQ.git

@blakeli0 blakeli0 Oct 29, 2024

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where were these installed before? In one of the base images?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@diegomarquezp diegomarquezp Oct 29, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, most images come with binaries that were compiled with glibc. However Alpine is made with BusyBox + "musl libc", which cannot run certain linux binaries that were compiled with glibc (i.e. missing shared objects).

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

blakeli0 reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
Comment thread .cloudbuild/library_generation/library_generation.Dockerfile
RUN python -m pip install --require-hashes -r src/library_generation/requirements.txt
RUN python -m pip install src/library_generation

# Install nvm with node and npm

@blakeli0 blakeli0 Oct 29, 2024

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why Node is not needed anymore? I thought we still need it for running owlbot cli?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@diegomarquezp diegomarquezp Oct 29, 2024

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, that's because Alpine can install nodejs + npm via apk

sdk-platform-java/.cloudbuild/library_generation/library_generation.Dockerfile

Lines 65 to 66 in 10b176b

# install OS tools
RUN apk update && apk add unzip curl rsync maven jq bash nodejs npm git

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

blakeli0 reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
JoeWang1127
JoeWang1127 reviewed Oct 29, 2024
View reviewed changes
Comment thread .cloudbuild/library_generation/library_generation.Dockerfile Outdated

RUN mvn install -B -ntp -DskipTests -Dclirr.skip -Dcheckstyle.skip
RUN cp "/root/.m2/repository/com/google/api/gapic-generator-java/${DOCKER_GAPIC_GENERATOR_VERSION}/gapic-generator-java-${DOCKER_GAPIC_GENERATOR_VERSION}.jar" \
RUN --mount=type=cache,target=/root/.m2 mvn dependency:go-offline -B -ntp -DskipTests -Dclirr.skip -Dcheckstyle.skip

@JoeWang1127 JoeWang1127 Oct 29, 2024

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need mvn dependency?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@diegomarquezp diegomarquezp Oct 30, 2024

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't have any direct effect on the image but just to download the dependencies in a separate step. This is because we can leverage caching to prevent downloading the external dependencies every time we build the image.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

JoeWang1127 reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

@blakeli0 blakeli0 Oct 30, 2024

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How much time it would save by caching the external dependencies? In general, I think it's OK to always download it because we don't build image often. Caching is nice but sometimes we may run into issues where new dependencies are not downloaded.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@diegomarquezp diegomarquezp Oct 30, 2024

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We removed this just to have a consistent behavior in local and prod (thanks @blakeli0)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
JoeWang1127
JoeWang1127 reviewed Oct 29, 2024
View reviewed changes
Comment thread .cloudbuild/library_generation/library_generation.Dockerfile Outdated
RUN apt-get update && apt-get install -y \
unzip openjdk-17-jdk rsync maven jq \
&& apt-get clean
RUN apk update && apk add unzip curl rsync maven jq bash nodejs npm git

@JoeWang1127 JoeWang1127 Oct 29, 2024

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need maven in the final image?

As for java formatter, we've changed to download the jar so Java runtime is suffice.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@diegomarquezp diegomarquezp Oct 30, 2024

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is because there is no candidate in APK to download the runtime directly (apk list jdk). I'll double check this.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@diegomarquezp diegomarquezp Oct 30, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, well, apk list doesn't support partial string matches. I found openjdk11 by searching that exact string. Thanks for checking on this.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@googleapis googleapis deleted a comment from JoeWang1127 Oct 30, 2024
@diegomarquezp
use openjdk directly
82c26d5
JoeWang1127
JoeWang1127 approved these changes Oct 30, 2024
View reviewed changes
@diegomarquezp
remove local caching
c277353
@sonarqubecloud

sonarqubecloud Bot commented Oct 30, 2024

Copy link
Copy Markdown

Quality Gate Passed Quality Gate passed for 'gapic-generator-java-root'

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarCloud

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@sonarqubecloud

sonarqubecloud Bot commented Oct 30, 2024

Copy link
Copy Markdown

Quality Gate Passed Quality Gate passed for 'java_showcase_integration_tests'

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarCloud

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

blakeli0
blakeli0 approved these changes Oct 30, 2024
View reviewed changes
@diegomarquezp
diegomarquezp merged commit 7528039 into main Oct 30, 2024
@diegomarquezp
diegomarquezp deleted the secure-base-image--public-docker-repo branch October 30, 2024 19:38
@diegomarquezp diegomarquezp mentioned this pull request Apr 1, 2026
[sdk-platform-java] The Hermetic Build integration tests should be run in GCB googleapis/google-cloud-java#12422
Closed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

2 more reviewers
@blakeli0 blakeli0 blakeli0 approved these changes
@JoeWang1127 JoeWang1127 JoeWang1127 approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

size: m Pull request size is medium.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@diegomarquezp @blakeli0 @JoeWang1127
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.