Open joephon opened 4 years ago
Docker
npm
mkdir koa && cd koa && vim app.js npm i --save koa
// koa/app.js const Koa = require('koa') const app = new Koa() const PORT = 3000 app.use((ctx) => { ctx.body = 'Hello World!' }) app.listen(PORT, () => console.log(`Server is running on port: ${PORT}`))
vim Dockerfile
// koa/Dockerfile FROM node:latest COPY . /app WORKDIRE /app RUN npm i EXPOSE 3000 CMD node ./app.js
docker build .
docker run -p 3000:3000 -d [your docker image id]
curl -get localhost:3000 // => Hello World!
Dependencies
Docker
npm
Step 1 init project and write your koa code
Step 2 write your Dockerfile
Step 3 build your docker file
Step 4 run your app
Bingo~
这篇文章价值一块钱