Skip to content

Commit

Permalink
feat(egg-prisma-template-ts): support docker deyloy
Browse files Browse the repository at this point in the history
  • Loading branch information
MrGaoGang committed Dec 21, 2022
1 parent de1291b commit 5acdb2b
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 28 deletions.
4 changes: 4 additions & 0 deletions packages/egg-prisma-template-ts/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
npm-debug.log
run
logs
19 changes: 19 additions & 0 deletions packages/egg-prisma-template-ts/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM node:14.19.3
# set container file dir
RUN mkdir -p /usr/src/app
# set work dir
WORKDIR /usr/src/app
# 复制packages.json
COPY package*.json /usr/src/app
# 安装依赖
RUN npm install
# 复制所有文件到工作目录
ADD . /usr/src/app
# ORM prisma 生成 类型定义
RUN npm run model:b
# 编译ts
RUN npm run tsc
# 在docker 中要使用前台模式运行
CMD [ "npm", "run" , "start:docker" ]
# 暴露容器端口
EXPOSE 7001
16 changes: 14 additions & 2 deletions packages/egg-prisma-template-ts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
- [x] 基于 md5 的密码加密
- [x] 用户注册
- [x] 登录态校验
- [x] `docker`: 利用 docker 一键部署 应用
- [ ] `redis`
- [ ] `docker`
- [ ] `swagger api doc`: 基于 `router` 注解的方式自动生成 api 请求文档;
- [ ] 微信
- [x] [微信小程序 登录](https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/others/WeChat_login.html)
- [ ] 微信公众号
- [ ] 微信公众号
- [ ] `github` 登录鉴权

内置的插件:
Expand Down Expand Up @@ -115,3 +115,15 @@ npm run dev
### 接口测试/鉴权测试

![](./docs//imgs/test.png)

## 四、打包部署

```bash

# 构建镜像
docker build -t prisma-egg-node .

# 启动
docker run -p 7001:7001 -d --name prisma-egg-node-instance prisma-egg-node

```
26 changes: 25 additions & 1 deletion packages/egg-prisma-template-ts/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions packages/egg-prisma-template-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@
},
"scripts": {
"start": "egg-scripts start --daemon --title=egg-server-egg-prisma-template-ts",
"start:docker": "egg-scripts start --title=egg-server-egg-prisma-template-ts",
"stop": "egg-scripts stop --title=egg-server-egg-prisma-template-ts",
"dev": "egg-bin dev",
"debug": "egg-bin debug",
"build:docker": "rm -rf logs && rm -rf run && docker build -t prisma-egg-node .",
"test-local": "egg-bin test",
"test": "npm run lint -- --fix && npm run test-local",
"cov": "egg-bin cov",
Expand All @@ -21,6 +23,7 @@
"db:c": "npx prisma migrate dev --name db-change",
"db:ui": "npx prisma studio",
"db:pull": "npx prisma db pull",
"model:b": "npx prisma generate",
"lint": "eslint . --ext .ts --resolve-plugins-relative-to .",
"clean": "ets clean"
},
Expand Down

This file was deleted.

16 changes: 0 additions & 16 deletions packages/egg-prisma-template-ts/test/app/service/Test.test.ts

This file was deleted.

0 comments on commit 5acdb2b

Please sign in to comment.