updated README for Docker

pull/60/head
13621160019@163.com 2021-08-06 18:45:51 +08:00
parent 0b3457d7b9
commit 14cec6a333
8 changed files with 66 additions and 132 deletions

View File

@ -42,10 +42,6 @@ MyEMS项目由下列组件构成:
[安装 myems-modbus-tcp](./myems-modbus-tcp/README.md)
### MyEMS MQTT数据转发服务 (Python)
[安装 myems-mqtt-publisher](./myems-mqtt-publisher/README.md)
### MyEMS 数据清洗服务 (Python)
[安装 myems-cleaning](./myems-cleaning/README.md)
@ -64,50 +60,41 @@ MyEMS项目由下列组件构成:
### Docker Docker-compose 安装
```
# 假定你的本机IP为: 192.168.2.3 MySQL所在IP为: 192.168.2.2
# 步骤一: 克隆仓库
git clone https://gitee.com/myems/myems.git
```
# 步骤二: 修改IP地址
# 你应该修改所有文件夹下中config.py的host为你的本机IP
修改以下文件中的数据库IP
假定数据库IP为: 192.168.2.2
```
sudo nano myems-api/config.py
sudo nano myems-aggregation/config.py
sudo nano myems-cleaning/config.py
sudo nano myems-modbus-tcp/config.py
sudo nano myems-normalization/config.py
# host: '127.0.0.1' => 'host': '192.168.2.2', (127.0.0.1 => mysql_ip)
# 你应该修改web,admin下中nginx.conf的127.0.0.1为你的本机IP
# host: '127.0.0.1' => 'host': '192.168.2.2'
```
修改web和admin文件夹下nginx.conf中的location '/api'
假定本机IP为: 192.168.2.3
```
sudo nano admin/nginx.conf
sudo nano web/nginx.conf
# proxy_pass http://127.0.0.1:8000/; => proxy_pass http://192.168.2.3:8000/; (127.0.0.1 => local_ip)
# 步骤三: 将'web'打包生成静态文件 (React)
# proxy_pass http://127.0.0.1:8000/; => proxy_pass http://192.168.2.3:8000/;
```
将Web打包生成产品文件
```
cd myems/web
npm install
npm run build
# 步骤四: 使用docker-compose安装
```
使用docker-compose安装
```
cd myems
docker-compose up -d
# 步骤五: 测试是否成功 (use local_ip:192.168.2.3)
谷歌浏览器打开:
web page: http://192.168.2.3:8001 - 用户administrator@myems.io 密码: !MyEMS1
admin page: http://192.168.2.3:8002 - 用户administrator 密码: !MyEMS1
rest api: http://192.168.2.3:8000/spaces
```
## 功能版本对比

View File

@ -43,10 +43,6 @@ Dieses Projekt besteht aus folgenden Komponenten:
[Installieren myems-modbus-tcp](./myems-modbus-tcp/README.md)
### MyEMS MQTT Data vorwärts Service (Python)
[Installieren myems-mqtt-publisher](./myems-mqtt-publisher/README.md)
### MyEMS Cleaning Service (Python)
[Installieren myems-cleaning](./myems-cleaning/README.md)
@ -64,60 +60,39 @@ Dieses Projekt besteht aus folgenden Komponenten:
[Installieren web UI](./web/README.md)
### Docker Docker-compose Installieren
```
# Angenommen, Ihre lokale IP: 192.168.2.3 und mysql IP: 192.168.2.2
# Schritt 01: Klon
git clone https://gitee.com/myems/myems.git
```
# Schritt 02: Ändern Sie die IP (mysql_ip: 192.168.2.2)
# Sie sollten den Host von config.py:
Ändern Sie die Datenbankkonfiguration in den folgenden Dateien
Angenommen, die Datenbank-IP lautet 192.168.2.2
```
sudo nano myems-api/config.py
sudo nano myems-aggregation/config.py
sudo nano myems-cleaning/config.py
sudo nano myems-modbus-tcp/config.py
sudo nano myems-normalization/config.py
# host: '127.0.0.1' => 'host': '192.168.2.2', (127.0.0.1 => mysql_ip)
# Sie sollten den proxy_pass von nginx.conf:
# host: '127.0.0.1' => 'host': '192.168.2.2'
```
Ändern Sie den location '/api' von nginx.conf in web und admin
Angenommen, die Host-IP lautet 192.168.2.3
```
sudo nano admin/nginx.conf
sudo nano web/nginx.conf
# proxy_pass http://127.0.0.1:8000/; => proxy_pass http://192.168.2.3:8000/; (127.0.0.1 => local_ip)
# Schritt 03: Generieren Sie die statische Richtung: 'build' for web (react)
# proxy_pass http://127.0.0.1:8000/; => proxy_pass http://192.168.2.3:8000/;
```
Verpacken Sie das web, um Produktdateien zu generieren
```
cd myems/web
npm install
npm run build
# Schritt 04: Installieren
cd myems
docker-compose up -d
# Schritt 05: Prüfen (lokale ip: 192.168.2.3)
# mit dem Google-Browser öffnen
web: http://192.168.2.3:8001 - Benutzeradministrator@myems.io Passwort !MyEMS1
admin: http://192.168.2.3:8002 - Benutzeradministrator Passwort !MyEMS1
api: http://192.168.2.3:8000/spaces
```
### Docker Docker-compose
Mit docker-compose installieren
```
git clone https://gitee.com/myems/myems.git
# for generate the static direction: 'build'
cd myems/web
npm install
npm run build
cd myems
docker-compose up -d
```

