Skip to content

Commit

Permalink
fix: [Task]: 更新 create-steedos-app 中的项目模版到微服务架构 #4712
Browse files Browse the repository at this point in the history
  • Loading branch information
baozhoutao committed Apr 11, 2023
1 parent 5f4812d commit b3dd929
Show file tree
Hide file tree
Showing 25 changed files with 385 additions and 61 deletions.
21 changes: 18 additions & 3 deletions packages/create-steedos-app/create-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,15 @@ export async function createApp({
name: appName,
version: '0.1.0',
private: true,
workspaces: [
"services/*"
],
scripts: {
start: 'steedos start'
},
docker: "docker-compose up",
start: "moleculer-runner services/*/package.service.js --hot --repl",
repl: "moleculer-runner --repl",
nodered: "node-red --settings nodered.config.js"
}
}
/**
* Write it to disk.
Expand All @@ -227,7 +233,13 @@ export async function createApp({
/**
* Default dependencies.
*/
const dependencies = ['@steedos/service-community']
const dependencies = [
'@steedos/service-package-loader',
'@steedos/node-red-contrib-steedos',
'dotenv-flow',
'moleculer-repl',
'node-red'
]
/**
* Default devDependencies.
*/
Expand Down Expand Up @@ -281,6 +293,9 @@ export async function createApp({
switch (name) {
case 'env':
case 'gitignore':
case 'gitpod.yml':
case 'npmrc':
case 'yarnrc':
case 'eslintrc.json': {
return '.'.concat(name)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"recommendations": [
"redhat.vscode-yaml", "steedos.steedosdx-vscode", "mongodb.mongodb-vscode"
"redhat.vscode-yaml", "steedos.steedosdx-vscode"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,5 @@
"./node_modules/@steedos/schemas/permissionset/schema.json": "/*.permissionset.yml",
"./node_modules/@steedos/schemas/profile/schema.json": "/*.profile.yml",
"./node_modules/@steedos/schemas/dashboard/schema.json": "/*.dashboard.yml"
},
"cSpell.words": [
"OIDC"
]
}
}
20 changes: 20 additions & 0 deletions packages/create-steedos-app/templates/default/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "Install Steedos DX",
"type": "shell",
"command": "echo Please Install Steedos DX Extensions",
"linux": {
"command": "npx json5 .vscode/extensions.json | npx json-cli-tool --path=recommendations --output=newline | xargs -L 1 code --install-extension",
},
"presentation": {
"reveal": "always",
"panel": "new"
},
"runOptions": {
"runOn": "folderOpen"
}
}
]
}
20 changes: 20 additions & 0 deletions packages/create-steedos-app/templates/default/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM node:14-slim

RUN apt-get update || : && apt-get install -y \
python \
curl \
build-essential

WORKDIR /app

ADD .env .
ADD lerna.json .
ADD package.json .
ADD steedos.config.js .
ADD steedos-packages .

ENV NODE_ENV=production

RUN yarn --production

