A toy application for very specific demo purposes.
- NodeJS installed.
- Docker installed.
- Google Cloud SDK (gcloud) installed and configured (logged into your Google Cloud account).
- A Google Cloud Project with the Cloud Run API and Artifact Registry API enabled.
- An Artifact Registry Docker repository created.
First install the dependencies:
npm install
Now run the application locally
npm start
Once it's running you can curl against localhost:8080 and see the response
To run the unit tests:
npm test
To run the linter:
npm run lint
To build the docker image locally run:
docker build -t gcp-training-javascript .
To test the local image run:
docker run --rm -p 9090:8080 --name local-gcp-training-javascript gcp-training-javascript
Once it's running you can curl against localhost:9090 and see the response
Uploading to Artifact Registry (replace the capitals vars):
# authenticate
gcloud auth configure-docker YOUR_REGION-docker.pkg.dev
# build your image
docker buildx build --platform linux/amd64 -t YOUR_REGION-docker.pkg.dev/GCP_PROJECT_NAME/YOUR_REPO_NAME/gcp-training-javascript .
# push image
docker push YOUR_REGION-docker.pkg.dev/GCP_PROJECT_NAME/YOUR_REPO_NAME/gcp-training-javascript
Deploy to Cloud Run:
gcloud run deploy gcp-training-javascript \
--image YOUR_REGION-docker.pkg.dev/YOUR_PROJECT_ID/YOUR_REPO_NAME/gcp-training-javascript:latest \
--region YOUR_REGION \
--allow-unauthenticated
Once deployed, gcloud will output the Service URL. You can access your running application at this URL.