updated docker-compose guide

pull/124/head
13621160019@163.com 2022-02-18 11:56:50 +08:00
parent 8ac293d4b3
commit ab4bb773f0
3 changed files with 65 additions and 80 deletions

View File

@ -9,16 +9,14 @@
### 配置 ### 配置
注一:这里的主机指的是**安装Docker的主机**, 这里的IP和账号密码都为假定的用来展示说明实际情况中用户需要根据自己的配置改为自己的具体的修改步骤会在“安装”中讲述 **注**这里的主机指的是安装Docker的主机, 这里的IP和账号密码都为假定的用来展示说明请酌情修改
注二:这里如果**安装数据库和安装Docker的主机为同一个主机那么数据库IP和主机IP修改为一个实际IP**即可这里是以数据库和安装Docker的主机不在同一个上举例的。 | -- | -- |
| ---------- | ----------- |
| -- | -- | | Host IP | 192.168.0.1 |
| ---------- | ----------- | | Database IP | 192.168.0.2 |
| 主机IP | 192.168.0.1 | | Database User | root |
| 数据库IP | 192.168.0.2 | | Database Password | !MyEMS1 |
| 数据库账号 | root |
| 数据库密码 | !MyEMS1 |
### 安装 ### 安装
@ -33,8 +31,10 @@ git clone https://gitee.com/myems/myems.git
cd myems/database/install cd myems/database/install
mysql -u root -p < myems_billing_baseline_db.sql mysql -u root -p < myems_billing_baseline_db.sql
mysql -u root -p < myems_billing_db.sql mysql -u root -p < myems_billing_db.sql
mysql -u root -p < myems_carbon_db.sql
mysql -u root -p < myems_energy_baseline_db.sql mysql -u root -p < myems_energy_baseline_db.sql
mysql -u root -p < myems_energy_db.sql mysql -u root -p < myems_energy_db.sql
mysql -u root -p < myems_energy_model_db.sql
mysql -u root -p < myems_fdd_db.sql mysql -u root -p < myems_fdd_db.sql
mysql -u root -p < myems_historical_db.sql mysql -u root -p < myems_historical_db.sql
mysql -u root -p < myems_reporting_db.sql mysql -u root -p < myems_reporting_db.sql
@ -57,12 +57,11 @@ sed -i 's/127.0.0.1:8000/192.168.0.1:8000/g' web/nginx.conf
3.2 复制example.env为.env并修改.env里的数据库IP账号密码 3.2 复制example.env为.env并修改.env里的数据库IP账号密码
``` ```
# 这里以修改数据库IP为例如果数据库账号密码也不同请根据自己需求替换.env里的账号密码
cd myems 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 cp myems-aggregation/example.env myems-aggregation/.env
sed -i 's/127.0.0.1/192.168.0.2/g' myems-aggregation/.env sed -i 's/127.0.0.1/192.168.0.2/g' myems-aggregation/.env
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-cleaning/example.env myems-cleaning/.env cp myems-cleaning/example.env myems-cleaning/.env
sed -i 's/127.0.0.1/192.168.0.2/g' 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 cp myems-modbus-tcp/example.env myems-modbus-tcp/.env
@ -76,12 +75,6 @@ sed -i 's/127.0.0.1/192.168.0.2/g' myems-normalization/.env
如果是Linux主机在api和admin服务中volumes/source使用 /upload 如果是Linux主机在api和admin服务中volumes/source使用 /upload
应确保api和admin共享同一主机文件夹。 应确保api和admin共享同一主机文件夹。
3.4 验证数据库连接
```
cd myems
python3 myems-api/test_mysql.py
```
4. 编译Web UI 4. 编译Web UI
``` ```
@ -99,12 +92,14 @@ docker-compose up -d
6. 验证 6. 验证
| | 网址 | 结果 | | | 网址 | 期望结果 |
| ----- | ----------------------- | ---------------- | | ----- | ----------------------- | ---------------- |
| web | 192.168.0.1:80 | 输入账号密码登录成功 | | web | 192.168.0.1:80 | 输入账号密码登录成功 |
| admin | 192.168.0.1:8001 | 输入账号密码登录成功 | | admin | 192.168.0.1:8001 | 输入账号密码登录成功 |
| api | 192.168.0.1:8000/version| 返回版本信息 | | api | 192.168.0.1:8000/version| 返回版本信息 |
如果api报错请确认.env里的数据库IP数据库账号数据库密码是否正确如果不正确请修改.env后执行
**注**如果api报错请确认.env里的数据库IP数据库账号数据库密码是否正确如果不正确请修改后执行
``` ```
docker-compose up --build -d docker-compose up --build -d
``` ```

