👷 add Dockerfile
This commit is contained in:
parent
7c2456a033
commit
c2af2aa94e
2
.dockerignore
Normal file
2
.dockerignore
Normal file
@ -0,0 +1,2 @@
|
||||
node_modules
|
||||
npm-debug.log
|
26
Dockerfile
Normal file
26
Dockerfile
Normal file
@ -0,0 +1,26 @@
|
||||
FROM node:16.17.0-alpine
|
||||
|
||||
#创建/opt/app 目录作为部署目录,创建容器实例时,挂载此目录
|
||||
RUN mkdir -p /opt/app
|
||||
# 设置工作目录
|
||||
WORKDIR /opt/app
|
||||
# 将代码复制到容器中
|
||||
COPY . /opt/app
|
||||
|
||||
RUN cd /opt/app
|
||||
# 添加权限,防止依赖无法安装
|
||||
RUN chmod -R 777 *
|
||||
# 添加执行shell文件权限
|
||||
RUN chmod u+x pm2.sh
|
||||
|
||||
RUN yarn --registry=https://registry.npm.taobao.org
|
||||
RUN npm i pm2 -g --registry=https://registry.npm.taobao.org
|
||||
RUN npm run build
|
||||
|
||||
RUN ls -l -a
|
||||
|
||||
# 容器对外暴露的端口号,要和node项目配置的端口号一致
|
||||
EXPOSE 3000
|
||||
|
||||
# 通过shell文件来执行多条命令
|
||||
CMD ["./pm2.sh"]
|
19
pm2.json
Normal file
19
pm2.json
Normal file
@ -0,0 +1,19 @@
|
||||
{
|
||||
"name": "nebula",
|
||||
"exec_mode": "cluster",
|
||||
"instances": "max",
|
||||
"script": "./node_modules/nuxt/bin/nuxt.js",
|
||||
"args": "start",
|
||||
"env": {
|
||||
"NODE_ENV": "production",
|
||||
"VUE_APP_TITLE": "production"
|
||||
},
|
||||
"env_dev": {
|
||||
"NODE_ENV": "development",
|
||||
"VUE_APP_TITLE": "development"
|
||||
},
|
||||
"env_prod": {
|
||||
"NODE_ENV": "production",
|
||||
"VUE_APP_TITLE": "production"
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user