1 Star 0 Fork 3

SerPai / myems

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
docker-compose-de.md 3.62 KB
一键复制 编辑 原始数据 按行查看 历史
Guangyu Zhang 提交于 2021-12-26 22:47 . updated readme for docker-compose

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 
  1. 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

  1. 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
  1. Build Web UI
cd myems/web
npm i --unsafe-perm=true --allow-root --legacy-peer-deps
npm run build
  1. Run docker-compose command
cd myems
docker-compose up -d 
  1. 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
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/Ser/myems.git
git@gitee.com:Ser/myems.git
Ser
myems
myems
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891