|
| 1 | +# Google Cloud Platform - Python Runtime Docker Image |
| 2 | + |
| 3 | +## `build.sh` |
| 4 | + |
| 5 | +There is a shell script called `build.sh` that builds everything in this |
| 6 | +repository. |
| 7 | + |
| 8 | +### Environment variables for `build.sh` |
| 9 | + |
| 10 | +DOCKER_NAMESPACE |
| 11 | +: The prefix applied to all images names created. To push images to Google |
| 12 | +Container Registry (GCR), this should be `gcr.io/YOUR-PROJECT-NAME`. |
| 13 | + |
| 14 | +TAG |
| 15 | +: The suffix applied to all images created. This should be unique. If not |
| 16 | +specified, the current time will be used (timestamp format `YYYY-mm-dd-HHMMSS`). |
| 17 | + |
| 18 | +GOOGLE_APPLICATION_CREDENTIALS |
| 19 | +: (System test only) Path to service account credentials in JSON format. |
| 20 | + |
| 21 | +GOOGLE_CLOUD_PROJECT |
| 22 | +: (System test only) Name of the Google Cloud Platform project to run the system |
| 23 | +tests under. |
| 24 | + |
| 25 | +## Building and Releasing |
| 26 | + |
| 27 | +A custom Jenkins job builds and releases this repository using scripts and job |
| 28 | +configurations that are not yet available publicly. The control flow is as |
| 29 | +follows: |
| 30 | + |
| 31 | +1. Jenkins job `python/release` is invoked by |
| 32 | + a. Manually running the script `build_and_release.py` with arguments |
| 33 | + b. Manually invoking the job from the GUI |
| 34 | +2. The job runs the script `release.sh` |
| 35 | + a. Service account credentials are read |
| 36 | + b. `gcloud auth activate-service-account` is performed |
| 37 | + c. `gcloud config set project` is performed |
| 38 | +3. The script invokes `build.sh` in this repository |
| 39 | +4. `build.sh` invokes Google Container Builder with the `cloudbuild-*.yaml` |
| 40 | + config files. |
| 41 | + |
| 42 | +## Building outside Jenkins |
| 43 | + |
| 44 | +To build this repository outside Jenkins, authenticate and authorize yourself |
| 45 | +with `gcloud auth`, set the variables listed above, and run: |
| 46 | + |
| 47 | +``` shell |
| 48 | +./build.sh |
| 49 | +``` |
| 50 | + |
| 51 | +This assumes an environment similar to the internal Jenkins environment (Linux, |
| 52 | +Debian or Ubuntu-like). |
| 53 | + |
| 54 | +## Building locally |
| 55 | + |
| 56 | +To build this repository using local Docker commands instead of the Google |
| 57 | +Container Builder service, add the `--local` flag as shown: |
| 58 | + |
| 59 | +``` shell |
| 60 | +./build.sh --local |
| 61 | +``` |
| 62 | + |
| 63 | +To open an interactive shell session to this image after building it, do the |
| 64 | +following: |
| 65 | + |
| 66 | +``` shell |
| 67 | +docker run -it --entrypoint /bin/bash YOUR-IMAGE-NAME |
| 68 | +``` |
| 69 | + |
| 70 | +## Running benchmarks |
| 71 | + |
| 72 | +There is a benchmark suite which compares the performance of interpreters |
| 73 | +against each other. |
| 74 | + |
| 75 | +``` shell |
| 76 | +./build.sh --nobuild --benchmark |
| 77 | +``` |
| 78 | + |
| 79 | +Since these benchmarks are run on cloud instances, the timings may vary from run |
| 80 | +to run. |
| 81 | + |
| 82 | +## Running system tests |
| 83 | + |
| 84 | +**TAKE NOTE: You will incur charges for use of Google Cloud Platform services!** |
| 85 | + |
| 86 | +System tests perform mutating operations against the real Google Cloud services. |
| 87 | +Since these system tests may fail or be flaky for outside reasons such as |
| 88 | +netorking issues, configuration errors, or services outages, they are run |
| 89 | +separately from building the images, and should be run in their own project. |
| 90 | + |
| 91 | +To run the system tests, you need a Google Cloud Project with a service account. |
| 92 | +From the [Google Cloud Console](https://console.cloud.google.com/), either |
| 93 | +create a new project or switch to an existing one. Next, |
| 94 | +[create a service account]( |
| 95 | +https://cloud.google.com/iam/docs/creating-managing-service-accounts) that will |
| 96 | +be used to run the system tests. Once you have a service account, |
| 97 | +[create and download a service account key](https://cloud.google.com/iam/docs/managing-service-account-keys). |
| 98 | + |
| 99 | +In the |
| 100 | +[IAM & Admin](https://console.cloud.google.com/permissions/projectpermissions) |
| 101 | +section, grant the `Owner` role to the service account you created above. Also |
| 102 | +grant the `Editor` role to the `cloud-logs@google.com` service account. |
| 103 | + |
| 104 | +Then, follow the |
| 105 | +[system test setup instructions](https://github.com/GoogleCloudPlatform/google-cloud-python/blob/master/CONTRIBUTING.rst#running-system-tests). It |
| 106 | +describes various steps, including running some scripts to populate and/or |
| 107 | +delete datastore example data and indexes (populate_datastore.py, |
| 108 | +clear_datastore.py, and `gcloud preview datastore create-indexes |
| 109 | +system_tests/data/index.yaml`). |
| 110 | + |
| 111 | +From the cloud console, you will need to enable at least the following APIs for |
| 112 | +your project: |
| 113 | + |
| 114 | +- Bigquery API |
| 115 | +- Cloud Bigtable Admin API |
| 116 | +- Cloud Spanner API |
| 117 | +- Google Cloud Natural Language API |
| 118 | +- Google Cloud Pub/Sub API |
| 119 | +- Google Cloud Speech API |
| 120 | +- Google Cloud Storage JSON API |
| 121 | +- Google Cloud Translation API |
| 122 | +- Google Cloud Vision API |
| 123 | +- Stackdriver Logging API |
| 124 | +- Stackdriver Monitoring API |
| 125 | + |
| 126 | +Once all the setup has been done, run the following: |
| 127 | + |
| 128 | +``` shell |
| 129 | +./build.sh --nobuild --system_tests |
| 130 | +``` |
0 commit comments