成果物
Express JS
package.json
{
"name": "WLSearch",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node index.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"express": "^4.17.1"
}
}
index.js
const express = require('express');
const app = express();
const port = process.env.PORT || 8080;
app.listen(port, () => {
console.log(`Listening on port ${port}.`);
});
app.get("/hello", async (req, res) => {
const word = req.query.w;
res.send(`Hello, you entered ${word}!`);
});
Dockerfile
FROM node:14-slim
WORKDIR /usr/src/app
COPY package.json package*.json ./
RUN npm install --only=production
COPY . .
CMD ["npm", "start"]
イメージ作成
$ gcloud builds submit --tag=gcr.io/wantinglist/wl-search --project=wantinglist