Skip to content

Commit

Permalink
remove airlock registry for python
Browse files Browse the repository at this point in the history
  • Loading branch information
diegomarquezp committed Sep 17, 2024
1 parent 34835a5 commit a3490e2
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 54 deletions.

This file was deleted.

11 changes: 0 additions & 11 deletions .cloudbuild/library_generation/image-configuration/airlock-pypirc

This file was deleted.

29 changes: 6 additions & 23 deletions .cloudbuild/library_generation/library_generation.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -54,29 +54,12 @@ RUN --mount=type=cache,target=/root/.m2 cp "/root/.m2/repository/com/google/api/
# python:3.11-alpine
FROM us-docker.pkg.dev/artifact-foundry-prod/docker-3p-trusted/python@sha256:0b5ed25d3cc27cd35c7b0352bac8ef2ebc8dd3da72a0c03caaf4eb15d9ec827a as python-scripts-build

# This will use GOOGLE_APPLICATION_CREDENTIALS if passed in docker build command.
# If not passed will leave it unset to support GCE Metadata in CI builds
ARG GOOGLE_APPLICATION_CREDENTIALS

RUN apk add bash curl

# Install gcloud to obtain the credentials to use the Airlock repostiory
RUN curl -sSL https://sdk.cloud.google.com | bash -e
ENV PATH $PATH:/root/google-cloud-sdk/bin


# Configure the Airlock pip package repository
RUN pip install keyrings.google-artifactregistry-auth -i https://pypi.org/simple/
COPY .cloudbuild/library_generation/image-configuration/airlock-pypirc /root/.pypirc
COPY .cloudbuild/library_generation/image-configuration/airlock-pip.conf /etc/pip.conf
RUN chmod 600 /root/.pypirc /etc/pip.conf

COPY library_generation /src

# install main scripts as a python package
WORKDIR /src

RUN --mount=type=secret,id=credentials python -m pip install --target /usr/local/lib/python3.11 -r requirements.txt
RUN python -m pip install --target /usr/local/lib/python3.11 -r requirements.txt
RUN python -m pip install --target /usr/local/lib/python3.11 .

# Final image. Installs the rest of the dependencies and gets the binaries
Expand Down Expand Up @@ -155,18 +138,18 @@ RUN rm /utilities.sh
RUN chmod 777 "${HOME}"
RUN touch "${HOME}/.bashrc" && chmod 755 "${HOME}/.bashrc"

# Copy the owlbot-cli binary
COPY --from=owlbot-cli-build /tools/repo-automation-bots/packages/owl-bot "/owl-bot"
WORKDIR /owl-bot
RUN npm link

# Here we transfer gapic-generator-java from the previous stage.
# Note that the destination is a well-known location that will be assumed at runtime.
# We hard-code the location string so it cannot be overriden.
COPY --from=ggj-build "/gapic-generator-java.jar" "${HOME}/.library_generation/gapic-generator-java.jar"
RUN chmod 755 "${HOME}/.library_generation"
RUN chmod 555 "${HOME}/.library_generation/gapic-generator-java.jar"

# Copy the owlbot-cli binary
COPY --from=owlbot-cli-build /tools/repo-automation-bots/packages/owl-bot "/owl-bot"
WORKDIR /owl-bot
RUN npm link

# Copy the library_generation python packages
COPY --from=python-scripts-build "/usr/local/lib/python3.11/" "/usr/lib/python3.11/"

Expand Down
16 changes: 1 addition & 15 deletions library_generation/DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,23 +129,9 @@ This is convenient in order to avoid installing the dependencies manually.
> From now, the examples assume you are in the root of your sdk-platform-java
> folder.
## Prepare your gcloud Application-Default-Credentials
This is necessary for the build context to access the Airlock repository of
Python packages.
To configure your credentials:

```bash
# creates or updates the credentials file in ~/.config/gcloud
gcloud auth application-default login
```

## Build the docker image
```bash
DOCKER_BUILDKIT=1 docker build \
--file .cloudbuild/library_generation/library_generation.Dockerfile \
--secret="id=credentials,src=$HOME/.config/gcloud/application_default_credentials.json" \
--build-arg GOOGLE_APPLICATION_CREDENTIALS=/run/secrets/credentials \
--iidfile image-id .
docker build --file .cloudbuild/library_generation/library_generation.Dockerfile --iidfile image-id .
```

This will create an `image-id` file at the root of the repo with the hash ID of
Expand Down

0 comments on commit a3490e2

Please sign in to comment.