CMD ["yarn", "start"]
65 changes: 48 additions & 17 deletions packages/create-steedos-app/templates/default/README-template.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,64 @@
This is a [Steedos](https://www.steedos.com/) project bootstrapped with [`create-steedos-app`](https://github.com/steedos/steedos-platform/tree/master/packages/create-steedos-app).
华炎魔方模版项目
===

## Getting Started
<p align="center">
<a href="./README_en.md">English</a>
<a href="https://www.steedos.cn/docs/"> · 文档</a>
<a href="https://www.steedos.cn/videos/"> · 视频</a>
<a href="https://demo.steedos.cn"> · 试用</a>
</p>

### Start mongodb & redis service

<p align="center" style="border-top: solid 1px #cccccc">
华炎魔方是 <a href="https://developer.salesforce.com/developer-centers/developer-experience" target="_blank">Salesforce Developer Experience (DX)</a> 的开源替代方案,将低代码技术与 <a href="https://www.steedos.cn/docs/deploy/devops"> DevOps 工具</a> 结合,实现敏捷开发的新高度。
</p>

<h3 align="center">
🤖 🎨 🚀
</h3>


# 快速向导

## 启动华炎魔方

开发软件包之前,先启动花华炎魔方服务。

1. 将 .env 复制为 .env.local,并修改相关配置参数。
2. 使用 docker 启动华炎魔方。

```bash
docker-compose up
```

### Start steedos service
## 访问华炎魔方

```bash
yarn
yarn start
```
打开浏览器,访问 http://127.0.0.1:5000,进入华炎魔方。

Open [http://localhost:5000](http://localhost:5000) with your browser to see the result.
进入设置应用,可以:
- 创建自定义对象
- 创建应用
- 创建微页面

## Learn More
## 开发软件包

To learn more about Steedos Platform, take a look at the following resources:
可以使用微服务的方式扩展华炎魔方。可以参考 services 文件夹下的例子。

- [Steedos Documentation](https://www.steedos.com/docs) - learn about Steedos features and API.
- [Steedos Examples](https://github.com/steedos/steedos-examples) - Enjoy our selection of steedos examples to learn from or incorporate into your project.
```bash
yarn
yarn start
```

You can check out [the Steedos GitHub repository](https://github.com/steedos/steedos-platform/) - your feedback and contributions are welcome!
## 使用 Node-RED

## Deploy your project
[Node-Red](https://nodered.org/) 是 IBM 开源的服务端低代码开发工具,提供了可视化的开发环境,开发华炎魔方微服务。

The easiest way to deploy your Steedos app is to use the [Docker Template](https://github.com/steedos/docker).
- 创建定时任务
- 自定义微服务
- 自定义API
- 自定义触发器
- 接收和推送消息

Check out our [Steedos deployment documentation](https://www.steedos.com/docs/deploy/getting-started) for more details.
```bash
yarn nodered
```
56 changes: 42 additions & 14 deletions packages/create-steedos-app/templates/default/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,56 @@ version: "3.9"

services:

steedos:
image: steedos/steedos-community:2.4
ports:
- "5000:5000"
env_file:
- .env.local
environment:
- PORT=5000
- MONGO_URL=mongodb://mongodb:27017/steedos
- MONGO_OPLOG_URL=mongodb://mongodb:27017/local
- TRANSPORTER=nats://nats:4222
- CACHER=redis://redis:6379
depends_on:
mongodb:
condition: service_healthy

redis:
image: redis:6.2
command: "redis-server --save \"\" --appendonly no --loglevel warning"
ports:
- "6379:6379"

mongodb:
image: 'bitnami/mongodb:4.4'
restart: on-failure
image: mongo:4.4
ports:
- 27017:27017
environment:
- MONGODB_REPLICA_SET_MODE=primary
- MONGODB_PORT_NUMBER=${MONGODB_PORT_NUMBER:-27017}
- MONGODB_INITIAL_PRIMARY_HOST=${MONGODB_INITIAL_PRIMARY_HOST:-mongodb}
- MONGODB_INITIAL_PRIMARY_PORT_NUMBER=${MONGODB_INITIAL_PRIMARY_PORT_NUMBER:-27017}
- MONGODB_REPLICA_SET_NAME=${MONGODB_REPLICA_SET_NAME:-steedos}
- MONGODB_ENABLE_JOURNAL=${MONGODB_ENABLE_JOURNAL:-true}
- MONGODB_ADVERTISED_HOSTNAME=${MONGODB_ADVERTISED_HOSTNAME:-mongodb}
- ALLOW_EMPTY_PASSWORD=${ALLOW_EMPTY_PASSWORD:-yes}
entrypoint: [ "/usr/bin/mongod", "--bind_ip_all", "--replSet", "steedos" ]
healthcheck:
test: echo 'db.runCommand("ping").ok' | mongo --quiet | grep 1
interval: 10s
timeout: 10s
retries: 5
volumes:
- 'steedos-mongo-data:/bitnami'
- 'steedos-mongo-data:/data/db'

mongodb-init:
image: mongo:4.4
restart: "no"
depends_on:
mongodb:
condition: service_healthy
command: >
mongo --host mongodb:27017 --eval "rs.initiate({ _id: 'steedos', members: [{_id: 0, host: 'mongodb:27017'}]})"
# Micro Service Transporter
nats:
image: bitnami/nats
ports:
- "4222:4222"
- "8222:8222" # monitor port

volumes:
steedos-mongo-data:
steedos-mongo-data:
driver: local
47 changes: 34 additions & 13 deletions packages/create-steedos-app/templates/default/env
Original file line number Diff line number Diff line change
@@ -1,23 +1,44 @@
# 参考 https://www.steedos.cn/docs/deploy/steedos-config

PORT=5000
ROOT_URL=http://127.0.0.1:5000
TRANSPORTER=redis://127.0.0.1:6379
CACHER=redis://127.0.0.1:6379/1
TRANSPORTER=nats://127.0.0.1:4222
CACHER=redis://127.0.0.1:6379
MONGO_URL=mongodb://127.0.0.1:27017/steedos
MONGO_OPLOG_URL=mongodb://127.0.0.1:27017/local
# NODE_ENV=development

STEEDOS_NODEID=steedos-primary
# STEEDOS_CFS_STORE=local
# STEEDOS_STORAGE_DIR=./storage

STEEDOS_CFS_STORE=local
STEEDOS_STORAGE_DIR=./storage
# 初始安装的软件包
# STEEDOS_INITIAL_PACKAGES=@steedos-labs/project-ee,@steedos-labs/demo-ee,@steedos-labs/flows

# 身份验证
STEEDOS_TENANT_ENABLE_PASSWORD_LOGIN=true
STEEDOS_TENANT_TOKEN_SECRET=change-me
# STEEDOS_TENANT_ENABLE_PASSWORD_LOGIN=true
# STEEDOS_TENANT_TOKEN_SECRET=
# STEEDOS_TENANT_ENABLE_REGISTER=true

# VSCode 代码同步
# METADATA_SERVER=
# METADATA_APIKEY=

# 启用 Steedos ID 统一身份认证。
# STEEDOS_IDENTITY_OIDC_ENABLED=true
# STEEDOS_IDENTITY_OIDC_ISSUER=https://id.steedos.cn/realms/master
# STEEDOS_IDENTITY_OIDC_CONFIG_URL=https://id.steedos.cn/realms/master/.well-known/openid-configuration
# STEEDOS_IDENTITY_OIDC_CLIENT_ID=steedos-oidc-public
# STEEDOS_IDENTITY_OIDC_CLIENT_SECRET=none
# STEEDOS_IDENTITY_OIDC_NAME=Steedos ID

# Node-RED 配置
# NODERED_CREDENTIAL_SECRET=steedos

# 配置资产包 CDN 服务的网址
# STEEDOS_UNPKG_URL=https://unpkg.steedos.cn

# 绑定华炎云账户
STEEDOS_CLOUD_API_KEY=
STEEDOS_CLOUD_SPACE_ID=
# 配置 Amis 当前引用的版本号
# STEEDOS_AMIS_VERSION=2.7.2

# vscode 代码同步
METADATA_SERVER=
METADATA_APIKEY=
# 配置资产包的地址,多个资产包用,隔开
# STEEDOS_PUBLIC_PAGE_ASSETURLS=https://unpkg.steedos.cn/@steedos-widgets/amis-object@1.1/dist/assets.json
3 changes: 1 addition & 2 deletions packages/create-steedos-app/templates/default/gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

**/node_modules

.npmrc
.yarnrc
**/npm-error.log
**/yarn-error.log
**/lerna-debug.log
Expand All @@ -16,5 +14,6 @@ logs

.env.local
.steedos
.node-red

yarn.lock
40 changes: 40 additions & 0 deletions packages/create-steedos-app/templates/default/gitpod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
image: ecr.aws.steedos.cn/dockerhub/steedos/gitpod-workspace-base:2.2.3

# List the ports you want to expose and what to do when they are served. See https://www.gitpod.io/docs/config-ports/
ports:
- port: 5000
onOpen: ignore
visibility: public
- port: 6379
onOpen: ignore
- port: 27017
onOpen: ignore
visibility: public
- port: 4222
onOpen: ignore
- port: 8222
onOpen: ignore

# List the start up tasks. You can start them in parallel in multiple terminals. See https://www.gitpod.io/docs/config-start-tasks/
tasks:
- name: Docker
command: |
echo "ROOT_URL=$(gp url 5000)" >> .env.local
echo "METADATA_SERVER=$(gp url 5000)" >> .env.local
yarn
docker-compose up
- name: Nodejs Services
command: |
gp await-port 5000
yarn start
- name: Node-RED
command: |
gp await-port 5000
yarn nodered
vscode:
extensions:
- redhat.vscode-yaml
- steedos.steedosdx-vscode
- steedos.steedosdx-vscode-core
- ms-ceintl.vscode-language-pack-zh-hans
7 changes: 7 additions & 0 deletions packages/create-steedos-app/templates/default/lerna.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"packages": [
"services/*"
],
"version": "0.0.1",
"useNx": false
}

0 comments on commit b3dd929

Please sign in to comment.