View File

@ -1,67 +1,67 @@
## Docker Compose ## Docker Compose
Create and start all the services with a single command Erstellen und starten Sie alle Dienste mit einem einzigen Befehl
### Prerequisite ### Voraussetzung
- Installed docker、docker-compose、npm on a host. - Installed docker, docker-compose, npm on a host.
- Installed MySQL database with username 'root' and password '!MyEMS1'. - Installed MySQL database with username 'root' and password '!MyEMS1'.
- The MySQL database can be connected from the host where Docker is installed. - The MySQL database can be connected from the host where Docker is installed.
### Configuration ### Konfiguration
Note 1: 这里的主机指的是**安装Docker的主机**, 这里的IP和账号密码都为假定的用来展示说明实际情况中用户需要根据自己的配置改为自己的具体的修改步骤会在“安装”中讲述。 **Anmerkung**: Der Host hier bezieht sich auf den Host, auf dem Docker installiert ist. Die IP und das Account-Passwort werden hier angenommen und verwendet, um Anweisungen anzuzeigen. Bitte ändern Sie sie entsprechend.
Note 2: 这里如果**安装数据库和安装Docker的主机为同一个主机那么数据库IP和主机IP修改为一个实际IP**即可这里是以数据库和安装Docker的主机不在同一个上举例的。 | -- | -- |
| ---------- | ----------- |
| -- | -- | | Host IP | 192.168.0.1 |
| ---------- | ----------- | | Database IP | 192.168.0.2 |
| Host IP | 192.168.0.1 | | Database User | root |
| Database IP | 192.168.0.2 | | Database Password | !MyEMS1 |
| Database User | root |
| Database Password | !MyEMS1 |
### Installation ### Installation
1. Clone repository 1. Repository klonen
``` ```
git clone https://gitee.com/myems/myems.git git clone https://gitee.com/myems/myems.git
``` ```
2. Import database schema 2. Datenbankschema importieren
``` ```
cd myems/database/install cd myems/database/install
mysql -u root -p < myems_billing_baseline_db.sql mysql -u root -p < myems_billing_baseline_db.sql
mysql -u root -p < myems_billing_db.sql mysql -u root -p < myems_billing_db.sql
mysql -u root -p < myems_carbon_db.sql
mysql -u root -p < myems_energy_baseline_db.sql mysql -u root -p < myems_energy_baseline_db.sql
mysql -u root -p < myems_energy_db.sql mysql -u root -p < myems_energy_db.sql
mysql -u root -p < myems_energy_model_db.sql
mysql -u root -p < myems_fdd_db.sql mysql -u root -p < myems_fdd_db.sql
mysql -u root -p < myems_historical_db.sql mysql -u root -p < myems_historical_db.sql
mysql -u root -p < myems_reporting_db.sql mysql -u root -p < myems_reporting_db.sql
mysql -u root -p < myems_system_db.sql mysql -u root -p < myems_system_db.sql
mysql -u root -p < myems_user_db.sql mysql -u root -p < myems_user_db.sql
``` ```
Note: Refer to [database/README.md](./database/README.md) Anmerkung: Siehe unter [database/README.md](./database/README.md)
3. Modify Config 3. Konfiguration ändern
注:如“配置”所述,这里假定的**主机IP为 192.168.0.1数据库IP为 192.168.0.2数据库账号为root,数据库密码:!MyEMS1,用户应该修改为自己对应的主机IP,数据库IP,数据库账号,数据库密码** **Anmerkungen**Die Host-IP hier angenommen ist 192.168.0.1, die Datenbank-IP ist 192.168.0.2, das Datenbank-Konto ist: root und das Datenbank-Passwort ist: !MyEMS1, bitte ändern Sie dies entsprechend
3.1 Modify api address in nginx.conf 3.1 API-Adresse ändern in nginx.conf
``` ```
cd myems 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' admin/nginx.conf
sed -i 's/127.0.0.1:8000/192.168.0.1:8000/g' web/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 3.2 Beispiel example.env bis .env und Datenbank-IP, Benutzername und Passwort in .env
``` ```
cd myems 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 cp myems-aggregation/example.env myems-aggregation/.env
sed -i 's/127.0.0.1/192.168.0.2/g' myems-aggregation/.env sed -i 's/127.0.0.1/192.168.0.2/g' myems-aggregation/.env
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-cleaning/example.env myems-cleaning/.env cp myems-cleaning/example.env myems-cleaning/.env
sed -i 's/127.0.0.1/192.168.0.2/g' 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 cp myems-modbus-tcp/example.env myems-modbus-tcp/.env
@ -70,18 +70,12 @@ cp myems-normalization/example.env myems-normalization/.env
sed -i 's/127.0.0.1/192.168.0.2/g' 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 3.3 Upload-Ordner ändern in docker-compose.yml
If Windows host, use c:\upload for volumes/source in api and admin services. 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. 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. Make sure the upload folders in api and admin are same folder on host.
3.4 Validate database connection 4. Web UI erstellen
```
cd myems
python3 myems-api/test_mysql.py
```
4. Build Web UI
``` ```
cd myems/web cd myems/web
@ -89,7 +83,7 @@ npm i --unsafe-perm=true --allow-root --legacy-peer-deps
npm run build npm run build
``` ```
5. Run docker-compose command 5. Befehl Docker-compose ausführen
``` ```
cd myems cd myems
@ -98,12 +92,13 @@ docker-compose up -d
6. Verification 6. Verification
| | Address | Result | | | Address | Erwartetes Ergebnis |
| ----- | ----------------------- | ---------------- | | ----- | ----------------------- | ---------------- |
| web | 192.168.0.1:80 | 输入账号密码登录成功 | | web | 192.168.0.1:80 | Login erfolgreich durch Eingabe von Konto und Passwort |
| admin | 192.168.0.1:8001 | 输入账号密码登录成功 | | admin | 192.168.0.1:8001 | Login erfolgreich durch Eingabe von Konto und Passwort |
| api | 192.168.0.1:8000/version| 返回版本信息 | | api | 192.168.0.1:8000/version| Versionsinformationen zurückgeben |
如果api报错请确认.env里的数据库IP数据库账号数据库密码是否正确如果不正确请修改.env后执行
**注**Wenn die API einen Fehler meldet, bestätigen Sie bitte, ob die Datenbank-IP, das Datenbankkonto und das Datenbankkennwort in .env sind korrekt. Wenn nicht, ändern Sie sie bitte und führen Sie
``` ```
docker-compose up --build -d docker-compose up --build -d
``` ```

