Skip to content

Instantly share code, notes, and snippets.

@apstndb
Last active January 10, 2023 22:22
Show Gist options
  • Save apstndb/f362881ac2335f10a5ebe5456e5c4cec to your computer and use it in GitHub Desktop.
Save apstndb/f362881ac2335f10a5ebe5456e5c4cec to your computer and use it in GitHub Desktop.

Revisions

  1. apstndb revised this gist Jun 4, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion cloudbuild.yaml
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    steps:
    # Cloud Build uses cloud
    # Cloud Build uses cloudbuild network
    # https://cloud.google.com/cloud-build/docs/overview#build_configuration_and_build_steps
    - name: gcr.io/cloud-builders/docker
    args: ['run', '-d', '--network=cloudbuild', '--name=cds-emulator', 'google/cloud-sdk:248.0.0', 'gcloud', 'beta', 'emulators', 'datastore', 'start', '--host-port=0.0.0.0:8081']
  2. apstndb revised this gist Jun 3, 2019. 2 changed files with 8 additions and 1 deletion.
    7 changes: 6 additions & 1 deletion 0Datastore_Emulator_on_Cloud_Build.md
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,8 @@
    ```
    cloud-build-local --config=cloudbuild.yaml --dryrun=false .
    ```
    ```

    ## refs

    https://cloud.google.com/cloud-build/docs/overview#build_configuration_and_build_steps
    > Each build step is run with its container attached to a local Docker network named cloudbuild. This allows build steps to communicate with each other and share data.
    2 changes: 2 additions & 0 deletions cloudbuild.yaml
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,6 @@
    steps:
    # Cloud Build uses cloud
    # https://cloud.google.com/cloud-build/docs/overview#build_configuration_and_build_steps
    - name: gcr.io/cloud-builders/docker
    args: ['run', '-d', '--network=cloudbuild', '--name=cds-emulator', 'google/cloud-sdk:248.0.0', 'gcloud', 'beta', 'emulators', 'datastore', 'start', '--host-port=0.0.0.0:8081']
    - name: jwilder/dockerize:0.6.1
  3. apstndb revised this gist Jun 3, 2019. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions cloudbuild.yaml
    Original file line number Diff line number Diff line change
    @@ -7,5 +7,6 @@ steps:
    env:
    - DATASTORE_EMULATOR_HOST=cds-emulator:8081
    args: ['sh', '-c', 'curl $${DATASTORE_EMULATOR_HOST}/v1/projects/example-project/indexes']
    # for cloud-build-local
    - name: gcr.io/cloud-builders/docker
    args: ['rm', '--force', 'cds-emulator']
  4. apstndb revised this gist Jun 3, 2019. 1 changed file with 22 additions and 0 deletions.
    22 changes: 22 additions & 0 deletions cloudbuild2.yaml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    # it is not success because docker stopped step returns 137
    steps:
    - name: google/cloud-sdk:248.0.0
    args: ['gcloud', 'beta', 'emulators', 'datastore', 'start', '--host-port=0.0.0.0:8081']
    - name: jwilder/dockerize:0.6.1
    id: dockerize
    args: ['dockerize', '-timeout=60s', '-wait=tcp://step_0:8081']
    waitFor: ['-']
    - name: gcr.io/cloud-builders/docker
    args: ['ps']
    waitFor: ['dockerize']
    - name: google/cloud-sdk:248.0.0
    id: main
    env:
    - DATASTORE_EMULATOR_HOST=step_0:8081
    args: ['sh', '-c', 'curl $${DATASTORE_EMULATOR_HOST}/v1/projects/example-project/indexes']
    waitFor: ['dockerize']
    - name: gcr.io/cloud-builders/docker
    env:
    - DATASTORE_EMULATOR_HOST=step_0:8081
    args: ['stop', "step_0"]
    waitFor: ['main']
  5. apstndb revised this gist Jun 3, 2019. 1 changed file with 0 additions and 2 deletions.
    2 changes: 0 additions & 2 deletions cloudbuild.yaml
    Original file line number Diff line number Diff line change
    @@ -3,8 +3,6 @@ steps:
    args: ['run', '-d', '--network=cloudbuild', '--name=cds-emulator', 'google/cloud-sdk:248.0.0', 'gcloud', 'beta', 'emulators', 'datastore', 'start', '--host-port=0.0.0.0:8081']
    - name: jwilder/dockerize:0.6.1
    args: ['dockerize', '-timeout=60s', '-wait=tcp://cds-emulator:8081']
    - name: gcr.io/cloud-builders/docker
    args: ['ps']
    - name: google/cloud-sdk:248.0.0
    env:
    - DATASTORE_EMULATOR_HOST=cds-emulator:8081
  6. apstndb revised this gist Jun 3, 2019. 1 changed file with 0 additions and 3 deletions.
    3 changes: 0 additions & 3 deletions cloudbuild.yaml
    Original file line number Diff line number Diff line change
    @@ -1,14 +1,11 @@
    steps:
    - name: gcr.io/cloud-builders/docker
    id: cds-emulator
    args: ['run', '-d', '--network=cloudbuild', '--name=cds-emulator', 'google/cloud-sdk:248.0.0', 'gcloud', 'beta', 'emulators', 'datastore', 'start', '--host-port=0.0.0.0:8081']
    - name: jwilder/dockerize:0.6.1
    id: dockerize
    args: ['dockerize', '-timeout=60s', '-wait=tcp://cds-emulator:8081']
    - name: gcr.io/cloud-builders/docker
    args: ['ps']
    - name: google/cloud-sdk:248.0.0
    id: main
    env:
    - DATASTORE_EMULATOR_HOST=cds-emulator:8081
    args: ['sh', '-c', 'curl $${DATASTORE_EMULATOR_HOST}/v1/projects/example-project/indexes']
  7. apstndb created this gist Jun 3, 2019.
    3 changes: 3 additions & 0 deletions 0Datastore_Emulator_on_Cloud_Build.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,3 @@
    ```
    cloud-build-local --config=cloudbuild.yaml --dryrun=false .
    ```
    16 changes: 16 additions & 0 deletions cloudbuild.yaml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    steps:
    - name: gcr.io/cloud-builders/docker
    id: cds-emulator
    args: ['run', '-d', '--network=cloudbuild', '--name=cds-emulator', 'google/cloud-sdk:248.0.0', 'gcloud', 'beta', 'emulators', 'datastore', 'start', '--host-port=0.0.0.0:8081']
    - name: jwilder/dockerize:0.6.1
    id: dockerize
    args: ['dockerize', '-timeout=60s', '-wait=tcp://cds-emulator:8081']
    - name: gcr.io/cloud-builders/docker
    args: ['ps']
    - name: google/cloud-sdk:248.0.0
    id: main
    env:
    - DATASTORE_EMULATOR_HOST=cds-emulator:8081
    args: ['sh', '-c', 'curl $${DATASTORE_EMULATOR_HOST}/v1/projects/example-project/indexes']
    - name: gcr.io/cloud-builders/docker
    args: ['rm', '--force', 'cds-emulator']