updated readme for docker-compose

pull/103/head
13621160019@163.com 2021-12-26 22:47:29 +08:00
parent 9dfe7365c8
commit da14bd2376
6 changed files with 226 additions and 8 deletions

View File

@ -211,7 +211,7 @@ administrator@myems.io
### Docker-Compose 快速部署
详见 [Docker Compose 快速部署](docker-compose.md)
详见 [Docker Compose 快速部署](docker-compose-cn.md)

View File

@ -209,7 +209,7 @@ administrator@myems.io
### Docker Compose Schnelle Bereitstellung
Sehen [Docker Compose Schnelle Bereitstellung](docker-compose.md)
Sehen [Docker Compose Schnelle Bereitstellung](docker-compose-de.md)
## MyEMS Straßenkarte

View File

@ -211,7 +211,7 @@ administrator@myems.io
### Docker Compose Repaid Deployment
See [Docker Compose Repaid Deployment](docker-compose.md)
See [Docker Compose Repaid Deployment](docker-compose-en.md)
## MyEMS Roadmap

View File

@ -1,5 +1,5 @@
## Docker Compose 快速部署
除了上面的分步安装方式也可以使用docker-compose命令一键安装
## Docker Compose
除了分步安装方式也可以使用docker-compose命令一键安装
### 前提
@ -20,14 +20,14 @@
| 数据库账号 | root |
| 数据库密码 | !MyEMS1 |
### Docker-Compose安装
### 安装
1. 克隆仓库
```
git clone https://gitee.com/myems/myems.git
```
2. 数据库导入 (否则数据库没有用户信息,网页无法验证登录)
2. 导入数据库结构
```
cd myems/database/install
@ -41,7 +41,7 @@ mysql -u root -p < myems_reporting_db.sql
mysql -u root -p < myems_system_db.sql
mysql -u root -p < myems_user_db.sql
```
注: 如有问题,详情可查看"database/README.md"
注: 详情可查看[database/README.md](./database/README.md)
3. 修改配置

109
docker-compose-de.md Normal file
View File

@ -0,0 +1,109 @@
## Docker Compose
Create and start all the services with a single command
### Prerequisite
- Installed docker、docker-compose、npm on a host.
- Installed MySQL database with username 'root' and password '!MyEMS1'.
- The MySQL database can be connected from the host where Docker is installed.
### Configuration
Note 1: 这里的主机指的是**安装Docker的主机**, 这里的IP和账号密码都为假定的用来展示说明实际情况中用户需要根据自己的配置改为自己的具体的修改步骤会在“安装”中讲述。
Note 2: 这里如果**安装数据库和安装Docker的主机为同一个主机那么数据库IP和主机IP修改为一个实际IP**即可这里是以数据库和安装Docker的主机不在同一个上举例的。
| -- | -- |
| ---------- | ----------- |
| Host IP | 192.168.0.1 |
| Database IP | 192.168.0.2 |
| Database User | root |
| Database Password | !MyEMS1 |
### Installation
1. Clone repository
```
git clone https://gitee.com/myems/myems.git
```
2. Import database schema
```
cd myems/database/install
mysql -u root -p < myems_billing_baseline_db.sql
mysql -u root -p < myems_billing_db.sql
mysql -u root -p < myems_energy_baseline_db.sql
mysql -u root -p < myems_energy_db.sql
mysql -u root -p < myems_fdd_db.sql
mysql -u root -p < myems_historical_db.sql
mysql -u root -p < myems_reporting_db.sql
mysql -u root -p < myems_system_db.sql
mysql -u root -p < myems_user_db.sql
```
Note: Refer to [database/README.md](./database/README.md)
3. Modify Config
注:如“配置”所述,这里假定的**主机IP为 192.168.0.1数据库IP为 192.168.0.2数据库账号为root,数据库密码:!MyEMS1,用户应该修改为自己对应的主机IP,数据库IP,数据库账号,数据库密码**
3.1 Modify api address in nginx.conf
```
cd myems
sed -i 's/127.0.0.1:8000/192.168.0.1:8000/g' admin/nginx.conf
sed -i 's/127.0.0.1:8000/192.168.0.1:8000/g' web/nginx.conf
```
3.2 Copy example.env to .env and modify database IP, username and password in .env
```
cd myems
cp myems-api/example.env myems-api/.env
sed -i 's/127.0.0.1/192.168.0.2/g' myems-api/.env
cp myems-aggregation/example.env myems-aggregation/.env
sed -i 's/127.0.0.1/192.168.0.2/g' myems-aggregation/.env
cp myems-cleaning/example.env myems-cleaning/.env
sed -i 's/127.0.0.1/192.168.0.2/g' myems-cleaning/.env
cp myems-modbus-tcp/example.env myems-modbus-tcp/.env
sed -i 's/127.0.0.1/192.168.0.2/g' myems-modbus-tcp/.env
cp myems-normalization/example.env myems-normalization/.env
sed -i 's/127.0.0.1/192.168.0.2/g' myems-normalization/.env
```
3.3 Modify upload folder in docker-compose.yml
If Windows host, use c:\upload for volumes/source in api and admin services.
If Linux host, use /upload for volumes/source in api and admin services.
Make sure the upload folders in api and admin are same folder on host.
3.4 Validate database connection
```
cd myems
python3 myems-api/test_mysql.py
```
4. Build Web UI
```
cd myems/web
npm i --unsafe-perm=true --allow-root --legacy-peer-deps
npm run build
```
5. Run docker-compose command
```
cd myems
docker-compose up -d
```
6. Verification
| | Address | Result |
| ----- | ----------------------- | ---------------- |
| web | 192.168.0.1:80 | 输入账号密码登录成功 |
| admin | 192.168.0.1:8001 | 输入账号密码登录成功 |
| api | 192.168.0.1:8000/version| 返回版本信息 |
如果api报错请确认.env里的数据库IP数据库账号数据库密码是否正确如果不正确请修改.env后执行
```
docker-compose up --build -d
```

