Skip to content

[sdk-platform-java] Centralize implementation for library_generation.Dockerfile and its Airlock variant #12385

Open

Description

@diegomarquezp

We should probably have a way to share the common code between the two, or maybe only keep the airlock one if it can be used locally as well. Otherwise these two files can easily get diverged from each other as they evolve. This is a separate future enhancement though.

Originally posted by @blakeli0 in googleapis/sdk-platform-java#3726 (comment)

Activity

  1. added
    type: cleanupAn internal cleanup or hygiene concern.
    priority: p2Moderately-important priority. Fix may not be included in next release.
    on Apr 1, 2025
  2. diegomarquezp commented on Apr 1, 2025

    @diegomarquezp
    ContributorAuthor

    Dockerfiles don't provide ways to natively reuse instructions like RUN.

    I would lean towards a script using jinja2 and two JSONs containing the base image digests.

  3. blakeli0 commented on Jul 23, 2025

    @blakeli0
    Contributor

    Another solution is to remove the need of two docker files. If we can download the docker image from Airlock in local, then we don't need the one that download images from docker central.

  4. zhumin8 commented on Jul 24, 2025

    @zhumin8
    Contributor

    iiuc, the only difference between the 2 dockerfile is the base image? If so,

    can we explore using a build argument (ARG) to specify the base image at build time. Use the airlock variant Dockerfile for default base image, like

    # Default to one of your base images
    ARG BASE_IMAGE=base-image
    FROM ${BASE_IMAGE}
    
    # ... other common instructions ...
    RUN apt-get update && apt-get install -y ...
    COPY . /app
    ...
    

    We should be able to build passing a different value for BASE_IMAGE as needed:

    docker build --build-arg BASE_IMAGE=xxx -t local-test:latest .

  5. diegomarquezp commented on Jul 24, 2025

    @diegomarquezp
    ContributorAuthor

    Thanks @zhumin8 for the pointer.

    Yes, the docs say it's possible as long as the ARG is at the top of the Dockerfile

    https://docs.docker.com/reference/dockerfile/#understand-how-arg-and-from-interact

  6. diegomarquezp commented on Jul 24, 2025

    @diegomarquezp
    ContributorAuthor

    I'll add a POC

  7. diegomarquezp commented on Jul 29, 2025

    @diegomarquezp
    ContributorAuthor

    @zhumin8 @blakeli0 the POC works in googleapis/sdk-platform-java#3870. Thank you for the recommendation. We may want a more formal way of handling the common inputs in the GCB yamls, though.

  8. changed the title [-]Centralize implementation for `library_generation.Dockerfile` and its Airlock variant[/-] [+][sdk-platform-java] Centralize implementation for `library_generation.Dockerfile` and its Airlock variant[/+] on Apr 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority: p2Moderately-important priority. Fix may not be included in next release.type: cleanupAn internal cleanup or hygiene concern.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions