GithubHelp home page GithubHelp logo

weisi / bazel_for_gcloud_python Goto Github PK

View Code? Open in Web Editor NEW
10.0 2.0 3.0 13 KB

Bazel rules for Python 3 Google App Engine and Google Cloud Functions deployment.

License: Other

Shell 24.02% Starlark 75.98%
google-cloud-functions google-app-engine bazel-rules python3

bazel_for_gcloud_python's Introduction

Bazel Rules: Python 3 Google App Engine & Google Cloud Functions

This repository contains the Bazel (Starlark) rules to build Python 3 and deploy to Google App Engine and Google Cloud Functions.

Usage

There is a GAE app example and a GCF example in the examples directory.

Google App Engine (Python 3)

Put this in the BUILD file:

py_binary(
    name = "app",
    srcs = [
        "app.py",
    ],
)

py_app_engine(
    name = "app_deploy",
    src = ":app",
    descriptor = "app.yaml",
    entry = "app",
    requirements = [
        "flask",
    ],
)

and run:

examples$ bazel run //app_engine:app_deploy

Google Cloud Functions (Python 3)

Put this in the BUILD file:

py_binary(
    name = "hello",
    srcs = [
        "hello.py",
    ],
)

py_cloud_function(
    name = "hello_deploy",
    src = ":hello",
    entry = "hello",
)

and run:

examples$ bazel run //function:hello_deploy

Features

In the BUILD rule you can also specify:

PyPI (pip) requirements
either as a package list or pointing to a requirements.txt file
The GCP project name
if you don't want to use the default one used by gcloud
Version (App Engine only)
the version string of the GAE deployment
Python Runtime (Cloud Functions only)
the Python runtime to use (default: python37)
Deploy name (Cloud Functions only)
the name of the deployed function (in GCP) and also in the HTTP path
Pub/Sub topic trigger (Cloud Functions only)
if you want your function to be triggered by a Cloud Pub/Sub message
GCS bucket trigger (Cloud Functions only)
if you want your function to be triggered by events from a GCS bucket
General event trigger (Cloud Functions only)
if you want your function to be triggered by other event types
Memory in MiB (Cloud Functions only)
the default is 256 MiB but you can request more, up to 2,048 MiB
Timeout in seconds (Cloud Functions only)
the default is 60 s but you can request up to 540 s.

Requirements

This solution depends on these commands being available:

Your Bazel workspace should be set to generate a ZIP package for py_binary targets, by setting some parameters in the .bazelrc file, like this.

LICENSE

bazel_for_gcloud_python is released under the Apache 2.0 License.

bazel_for_gcloud_python's People

Contributors

lucienve avatar weisi avatar zweihan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

zweihan

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.