View File

@ -3,22 +3,20 @@ Create and start all the services with a single command
### Prerequisite ### Prerequisite
- Installed docker、docker-compose、npm on a host. - Installed docker, docker-compose, npm on a host.
- Installed MySQL database with username 'root' and password '!MyEMS1'. - Installed MySQL database with username 'root' and password '!MyEMS1'.
- The MySQL database can be connected from the host where Docker is installed. - The MySQL database can be connected from the host where Docker is installed.
### Configuration ### Configuration
Note 1: 这里的主机指的是**安装Docker的主机**, 这里的IP和账号密码都为假定的用来展示说明实际情况中用户需要根据自己的配置改为自己的具体的修改步骤会在“安装”中讲述。 **Note**: The host here refers to the host where docker is installed. The IP and account password here are assumed and used to show instructions. Please modify them as appropriate.
Note 2: 这里如果**安装数据库和安装Docker的主机为同一个主机那么数据库IP和主机IP修改为一个实际IP**即可这里是以数据库和安装Docker的主机不在同一个上举例的。 | -- | -- |
| ---------- | ----------- |
| -- | -- | | Host IP | 192.168.0.1 |
| ---------- | ----------- | | Database IP | 192.168.0.2 |
| Host IP | 192.168.0.1 | | Database User | root |
| Database IP | 192.168.0.2 | | Database Password | !MyEMS1 |
| Database User | root |
| Database Password | !MyEMS1 |
### Installation ### Installation
@ -33,8 +31,10 @@ git clone https://gitee.com/myems/myems.git
cd myems/database/install cd myems/database/install
mysql -u root -p < myems_billing_baseline_db.sql mysql -u root -p < myems_billing_baseline_db.sql
mysql -u root -p < myems_billing_db.sql mysql -u root -p < myems_billing_db.sql
mysql -u root -p < myems_carbon_db.sql
mysql -u root -p < myems_energy_baseline_db.sql mysql -u root -p < myems_energy_baseline_db.sql
mysql -u root -p < myems_energy_db.sql mysql -u root -p < myems_energy_db.sql
mysql -u root -p < myems_energy_model_db.sql
mysql -u root -p < myems_fdd_db.sql mysql -u root -p < myems_fdd_db.sql
mysql -u root -p < myems_historical_db.sql mysql -u root -p < myems_historical_db.sql
mysql -u root -p < myems_reporting_db.sql mysql -u root -p < myems_reporting_db.sql
@ -46,7 +46,7 @@ Note: Refer to [database/README.md](./database/README.md)
3. Modify Config 3. Modify Config
注:如“配置”所述,这里假定的**主机IP为 192.168.0.1数据库IP为 192.168.0.2数据库账号为root,数据库密码:!MyEMS1,用户应该修改为自己对应的主机IP,数据库IP,数据库账号,数据库密码** **Note**The host IP assumed here is 192.168.0.1, the database IP is 192.168.0.2, the database account is: root, and the database password is: !MyEMS1, please modify as appropriate
3.1 Modify api address in nginx.conf 3.1 Modify api address in nginx.conf
``` ```
@ -58,10 +58,10 @@ 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 3.2 Copy example.env to .env and modify database IP, username and password in .env
``` ```
cd myems 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 cp myems-aggregation/example.env myems-aggregation/.env
sed -i 's/127.0.0.1/192.168.0.2/g' myems-aggregation/.env sed -i 's/127.0.0.1/192.168.0.2/g' myems-aggregation/.env
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-cleaning/example.env myems-cleaning/.env cp myems-cleaning/example.env myems-cleaning/.env
sed -i 's/127.0.0.1/192.168.0.2/g' 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 cp myems-modbus-tcp/example.env myems-modbus-tcp/.env
@ -75,12 +75,6 @@ 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. 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. 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 4. Build Web UI
``` ```
@ -98,12 +92,13 @@ docker-compose up -d
6. Verification 6. Verification
| | Address | Result | | | Address | Expected Result |
| ----- | ----------------------- | ---------------- | | ----- | ----------------------- | ---------------- |
| web | 192.168.0.1:80 | 输入账号密码登录成功 | | web | 192.168.0.1:80 | Login succeeded by entering account and password |
| admin | 192.168.0.1:8001 | 输入账号密码登录成功 | | admin | 192.168.0.1:8001 | Login succeeded by entering account and password |
| api | 192.168.0.1:8000/version| 返回版本信息 | | api | 192.168.0.1:8000/version| Return version information |
如果api报错请确认.env里的数据库IP数据库账号数据库密码是否正确如果不正确请修改.env后执行
**Note**If the API reports an error, please confirm Whether the database IP, database account and database password in .env are correct. If not, please modify them then execute:
``` ```
docker-compose up --build -d docker-compose up --build -d
``` ```