Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add one click startup script by docker compose #405

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
124 changes: 124 additions & 0 deletions docker/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
# config for myems_system_db
MYEMS_SYSTEM_DB_HOST=mysql
MYEMS_SYSTEM_DB_PORT=3306
MYEMS_SYSTEM_DB_DATABASE=myems_system_db
MYEMS_SYSTEM_DB_USER=root
MYEMS_SYSTEM_DB_PASSWORD=!MyEMS1

# config for myems_energy_db
MYEMS_ENERGY_DB_HOST=mysql
MYEMS_ENERGY_DB_PORT=3306
MYEMS_ENERGY_DB_DATABASE=myems_energy_db
MYEMS_ENERGY_DB_USER=root
MYEMS_ENERGY_DB_PASSWORD=!MyEMS1

# config for myems_energy_baseline_db
MYEMS_ENERGY_BASELINE_DB_HOST=mysql
MYEMS_ENERGY_BASELINE_DB_PORT=3306
MYEMS_ENERGY_BASELINE_DB_DATABASE=myems_energy_baseline_db
MYEMS_ENERGY_BASELINE_DB_USER=root
MYEMS_ENERGY_BASELINE_DB_PASSWORD=!MyEMS1

# config for myems_energy_plan_db
MYEMS_ENERGY_PLAN_DB_HOST=mysql
MYEMS_ENERGY_PLAN_DB_PORT=3306
MYEMS_ENERGY_PLAN_DB_DATABASE=myems_energy_plan_db
MYEMS_ENERGY_PLAN_DB_USER=root
MYEMS_ENERGY_PLAN_DB_PASSWORD=!MyEMS1

# config for myems_billing_db
MYEMS_BILLING_DB_HOST=mysql
MYEMS_BILLING_DB_PORT=3306
MYEMS_BILLING_DB_DATABASE=myems_billing_db
MYEMS_BILLING_DB_USER=root
MYEMS_BILLING_DB_PASSWORD=!MyEMS1

# config for myems_billing_baseline_db
MYEMS_BILLING_BASELINE_DB_HOST=mysql
MYEMS_BILLING_BASELINE_DB_PORT=3306
MYEMS_BILLING_BASELINE_DB_DATABASE=myems_billing_baseline_db
MYEMS_BILLING_BASELINE_DB_USER=root
MYEMS_BILLING_BASELINE_DB_PASSWORD=!MyEMS1

# config for myems_historical_db
MYEMS_HISTORICAL_DB_HOST=mysql
MYEMS_HISTORICAL_DB_PORT=3306
MYEMS_HISTORICAL_DB_DATABASE=myems_historical_db
MYEMS_HISTORICAL_DB_USER=root
MYEMS_HISTORICAL_DB_PASSWORD=!MyEMS1

# config for myems_user_db
MYEMS_USER_DB_HOST=mysql
MYEMS_USER_DB_PORT=3306
MYEMS_USER_DB_DATABASE=myems_user_db
MYEMS_USER_DB_USER=root
MYEMS_USER_DB_PASSWORD=!MyEMS1

# config for myems_fdd_db
MYEMS_FDD_DB_HOST=mysql
MYEMS_FDD_DB_PORT=3306
MYEMS_FDD_DB_DATABASE=myems_fdd_db
MYEMS_FDD_DB_USER=root
MYEMS_FDD_DB_PASSWORD=!MyEMS1

# config for myems_reporting_db
MYEMS_REPORTING_DB_HOST=mysql
MYEMS_REPORTING_DB_PORT=3306
MYEMS_REPORTING_DB_DATABASE=myems_reporting_db
MYEMS_REPORTING_DB_USER=root
MYEMS_REPORTING_DB_PASSWORD=!MyEMS1

# config for myems_carbon_db
MYEMS_CARBON_DB_HOST=mysql
MYEMS_CARBON_DB_PORT=3306
MYEMS_CARBON_DB_DATABASE=myems_carbon_db
MYEMS_CARBON_DB_USER=root
MYEMS_CARBON_DB_PASSWORD=!MyEMS1

