pete
pete

Reputation: 601

Install a python library from a Cloud Source Repository to a Cloud Run container

I have a Google Source Repository that mirrors a private Github repo of mine that contains code for a Python package. I also have a Cloud Run instance where I'd like to install this private Python library. How can I go about doing that in the cloudbuild.yaml or Dockerfile?

Upvotes: 2

Views: 789

Answers (1)

guillaume blaquiere
guillaume blaquiere

Reputation: 75705

Cloud Source repository is a Git repository. So, if you want to get sources (your private library) from there, simply clone the repo (the head, or a specific tag/commit sha).

You can't use pip install command because you need a private pipy server installed to achieve this. If you have this, get the credentials and request it!


That's for the principle. Then how to achieve this in Cloud Build or in Docker build.

IMO, the easiest is in the Cloud Build pipeline. Load a GIT compliant image (for instance gcr.io/cloud-builders/git) and close your Cloud Source repo. I recommend this step because you can use the Cloud Build authentication context to log into Cloud Source repository.

Then, in your Dockerfile, copy all your environment (your code and the venv that contains the download library). The additional public libraries can be download inside the Dockerfile, or in the Cloud Build, as you wish.

Upvotes: 5

Related Questions