Skip to content
Sample Node.js App for use with Google Cloud Build + Cloud Run
JavaScript Dockerfile
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore
Dockerfile
LICENSE
README.md
cloudbuild.yaml
docker-compose.yml
package-lock.json
package.json
server.js
test.js

README.md

Sample Node App

This folder contains a Dockerized Node.js app that is meant to be used for demonstration purposes only. You should follow the example in this code in your own apps and then remove this sample app once things are working.

The app responds with a simple "Hello World!".

Running the app in local development

The provided Docker Compose file allows you to run the app locally in development. To start the container, run:

$ docker-compose up

Once the stack has launched, you can test the application by navigating to:

Executing the Tests

Simply run:

$ npm run test

Building and pushing the Docker image to Container Registry

  1. Configure Docker to use gcloud as a credential helper. Your Docker client version must be 1.13 or newer.
gcloud auth configure-docker
  1. Build and tag your image.
docker build -t [GCP-CONTAINER-REGISTRY-HOSTNAME]/[PROJECT-ID]/sample-node-app .
  1. Push the Docker image
docker push [GCP-CONTAINER-REGISTRY-HOSTNAME]/[PROJECT-ID]/sample-node-app

The Container Registry hostname will vary according to your region. For more information, check the Container Registry docs.

You can’t perform that action at this time.