# config for mqtt broker
MYEMS_MQTT_BROKER_HOST=mysql
MYEMS_MQTT_BROKER_PORT=1883
MYEMS_MQTT_BROKER_USERNAME=admin
MYEMS_MQTT_BROKER_PASSWORD=!MyEMS1

# indicated in how many minutes to calculate meter energy consumption
# 30 for half hourly period
# 60 for hourly period
# the default value is 60
MINUTES_TO_COUNT=60

# indicates the project's time zone offset from UTC
# the default value is +08:00
UTC_OFFSET=+08:00

# indicates from when ( in local timezone) of the day to calculate working days
# the default value is 00:00:00
WORKING_DAY_START_TIME_LOCAL=00:00:00

# indicates where user uploaded files will be saved to
# must use the root folder of myems-admin web application
# for example if you serve myems-admin at /var/www/myems-admin
# you should set the upload_path as below
# the default value is /var/www/myems-admin/upload/
UPLOAD_PATH=/var/www/myems-admin/upload/

# main currency unit
# the default value is CNY
CURRENCY_UNIT=CNY

# maximum failed login count, otherwise the user should be locked
# the default value is 3
MAXIMUM_FAILED_LOGIN_COUNT=3

# indicates if the tariff appended to parameters data
# the default value is True
IS_TARIFF_APPENDED=True

# indicates if search meters recursively by space tree
# this config is used in meter tracking report and in meter batch report
# the default value is True
IS_RECURSIVE=True

# indicates how long in second the user session expires
# the default value is 60 * 60 * 8 = 28800
SESSION_EXPIRES_IN_SECONDS=28800
9 changes: 9 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
## 一键启动MyEMS

```
docker compose up
```

## 数据库脚本

./docker/mysql/init/init.sql
98 changes: 98 additions & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
version: '3.8'
services:
api:
image: myems/myems-api:4.7.0
command: gunicorn app:api -b 0.0.0.0:8000 --timeout 600 --workers=4
volumes:
- ./myems-upload:/var/www/myems-admin/upload
restart: always
env_file:
- .env
ports:
- "8000:8000"
depends_on:
- mysql

aggregation:
image: myems/myems-aggregation:4.7.0
command: python main.py
restart: always
env_file:
- .env
depends_on:
- mysql

cleaning:
image: myems/myems-cleaning:4.7.0
command: python main.py
restart: always
env_file:
- .env
depends_on:
- mysql

modbus_tcp:
image: myems/myems-modbus-tcp:4.7.0
command: python main.py
restart: always
env_file:
- .env
depends_on:
- mysql

normalization:
image: myems/myems-normalization:4.7.0
command: python main.py
restart: always
env_file:
- .env
depends_on:
- mysql

admin:
image: myems/myems-admin:4.7.0
command: nginx -c /etc/nginx/nginx.conf -g "daemon off;"
healthcheck:
test: [ "CMD","nginx","-t" ]
volumes:
- ./myems-upload:/var/www/myems-admin/upload
restart: always
ports:
- "8001:8001"
depends_on:
- mysql
- api

web:
image: myems/myems-web:4.3.0
command: nginx -c /etc/nginx/nginx.conf -g "daemon off;"
volumes:
- ./nginx/nginx.conf:/etc/nginx/nginx.conf
healthcheck:
test: [ "CMD","nginx","-t" ]
restart: always
ports:
- "8002:80"
depends_on:
- mysql
- api

mysql:
image: bitnami/mysql:8.4
restart: always
environment:
TZ: Asia/Shanghai
MYSQL_ROOT_PASSWORD: '!MyEMS1'
ports:
- 3306:3306
volumes:
- 'mysql_data:/bitnami/mysql/data'
- ./mysql/init:/docker-entrypoint-initdb.d
healthcheck:
test: ['CMD', '/opt/bitnami/scripts/mysql/healthcheck.sh']
interval: 15s
timeout: 5s
retries: 6
volumes:
mysql_data:
driver: local
Loading