Bower

If you're using Bower to install web dependencies for your app and you're
deploying your app to Google App Engine Flexible environment, then there are
several ways to make sure the dependencies are available to your deployed app.
This tutorial discusses three different methods.

Prerequisites

Prepare

Install Bower:

npm install -g bower

Create a bower.json file if you don't already have one:

bower init

Then save new dependencies to your bower.json with:

bower install --save

Easiest - Do nothing

When you deploy to App Engine Flexible enviroment a Docker image is created for
you and your code is copied into the image. This first method relies on the
Docker image build step to make Bower dependencies available to your app. This
method is the easiest.

This method is simple:

Install Bower dependencies locally

Deploy

For example:

cd my-app
bower install
gcloud app deploy

The Bower dependencies will be installed, and during the deployment the files
will be copied into the Docker image, and thus will be available to your
deployed app.

Less Easy - Use package.json

Let's say you don't want locally installed Bower dependencies to be copied
into the Docker image. To make the dependencies available to your deployed app,
you can have the dependencies installed inside the Docker image as it is
constructed.

Run the following command to generate an `app.yaml file if you don't already
have one:

gcloud app gen-config . --runtime=nodejs

To prevent locally installed Bower dependencies from being copied into the
Docker image, add the following to app.yaml:

The ellipses hide other configurations that may exist in package.json.

Now deploy:

gcloud app deploy

As the Docker image is built it will run npm install, which will in turn
run bower install.

Much Less Easy - Use a Dockerfile

Another method that does not rely on package.json is to use a custom
Dockerfile.

To make Docker install the Bower dependencies you need to use runtime: custom.
Here we assume you're deploying a Node.js app, but with a little extra
customization in the Dockerfile you can make this work for other languages.

Run the following command to generate the necessary files:

gcloud app gen-config . --custom --runtime=nodejs

This generates three files: Dockerfile, .dockerignore, and app.yaml.

To prevent locally installed Bower dependencies from being copied into the
Docker image. Add the following to app.yaml:

Related Tutorials

Submit a Tutorial

Request a Tutorial

GCP Tutorials

Beta: Community Contributed Tutorials is a Beta release. This feature is not covered by any SLA or deprecation policy and may be subject to backward-incompatible changes.
Except as otherwise noted, the content of this page is licensed under the
Creative Commons Attribution 4.0 License, and code samples are licensed under the
Apache 2.0 License. For details, see our
Site Policies. Java is a registered trademark of Oracle and/or its affiliates.