109
docker-compose-en.md Normal file
View File

@ -0,0 +1,109 @@
## Docker Compose
Create and start all the services with a single command
### Prerequisite
- Installed docker、docker-compose、npm on a host.
- Installed MySQL database with username 'root' and password '!MyEMS1'.
- The MySQL database can be connected from the host where Docker is installed.
### Configuration
Note 1: 这里的主机指的是**安装Docker的主机**, 这里的IP和账号密码都为假定的用来展示说明实际情况中用户需要根据自己的配置改为自己的具体的修改步骤会在“安装”中讲述。
Note 2: 这里如果**安装数据库和安装Docker的主机为同一个主机那么数据库IP和主机IP修改为一个实际IP**即可这里是以数据库和安装Docker的主机不在同一个上举例的。
| -- | -- |
| ---------- | ----------- |
| Host IP | 192.168.0.1 |
| Database IP | 192.168.0.2 |
| Database User | root |
| Database Password | !MyEMS1 |
### Installation
1. Clone repository
```
git clone https://gitee.com/myems/myems.git
```
2. Import database schema
```
cd myems/database/install
mysql -u root -p < myems_billing_baseline_db.sql
mysql -u root -p < myems_billing_db.sql
mysql -u root -p < myems_energy_baseline_db.sql
mysql -u root -p < myems_energy_db.sql
mysql -u root -p < myems_fdd_db.sql
mysql -u root -p < myems_historical_db.sql
mysql -u root -p < myems_reporting_db.sql
mysql -u root -p < myems_system_db.sql
mysql -u root -p < myems_user_db.sql
```
Note: Refer to [database/README.md](./database/README.md)
3. Modify Config
注:如“配置”所述,这里假定的**主机IP为 192.168.0.1数据库IP为 192.168.0.2数据库账号为root,数据库密码:!MyEMS1,用户应该修改为自己对应的主机IP,数据库IP,数据库账号,数据库密码**
3.1 Modify api address in nginx.conf
```
cd myems
sed -i 's/127.0.0.1:8000/192.168.0.1:8000/g' admin/nginx.conf
sed -i 's/127.0.0.1:8000/192.168.0.1:8000/g' web/nginx.conf
```
3.2 Copy example.env to .env and modify database IP, username and password in .env
```
cd myems
cp myems-api/example.env myems-api/.env
sed -i 's/127.0.0.1/192.168.0.2/g' myems-api/.env
cp myems-aggregation/example.env myems-aggregation/.env
sed -i 's/127.0.0.1/192.168.0.2/g' myems-aggregation/.env
cp myems-cleaning/example.env myems-cleaning/.env
sed -i 's/127.0.0.1/192.168.0.2/g' myems-cleaning/.env
cp myems-modbus-tcp/example.env myems-modbus-tcp/.env
sed -i 's/127.0.0.1/192.168.0.2/g' myems-modbus-tcp/.env
cp myems-normalization/example.env myems-normalization/.env
sed -i 's/127.0.0.1/192.168.0.2/g' myems-normalization/.env
```
3.3 Modify upload folder in docker-compose.yml
If Windows host, use c:\upload for volumes/source in api and admin services.
If Linux host, use /upload for volumes/source in api and admin services.
Make sure the upload folders in api and admin are same folder on host.
3.4 Validate database connection
```
cd myems
python3 myems-api/test_mysql.py
```
4. Build Web UI
```
cd myems/web
npm i --unsafe-perm=true --allow-root --legacy-peer-deps
npm run build
```
5. Run docker-compose command
```
cd myems
docker-compose up -d
```
6. Verification
| | Address | Result |
| ----- | ----------------------- | ---------------- |
| web | 192.168.0.1:80 | 输入账号密码登录成功 |
| admin | 192.168.0.1:8001 | 输入账号密码登录成功 |
| api | 192.168.0.1:8000/version| 返回版本信息 |
如果api报错请确认.env里的数据库IP数据库账号数据库密码是否正确如果不正确请修改.env后执行
```
docker-compose up --build -d
```