google-nomulus/cloudbuild-proxy.yaml
jianglai f96da3cb29 Add a cloud build config to upload WAR files to GCS
The private repo structure is re-done to mirror that of the public repo to facilitate easy merging.

Also removed steps to tag the private repos. This will likely cause a race condition if both the nomulus and the proxy cloud build are triggered by the same tag. They will both try to tag the private repo with the same tag.

The tagging of the private repo should happen simultaneously with the public repo tagging, and in an out-of-band process as far as the build process is concerned. The build process should not have side effect on its source.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=225544063
2018-12-14 11:29:46 -05:00

37 lines
1.5 KiB
YAML

# To run the build locally, install cloud-build-local first.
# See: https://cloud.google.com/cloud-build/docs/build-debug-locally
# Then run:
# cloud-build-local --config=cloudbuild-proxy.yaml --dryrun=false --substitutions TAG_NAME=[TAG] .
# This will create a docker image named gcr.io/[PROJECT_ID]/proxy:[TAG] locally.
# The PROJECT_ID is the current project name that gcloud uses.
# You can add "--push true" to have the image pushed to GCR.
#
# To manually trigger a build on GCB, run:
# gcloud builds submit --config cloudbuild-proxy.yaml --substitutions TAG_NAME=[TAG] .
#
# To trigger a build automatically, follow the instructions below and add a trigger:
# https://cloud.google.com/cloud-build/docs/running-builds/automate-builds
steps:
# Set permissions correctly. Not sure why it is necessary, but it is.
- name: 'alpine'
args: ['chown', '-R', 'root:root', '.']
- name: 'alpine'
args: ['chmod', '-R', '777', '.']
# Clone the private repo merge its contents.
- name: 'gcr.io/cloud-builders/gcloud'
args: ['source', 'repos', 'clone', 'nomulus-config']
- name: 'alpine'
args: ['sh', '-c', 'cp -r nomulus-config/* .']
# Build the deploy jar.
- name: 'openjdk:8-slim'
args: ['./gradlew', ':proxy:deployJar', '-x', 'autoLintGradle']
dir: 'gradle'
# Build the docker image.
- name: 'gcr.io/cloud-builders/docker'
args: ['build', '--tag', 'gcr.io/${PROJECT_ID}/proxy:${TAG_NAME}', '.']
dir: 'gradle/proxy'
# Images to upload to GCR.
images: ['gcr.io/${PROJECT_ID}/proxy:${TAG_NAME}']
timeout: 3600s
options:
machineType: 'N1_HIGHCPU_8'