Last active
July 9, 2019 13:10
-
-
Save Timtech4u/a5d6bb10e871d00eacd5af81b9cccf13 to your computer and use it in GitHub Desktop.
Source Codes for Google Cloud Run Article
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Use the official Node.js 10 image. | |
# https://hub.docker.com/_/node | |
FROM node:10 | |
# Create and change to the app directory. | |
WORKDIR /usr/src/app | |
# Copy application dependency manifests to the container image. | |
# A wildcard is used to ensure both package.json AND package-lock.json are copied. | |
# Copying this separately prevents re-running npm install on every code change. | |
COPY package.json package*.json ./ | |
# Install production dependencies. | |
RUN npm install --only=production | |
# Copy local code to the container image. | |
COPY . . | |
# Run the web service on container startup. | |
CMD [ "npm", "start" ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express'); | |
const app = express(); | |
app.get('/', (req, res) => { | |
console.log('Hello world received a request.'); | |
const target = process.env.TARGET || 'World'; | |
res.send(`Hello ${target}!`); | |
}); | |
const port = process.env.PORT || 8080; | |
app.listen(port, () => { | |
console.log('Hello world listening on port', port); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "hello-cloud-run", | |
"version": "1.0.0", | |
"description": "Simple hello world sample in Node", | |
"main": "index.js", | |
"scripts": { | |
"start": "node index.js" | |
}, | |
"author": "", | |
"license": "Apache-2.0", | |
"dependencies": { | |
"express": "^4.16.4" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment