GithubHelp home page GithubHelp logo

chriseaton / cloud-build-local Goto Github PK

View Code? Open in Web Editor NEW
4.0 1.0 0.0 38.15 MB

A local Google Cloud Build Local runner for non-production and development purposes based on the original (now archived) Google respository.

License: Apache License 2.0

Go 98.06% Dockerfile 0.02% Shell 1.91% JavaScript 0.01%
build-tool cli cloud gcb gcp google-cloud-build ci-cd cicd deployment local-ci

cloud-build-local's Introduction

Google Cloud Build Local

GCBL runs Google Cloud Build locally, allowing easier debugging, execution of builds on your own hardware, and integration into local build and test workflows.

Community Fork

This Google Cloud Build Local fork is maintained by volunteers, so may not always maintain 100% parity with Google's Cloud Build service. Stability and compatibility are our primary goals. If you'd like to contribute, please feel free to put something together and submit a merge request!

As of 2023, the original repository from Google has been archived. This fork is an attempt to keep the project alive, at least, in some form close to the original, and maybe improve on it a bit.

Note

Cloud Build Local works without Google Cloud!
You can create pipelines as you see fit, locally, and yes, offline!
Check out the §New Features below regarding the --no-cloud argument.

Samples

See our example node.js GCP function in the samples/ directory which includes an example pipeline.

Tip

See also: Google Cloud Build File Schema GCBL maintains parity with syntax and format, so you can leverage the official documentation to construct your deployment pipelines (*.yaml files).

New Features

  • Added support for loading .env file secrets for secretEnv replacements.
    This will convert only the matching secretEnv into a corresponding env with a value.
    To use this, just add the --env=<envfilepath> argument with envfilepath as the path to the .env file.
    This is not supported in the cloud, and only works for GCBL. Which means the cloud will simply treat a secretEnv as intended :)
  • No contributor agreements. Just code!
  • Added support for skipping cloud token gathering and metadata with argument --no-cloud. This let's you run cloud-build-local without an active gcloud authentication token (which requires a GCP account).

Usage

  1. You'll need to make sure your system has docker installed.
  2. Grab the latest release or build from source.
  3. Install into your system. Here's an easy way to do it:
    unzip <release>.zip
    sudo chown root: ./cloud-build-local
    sudo chmod u+x,g+x,o+x ./cloud-build-local
    sudo mv ./cloud-build-local /usr/bin/
    
  4. Get started using GCBL!

To run a local build you should make sure you've got credentials to GCP if using any resources (gcloud auth login), then specify a false dryrun, the config, and the source code/content directory path. If you don't have a Google Cloud login, then use the --no-cloud argument.

./cloud-build-local \
  --dryrun=false \
  --config=path/to/cloudbuild.yaml \
  --env=/path/to/.env \
  /path/to/app

Development

To build GCBL from source, and run tests, you need a working Go environment. You should also install gcloud and Docker.

This binary has only been tested to work on Linux operating systems. Windows and Mac are currently unsupported, though community contributions are welcome in this area.

Setup

go mod vendor
go get

Build

go build -o cloud-build-local github.com/GoogleCloudPlatform/cloud-build-local

Optionally, create a system-wide link to the built executable:

sudo ln -s "$(pwd)/cloud-build-local" /usr/bin/cloud-build-local

Test

If you'd like to run the manual test build...

  1. Create a tests/.env file with a secret replacement value:
    HELLO_BUILD=my secret env variable replacement
  2. Run the test locally:
    ./cloud-build-local --dryrun=false --config=./tests/cloudbuild.yaml --env=./tests/.env ./tests/src

Other tests (legacy):

go test $(go list github.com/GoogleCloudPlatform/cloud-build-local/... | grep -v vendor)

cloud-build-local's People

Contributors

bendory avatar chriseaton avatar codrienne avatar danielpeach avatar emoryruscus avatar leeonlee avatar philmod avatar rafikk avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.