Skip to content

Commit e270ef4

Browse files
author
jiawei22
committed
Dockerfile构建NodeJS应用示例
0 parents  commit e270ef4

File tree

5 files changed

+64
-0
lines changed

5 files changed

+64
-0
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.idea/

Dockerfile

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM node:18.8.0-alpine
2+
3+
WORKDIR app_work_dir
4+
ADD . /app_work_dir
5+
6+
RUN npm install
7+
EXPOSE 5050
8+
9+
ENTRYPOINT ["npm", "run"]
10+
CMD ["start"]

README.md

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# NodeJS应用示例
2+
3+
## 本地运行
4+
5+
```sh
6+
$ git clone https://github.com/sinacloud/nodejs-getting-started-dockerfile.git
7+
$ cd nodejs-getting-started-dockerfile
8+
$ npm install
9+
$ npm start
10+
```
11+
12+
现在,本示例应用已经跑在了你的 localhost:5050 端口上了。
13+
14+
## 部署到sinacloud
15+
16+
首先,提交代码到你的sinacloud应用的git仓库。
17+
18+
19+
登陆sinacloud容器云的管理页面,在运行环境管理-代码管理-如何部署查看部署代码方式。
20+
21+
部署完成之后,你就可以通过 http://$APPNAME.saelinzi.com 来访问你的应用了。
22+
```
23+
如果您的应用显示未激活,您需要设置host才能访问,设置方法参见应用的管理页面
24+
```
25+
26+
## 相关文档

index.js

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
var express = require('express')
2+
var app = express()
3+
4+
app.get('/', function (req, res) {
5+
res.send('Hello SAE NodeJS')
6+
})
7+
8+
app.listen(process.env.PORT || 5050)

package.json

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "nodejs-getting-started-dockerfile",
3+
"description": "getting started with nodejs on sinacloud platform",
4+
"version": "0.0.1",
5+
"private": true,
6+
"author": {
7+
"name": "sae",
8+
"email": "saemail@sina.cn"
9+
},
10+
"dependencies": {
11+
"express": "^4.13.3"
12+
},
13+
"engines": {
14+
"node": "v18.8.0"
15+
},
16+
"scripts": {
17+
"start": "node index.js"
18+
}
19+
}

0 commit comments

Comments
 (0)