View File

@ -43,10 +43,6 @@ This project is compose of following components:
[Install myems-modbus-tcp](./myems-modbus-tcp/README.md)
### MyEMS MQTT Data Forwarding Service (Python)
[Install myems-mqtt-publisher](./myems-mqtt-publisher/README.md)
### MyEMS Cleaning Service (Python)
[Install myems-cleaning](./myems-cleaning/README.md)
@ -64,65 +60,43 @@ This project is compose of following components:
[Install web UI](./web/README.md)
### Docker Docker-compose
```
git clone https://gitee.com/myems/myems.git
# for generate the static direction: 'build'
cd myems/web
npm install
npm run build
cd myems
docker-compose up -d
```
### Docker Docker-compose Install
修改文件夹下config.py中的host为数据库IP
假定数据库IP为: 192.168.2.2
```
# Supposed that your local ip is: 192.168.2.3 and mysql ip is: 192.168.2.2
# Step 01: Clone
git clone https://gitee.com/myems/myems.git
# Step 02: Modify the ip (use mysql_ip: 192.168.2.2)
# You should modify the host of config.py in these directions:
sudo nano myems-api/config.py
sudo nano myems-aggregation/config.py
sudo nano myems-cleaning/config.py
sudo nano myems-modbus-tcp/config.py
sudo nano myems-normalization/config.py
# host: '127.0.0.1' => 'host': '192.168.2.2', (127.0.0.1 => mysql_ip)
# You should modify the proxy_pass of nginx.conf in these directions:
# host: '127.0.0.1' => 'host': '192.168.2.2'
```
修改web,admin下中nginx.conf的127.0.0.1为本机IP
假定本机IP为: 192.168.2.3
```
sudo nano admin/nginx.conf
sudo nano web/nginx.conf
# proxy_pass http://127.0.0.1:8000/; => proxy_pass http://192.168.2.3:8000/; (127.0.0.1 => local_ip)
# Step 03: Generate the static direction: 'build' for web (react)
# proxy_pass http://127.0.0.1:8000/; => proxy_pass http://192.168.2.3:8000/;
```
将Web打包生成产品文件
```
cd myems/web
npm install
npm run build
# Step 04: Install
```
使用docker-compose安装
```
cd myems
docker-compose up -d
# Step 05: Test (use local_ip: 192.168.2.3)
# open with the google browser
web page: http://192.168.2.3:8001 - useradministrator@myems.io password !MyEMS1
admin page: http://192.168.2.3:8002 - useradministrator password !MyEMS1
rest api: http://192.168.2.3:8000/spaces
```
## Compare Editions
| Features | Community Edition | Enterprise Edition | Explanation |

6
admin/Dockerfile vendored
View File

@ -3,10 +3,10 @@ FROM nginx
# remove the config
RUN rm /etc/nginx/conf.d/default.conf && \
rm /etc/nginx/nginx.conf && \
mkdir -p /usr/share/nginx/admin
mkdir -p /var/www/html/admin
# copy the config and web codes
COPY nginx.conf /etc/nginx/
COPY . /usr/share/nginx/admin
EXPOSE 80
COPY . /var/www/html/admin
EXPOSE 8001
CMD ['nginx', '-c /etc/nginx/nginx.conf', '-g "daemon off;"']

8
admin/nginx.conf vendored
View File

@ -26,13 +26,13 @@ http {
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
listen 8001;
server_name myems-admin;
#access_log /var/log/nginx/host.access.log main;
location / {
root /usr/share/nginx/admin;
root /var/www/html/admin;
index index.html index.htm;
}
@ -42,7 +42,7 @@ http {
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
root /var/www/html/admin;
}
location /api {

View File

@ -34,7 +34,7 @@ services:
test: [ "CMD","nginx","-t" ]
restart: always
ports:
- "8001:80"
- "8001:8001"
web:
build: ./web
command: nginx -c /etc/nginx/nginx.conf -g "daemon off;"
@ -42,4 +42,4 @@ services:
test: [ "CMD","nginx","-t" ]
restart: always
ports:
- "8002:80"
- "80:80"

8
web/Dockerfile vendored
View File

@ -3,12 +3,10 @@ FROM nginx
# remove the config
RUN rm /etc/nginx/conf.d/default.conf && \
rm /etc/nginx/nginx.conf && \
mkdir -p /usr/share/nginx/web
mkdir -p /var/www/html/web
# copy the config and web codes
# Attention:
# You should run 'npm run build' in the web direction to generate the build direction because this's a react projection.
# Note: You should run 'npm run build' in the web direction to generate the production build.
COPY nginx.conf /etc/nginx/
COPY ./build/ /usr/share/nginx/web
COPY ./build/ /var/www/html/web
EXPOSE 80
CMD ['nginx', '-c /etc/nginx/nginx.conf', '-g "daemon off;"']

6
web/nginx.conf vendored
View File

@ -26,12 +26,12 @@ http {
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
server_name myems-web;
#access_log /var/log/nginx/host.access.log main;
location / {
root /usr/share/nginx/web;
root /var/www/html/web;
index index.html index.htm;
}
@ -41,7 +41,7 @@ http {
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
root /var/www/html/web;
}
location /api {